Commit graph

7 commits

Author SHA1 Message Date
Lars Sundström
5817e72d0d IOS7: Implement Apple GCVirtualController
Apple introduced the GCVirtualController in iOS 15 which is a
software emulation of a real controller. The virtual controllers
can be configurable with different inputs. See more info at:
https://developer.apple.com/documentation/gamecontroller/gcvirtualcontroller

A simple gamepad configuration with a dPad and A and B buttons
is added. The user can enable/disable the virtual game controller
swiping two fingers right to left, or through the port-specific
option dialog.
2023-05-05 22:35:03 +02:00
Lars Sundström
045ddca927 IOS7: Add dpad actions to gamepad controller
Some game engines requires the dpad to control a character. The GRIM
engine is an example of this where the user steer the character by
the arrow keys or dpad controller.
2023-05-05 22:35:03 +02:00
Lars Sundström
235ebcbfb8 IOS7: Fix compiler warnings
This commit fixes the compiler warnings regarding:
- The local declaration of 'view' hides instance variable [-Wshadow-ivar]
- Some of the gamepad controller buttons is only available in specific
versions of iOS and tvOS.
- Use of non-standard escape character '\E'. \E is a GNU shortcut.
2023-01-29 21:13:52 +00:00
Lars Sundström
fde0aa965d IOS7: Add general handling of the menu button on game controllers
Expose the handleMainMenuKey function and call that when pressing the
menu button on game controllers.
2023-01-29 21:13:52 +00:00
Lars Sundström
5aeef796bc IOS7: Implement support for Apple TV remote
The Apple TV remote has a touch area which functions as a touch
controller. It also has a few buttons that can be programmed for
different actions.

The "touchpad mode" is not really relevant for the Apple TV remote.
However the pointer should be moved when swiping on the touch area
on the remote. Since we don't want to generate actions on touchBegan
and touchEnded for the remote, make sure these are only triggered if
the touch is made on direct contact with the screen, UITouchTypeDirect.

Implement the button handling by implement the microGamepad profile in
the GamepadController class. Only buttons A, X and the menu buttons are
relevant since the touch area is using the touch controller class.
The tvOS simulator however doesn't call the lambda functions defined for
the microGamepad buttons, hence the implementation of the "pressesBegan"
and "pressesEnded" which is called instead when running the simulator.

Implement common handling of the menu button. If the menu button is
pressed the soft keyboard will be shown. If pressing the menu button
again the soft keyboard will be hidden. If pressing the menu button
a third time the application will be suspended.

Implement new gesture recognizers that can be used with the Apple TV
remote. Up/down/left/right actions are triggered on press on the arrow
buttons, or tap on the edges of the touch area.

A long press, 5 seconds, of "Play/Pause" button toggles Mouse-click-and-
drag mode needed by some games.
2023-01-29 21:13:51 +00:00
Lars Sundström
d76bc708c0 IOS7: Add isConnected property to GameControllers 2022-08-08 21:08:56 +01:00
Lars Sundström
8d395fd790 IOS7: Add support for Extended Gamepad controllers
Add support for Extended Gamepad controllers. What defines extended
gamepad controllers can be found here:
https://developer.apple.com/documentation/gamecontroller/gcextendedgamepad

Support has been added for controlling the pointer position using the
left thumbstick, left clicks using the A-button and right clicks using
the B-button. Also the Main menu can be accessed using the Home/Menu
button.

The thumbstick values are received when changed, however if holding the
thumbstick in the same position the valueChangedHandler will not be
called. Therefore store the X- and Y-axis values and begin to poll
readings of the stored values for as long as the thumbstick is out of
the center position.
2022-08-08 21:08:56 +01:00