diff options
author | Mike Krus <mike.krus@kdab.com> | 2016-02-13 23:25:30 +0000 |
---|---|---|
committer | Andy Nichols <andy.nichols@qt.io> | 2016-05-31 12:55:48 +0000 |
commit | c64fa3b36bbc68a936f6a063ab048b406e1a22e2 (patch) | |
tree | 80bcf475af4ecf61c90b67b88f7755ad6a723995 | |
parent | ecd0a55a0bfbcb597de5550e2be96e52b9ec27c5 (diff) |
Added support to tvOS remote (microGamepad)
Play/Pause buttons is X
Menu button is play/pause (don’t ask)
Press touch area is A
Touch area is left thumbstick
Change-Id: Idd51e8e4e8f20397475df801af42b82865f4c328
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
-rw-r--r-- | src/plugins/gamepads/darwin/qdarwingamepadbackend.mm | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/src/plugins/gamepads/darwin/qdarwingamepadbackend.mm b/src/plugins/gamepads/darwin/qdarwingamepadbackend.mm index 6da7650..71e8761 100644 --- a/src/plugins/gamepads/darwin/qdarwingamepadbackend.mm +++ b/src/plugins/gamepads/darwin/qdarwingamepadbackend.mm @@ -436,8 +436,51 @@ Q_ARG(QGamepadManager::GamepadButton, QGamepadManager::ButtonY)); } }]; - } +#ifdef Q_OS_TVOS + else if (controller.microGamepad) { + //leftThumbstick + [controller.microGamepad.dpad setValueChangedHandler:^(GCControllerDirectionPad *dpad, float xValue, float yValue) { + Q_UNUSED(dpad) + QMetaObject::invokeMethod(backend, "darwinGamepadAxisMoved", Qt::AutoConnection, + Q_ARG(int, index), + Q_ARG(QGamepadManager::GamepadAxis, QGamepadManager::AxisLeftX), + Q_ARG(double, xValue)); + QMetaObject::invokeMethod(backend, "darwinGamepadAxisMoved", Qt::AutoConnection, + Q_ARG(int, index), + Q_ARG(QGamepadManager::GamepadAxis, QGamepadManager::AxisLeftY), + Q_ARG(double, -yValue)); + }]; + //buttonA + [controller.microGamepad.buttonA setValueChangedHandler:^(GCControllerButtonInput *button, float value, BOOL pressed) { + Q_UNUSED(button) + if (pressed) { + QMetaObject::invokeMethod(backend, "darwinGamepadButtonPressed", Qt::AutoConnection, + Q_ARG(int, index), + Q_ARG(QGamepadManager::GamepadButton, QGamepadManager::ButtonA), + Q_ARG(double, value)); + } else { + QMetaObject::invokeMethod(backend, "darwinGamepadButtonReleased", Qt::AutoConnection, + Q_ARG(int, index), + Q_ARG(QGamepadManager::GamepadButton, QGamepadManager::ButtonA)); + } + }]; + //buttonX + [controller.microGamepad.buttonX setValueChangedHandler:^(GCControllerButtonInput *button, float value, BOOL pressed) { + Q_UNUSED(button) + if (pressed) { + QMetaObject::invokeMethod(backend, "darwinGamepadButtonPressed", Qt::AutoConnection, + Q_ARG(int, index), + Q_ARG(QGamepadManager::GamepadButton, QGamepadManager::ButtonX), + Q_ARG(double, value)); + } else { + QMetaObject::invokeMethod(backend, "darwinGamepadButtonReleased", Qt::AutoConnection, + Q_ARG(int, index), + Q_ARG(QGamepadManager::GamepadButton, QGamepadManager::ButtonX)); + } + }]; + } +#endif } -(void)removeMonitoredController:(GCController *)controller |