iOS7 Add pointer device support #4032
Setting this property to true indicates the view controller’s preference to lock the pointer, although the system may not honor the request. For the system to consider locking the pointer: The scene must be full screen, not in Split View or Slide Over, with no other apps in Slide Over. The scene must be in the UISceneActivationStateForegroundActive state. The ScummVM iOS7 client fulfills the above so the pointer is locked. Locking the pointer hides the OS cursor (the dot), however that's wanted since the ScummVM engine draws its own pointer.
Squash with the one above
For game controllers, I'd recommend sending controller events to allow the iOS port to make better use of the keymapper instead of using a hard-coded mapping in the iOS 7 backend. There are some details about this here: https://wiki.scummvm.org/index.php?title=Keymapper
Add a GameController base class which handles user inputs from a controller. The input is either a pointer move or a button action. If the input is a pointer move, make sure that the move is within valid coordinates in the game (respecting the resolution which is most probably lower than the view resolution).
Move touch inputs to a TouchController class to move some logic from the iPhoneView class. Only do this for touches on screen since connected trackpads can generate touches as well. The latter ones are of type UITouchTypeIndirectPointer while touches on screen are of type UITouchTypeDirect. They are separated thanks to the preference key UIApplicationSupportsIndirectInputEvents set to YES in Info.plist. Without the preference above, there is no way to distinguish touches from screen from a trackpad.
Add support for mouses using the GameController framework. This requires iOS 14 and up. The trackpad on the magic keyboard to iPads is connected as a mouse and of course other connected mouses. The mouse movements triggers calls to the mouseMovedHandler code block. The calls delivers delta movements on the X and Y axis from the last pointer position. It doesn't keep track on where the pointer is in the view. That's where pointerPosition property in the iPhoneView comes into place.
Joystick actions are suitable for joysticks and gamepads where the movements are updated by a controller stick. On gamepads that's usually a thumbstick. Add joystick events which can be triggered by each implemented controller that should utilize the ScummVM Joystick events.
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.
Trigger EVENT_INPUT_CHANGED when devices connects to make the ScummVM engine update the hardware input set.
I am getting the following compilation errors with my version of Xcode (Xcode 9.2 / SDK for iPhoneOS 11.2):
Looking at the documentation it appears that
Once compiled (after commenting out the code causing the errors above) it works mostly well, but there seems to be a regression in direct touch mode (when touchpad mode is disabled). With current master code the cursor immediately moves to where we touch on the screen. With this pull request it doesn't immediately move to where we touch, and only move there if we touch and then move a bit the finger while still touching. I find this a bit confusing and made it harder to press buttons in the menu for example.
Hmmmm, the gamepad controller support should not be compiled on iOS versions older than 14 due to the API-check in the header file. But I will look at it.
I will also check the regression problem with touchpad mode disabled as well.
I’m currently on a trip so I will look into it late next week.