Commit Graph
280 Commits
Author SHA1 Message Date
Lars Sundström 414c427fd6 IOS7: Use new key overload functions
Call the overload functions for key inputs and return the results
as an array of UIKeyCommands.
2024-02-23 22:41:18 +01:00
Lars Sundström c5ef6ecb77 IOS7: Add functions creating UIKeyCommands for special keys
Use the helper function to create an array of UIKeyCommands for the
END, HOME, PAGE UP, PAGE DOWN and the ESC keys. Add a generic handler
function that decides which action for which key.

This allows the application to register key presses of these keys,
however some of them requires iOS 13.4 or later.
2024-02-23 22:41:18 +01:00
Lars Sundström 25d7787d9f IOS7: Add functions creating UIKeyCommands for Fn keys
Use the helper function to create an array of UIKeyCommands for the
Fn keys. Add a generic handler function that decides which action
for which key.

This allows the application to register key presses of the Fn keys,
however only supoorted in iOS 13.4 and later.
2024-02-23 22:41:18 +01:00
Lars Sundström a8314ea05b IOS7: Add functions creating UIKeyCommands for number keys
Use the helper function to create an array of UIKeyCommands for the
number keys. Add a generic handler function that decides which action
for which key.

Since not all keyboards have the function keys, Fn1-Fn12, e.g. the
Apple Magic Keyboard for iPads, map these keys to the number keys
when pressed together with the CMD modifier key. Fn11 and Fn12
requires CMD + Shift as modifier keys.
2024-02-23 22:41:18 +01:00
Lars Sundström 8baa1de5d0 IOS7: Add functions creating UIKeyCommands for roman letter keys
Use the helper function to create an array of UIKeyCommands for the
roman letter keys. Since most of the games supports input of roman
letters, overload these keys. Keys with other characters than these
are not overloaded and will therefore trigger the call to the
delegate function:
"textField:shouldChangeCharactersInRange:replacementString:"
and will therefore still be passed to the IOS7 event handler.
However no modifier flags will be passed for those and they will not
support repeated presses.

Add a generic handler function that decides which action
for which key.
2024-02-23 22:41:18 +01:00
Lars Sundström 2bbbdc75fb IOS7: Add functions creating UIKeyCommands for arrow keys
Use the helper function to create an array of UIKeyCommands for the
arrow keys. Add a generic handler function that decides which action
for which key.

Since not all keyboards have the PAGE UP/DOWN nor HOME/END keys,
e.g. the Apple Magic Keyboard for iPads, map these keys to the arrow
keys when pressed together with the CMD modifier key.
2024-02-23 22:41:18 +01:00
Lars Sundström 99fb3faf9d IOS7: Add helper functions to overload keys
Currently the key inputs are sent to the IOS7 event handler on calls
to the delegate function:
"textField:shouldChangeCharactersInRange:replacementString:"
So when typing on either the software keyboard or a connected HW
keyboard the input is handled by the hidden textfield that is in
focus. The delegate is called on each key input and the character
typed is passed to the IOS7 event handler.

Doing as above has the drawback that if they user holds down a key,
common in games when shooting or moving, the key event is only sent
once. The delegate function is only called once per distinct key
press.

By implementing the keyCommands function and create UIKeyCommands
for a set of keys, the system will call a defined callback function.
This also enables repeatedly calls as long as the key is held down.

Modifier keys can also be configured to create UIKeyCommands to
trigger custom actions. This way we can overload the key functions
when they are pressed at the same time as a modifier key.

Add helper funtions that can be used to create UIKeyCommands for
a set of keys. Keys are represented by their input, e.g. the key
for the character 'c' is defined as a string with only one char,
the 'c', while special keys are represeented by strings defined
by the OS.

Register UIKeyCommands for all types of modifier keys and add a
function that can convert system modifier flags to flags used by
ScummVM.
2024-02-23 22:41:18 +01:00
Lars Sundström c8d93ad820 IOS7: Pass key modifier flags to key events
Prepare the backend to send key modifier flags in the key events.
No modifier flags are sent at this point but will be added in
upcoming commits.
2024-02-23 22:41:18 +01:00
Lars Sundström ceb54851c5 IOS7: Make specific options if running in macOS
Add a convenience function to check if the application is running
in macOS. Use this method to change the default visibility of on-
screen control buttons and function bar.
Neither of these are needed when running on macOS since both mouse
and keyboard are available. Also the mouse pointer in ScummVM does
not access the on-screen control buttons.

However this requires function keys and key combinations like e.g.
Alt+X to work to be able to save and quit games.
These will be added in future commits.
2024-01-21 10:57:27 +01:00
Lars Sundström da19f39164 IOS7: Update the window size correctly
Applications running on iOS are usually full screen. On newer iPads
and when running iOS applications on macOS the application window
size can be changed.

When running the iOS application on macOS using "Designed for iPad"
option, the window can be changed, also to full screen. The function
"safeAreaInsetsDidChange" is then called. Update the screen size
using the view window property instead of checking the UIScreen
window bounds since these never changes.

If forcing the application to run in full screen setting the option
UIRequiresFullScreen to TRUE, it seems to trigger ScummVM to run
in portrait mode instead of landscape mode when running the app in
macOS using "Designed for iPad" on Apple silicon macs.

The UI doesn't require full screen since the application handles
resolution changes nice.
2024-01-21 10:57:27 +01:00
Lars Sundström 20d14337c9 IOS7: Make "Designed for iPad" on Mac silicon great again
It is possible to run iOS applications on macOS on Mac computers
running on Apple Silicon. This was possible before moving to the
ModularGraphicsBackend implementation in the iOS7 port with just
a little tweaking.

After the move to ModularGraphicsBackend, the ScummVM application
crashed on launch. There were two reasons for crashing;

1. dlsym() was called with the special handle RTLD_SELF to search
for the address binding of the GLES2 load symbol. Using RTLD_SELF
the search for the symbol is limited to the shared object issuing
the call to dlsym() and those shared objjects which were loaded
after it. When running an iOS app in macOS it seems that the app
is running inside a wrapper, which means that the objects resides
in a different level. Changing the search level to RTLD_DEFAULT
changes the search to also include all objects loaded at program
start-up.

2. As for the native macOS application, XCode also adds the
argument -NSDocumentRevisionsDebugMode YES if XCode option
"Allow debugging when using document Versions Browser" is on.
Make sure not to parse that argument also when building the
IPHONE target.
2024-01-21 10:57:27 +01:00
Lars Sundström 4db72b15d2 IOS7: Fix toggling of mouse mode when HW keyboard connected
It was not possible to change the mouse mode between "Direct mouse"
and "Touchpad emulation" if a hardware keyboard was connected when
using the on-screen control button.

Fix this by checking if a hardware keyboard is connected.
2024-01-21 10:57:27 +01:00
Eugene Sandulenko 00440cfe86 HELP: Added explanation what ScummVM is and where to get help for Android and iOS 2023-12-26 15:21:23 +01:00
Le Philousophe db5041ecb0 COMMON: Make savepath a Path object 2023-12-24 13:19:25 +01:00
Le Philousophe dc7fadef28 COMMON: Make iconspath a Path object 2023-12-24 13:19:25 +01:00
Le Philousophe 01ebece807 COMMON: Make getDefaultConfigFileName return a Path instead of a String 2023-12-24 13:19:25 +01:00
Le Philousophe d9a8131ba2 COMMON: Make getDefaultLogFileName return a Path instead of a String 2023-12-24 13:19:25 +01:00
Lars Sundström f50a202277 IOS7: Update backend options widget
Update the options widget to be scrollable and add padding.
2023-12-16 19:37:33 +01:00
Lars Sundström 66a74c5710 IOS7: Add note about disabled tap gestures in help
The tap gestures are disabled while the virtual controller is
connected. Add a note about it in the help section.
2023-12-16 19:37:33 +01:00
Thierry Crozat bb8fa8b481 IOS7: Save state to a separate file when closing ScummVM
The state information was saved using ConfMan in the scummvm ini file,
but this could cause corruption of that ini file if the application
was killed while ConfMan was flushed (see bug #14623). To reduce the
risk of losing the config file, we now save the state to a separate
file.
2023-12-13 22:04:22 +00:00
Thierry Crozat 229ec5ce06 IOS7: Make some minor correction for the help text 2023-12-12 22:19:20 +00:00
Lothar Serra Mari 9b3abdb286 IOS7: Fix broken character in help screen 2023-12-03 21:50:51 +01:00
Lars Sundström e37ab61eca IOS7: Enable/disable gesturers on virtual controller connect
Dont trigger mouse down events in case virtual controller is
connected. When pressing buttons this also trigger tap gestures
and when holding down buttons this triggers long press gestures.
Disable these gestures when virtual controller connects and enable
them again when controller disconnects.
2023-12-03 21:00:32 +01:00
Lars Sundström 81401a1f2e IOS7: Add minimal gamepad layout
This will only consist of a left directional input and the buttons
A, B, X and Y.
2023-12-03 21:00:32 +01:00
Lars Sundström b16faf1187 IOS7: Add options backend checkbox to use minimal gamepad layout
Add a checkbox to allow users to have a minimal gamepad layout.
The minimal layout will be implemented in next commit. The layout
will consist of less buttons. This allows users to select which
controller layout to use, a full layout with many buttons for
games requiring it or a minimal with less buttons.
2023-12-03 21:00:32 +01:00
Lars Sundström fff52cbda1 IOS7: Add more buttons to the Virtual Controller
There are games using more buttons than are currently configured for
the virtual controller. Add a right thumbstick and left and right
shoulder buttons. The shoulder buttons are e.g. used in Escape from
Monkey Island to browse the items in the action list.
2023-12-03 21:00:32 +01:00
Lars Sundström 3245ec5687 IOS7: Use MacText tables in help section
Describe the touch actions using a table in the help section. This
will make the help documentation more readable.
2023-12-03 21:00:32 +01:00
Eugene Sandulenko 86a289ea32 IOS: Make image dimensions in help text dependent on the font size 2023-11-01 00:17:38 +01:00
Cameron Cawley bcc9259382 BACKENDS: Report if the backend supports cursors with alpha channels 2023-10-29 02:02:11 +02:00
Lars Sundström eb601e86bb IOS7: Fix showing/hiding of inputAccessoryView
There is an option to show/hide the inputAccessoryView contataing
special buttons not present on the iOS system keyboard, nor the
Apple iPad Magic keyboard.

Make sure the parent frame size is resized properly depending on
the option setting and if HW keyboards are connected.
2023-10-25 22:05:04 +02:00
Lars Sundström 01106f01d6 IOS7: Enable HW keyboards without first enabling the soft keyboard
The soft keyboard is enabled by calling showKeyboard which will set
the inputView, which is a UITextField, to become the first responder.
This will trigger the software keyboard to pop up. The showKeyboard
function is either called by the GUI when clicking into an editable
box, by the engine when keyboard input is required or when the user
forces it to be shown by a gesture or pressing the on-screen control
button..

The keyboard handling above suits the software keyboard but no HW
keyboards since if the inputView is not the first responder no key
presses are registered. One can expect that key button presses on a
HW keyboard should be registered without enabling the soft keyboard.

Implement handling to enable the inputView when HW keyboards are
connected.
2023-10-25 22:05:04 +02:00
Lars Sundström 4dff5ab486 IOS7: Don't account suspended time in getMillis()
It was reported that in some games, e.g. COMI, if suspending the iOS
application by putting it to background and then some time later
resuming it again the music doesn't start playing. It was reproduced
in The Dig and most probably Full Throttle was affected.

The time it took for the music to play again after resuming turned
out to be related to the time the app was in background. The longer
the app was in background, the longer it took for the music to start
playing again.

The legacy implementation of getMillis in the iOS7 backend accounted
the time the application was suspended. The time was accumulated
every time the app moved to background and it was never reset.
The getMillis function used the accumulated value and substracted it
from the time difference from the current time.

This seems to have caused problems with the timer handler, causing
slots to not be executed in correct time. The Android backend do not
account for the time in background.
2023-10-25 22:05:04 +02:00
Lars Sundström 7ad9e9c8e2 IOS7: Defer screen edge system gestures on orientation changes
The system gestures on screen edges took precedence over the tap
gestures again after screen rotations.
Call function setNeedsUpdateOfScreenEdgesDeferringSystemGestures
on orientation changes to notify the system that it needs to read
the edges from the view controller’s
preferredScreenEdgesDeferringSystemGestures property again.

Defer system gestures on all edges since the top changes when
rotating the device.
2023-10-13 19:25:01 +02:00
Lars Sundström bf724a36f6 IOS7: Defer system gestures on edges
The tap gestures were cancelled due to system gestures taking over
when tapping on the screen edges. This made it hard to click on
verbs in games or buttons in launcher when in "Direct mouse mode".

There is an option to defer the system gestures on selcted edges.
This will make tap gestures to be recognised also on screen edges.
Also it won't interfere with the gesture to close the application
on devices lacking home button.
2023-10-13 14:46:48 +03:00
Lars Sundström a7bf2bf5a7 IOS7: Reset screen size properly when HW keyboard is connected
The accessory view can be configured to be shown or not. When it is
configured to be shown the screen size has to be adjusted according
to the height of the accessory view, also in the case when a HW
keyboard is connected.

It was noted that the screen size was not properly restored when
disabling the keyboard input. The screen size was only adjusted when
the keyboard input became enabled. The reason for that was that when
disabling the keyboard input the accessory also became hidden. So
the screen size was not updated.

Make sure to always reset the screen size when the accessory view
is configured to be visible.
2023-10-13 14:46:48 +03:00
Lars Sundström 283fb6760a IOS7: Only allow touches on screen for new touch gestures
Connected hardware devices such as mice and touchpads also generates
gesture events. If holding down a mouse button that is considered as
a long press gesture, but it's also a mouse button event.
These events are interfering with each others and cancels e.g. long
press gestures.

Make sure the tap and long press gestures only allows to be triggered
by direct touches on screen.
2023-10-13 14:46:48 +03:00
Lars Sundström 473400071c IOS7: Remove "ClickAndDragMode" from widget layout
The "ClickAndDragMode" option is removed. The widget layout was not
removed when the option was removed. Remove it.
2023-10-11 23:14:37 +02:00
Lars Sundström e834bf859b IOS7: Remove old help documentation
The help documentation is moved from the backend tab to the main
launcher screen.
2023-10-11 23:14:37 +02:00
Lars Sundström bc07130dec IOS7: Add help sections for the iOS port
Add help sections to describe the different touch modes, touch
actions, how to add a game etc.

A temporary version for tvOS with no images is provided as well.
2023-10-11 23:14:37 +02:00
Lars Sundström c113dfa993 IOS7: Fix AppleTV OS build errors and warnings
The tap gestures for right/left click in the iOS port was not
protected by the TARGET_OS_IOS macro definition in the touchesMoved
method which is called when a touch is moved.
Touches are used in tvOS when controlling the mouse pointer using
the touch area on the Apple remote controller.

Fix some compiler warnings about unused variables and functions in
the tvOS port.
2023-10-11 21:33:32 +02:00
Lars Sundström 8f407b7a06 IOS7: Fix long press on touch mode button to show keyboard
After adding the other long-press gestures it was hard to trigger
the gesture to show the keyboard by pressing the touch mode button
on the on-screen controls.

Changing the minimum time to trigger from 1 second to default 0.5
seconds fixed that. Add the one-touch-only requirement as well.
2023-10-11 06:28:03 +02:00
Lars Sundström 8466e036b5 IOS7: Update touch mode when swiping two fingers right
The ability to change touch mode between touchpad emulation and
"direct" mouse mode is kept. Inform the user about the updated
mode change and update the on-screen control button to reflect
the new mode which is useful when the on-screen controls are
disabled.
2023-10-11 06:28:03 +02:00
Lars Sundström a490768622 IOS7: Refactor touch event functions
Remove the deprecated events and their corresponding functions.
2023-10-11 06:28:03 +02:00
Lars Sundström cc499d560e IOS7: Only handle one touch for mouse movements
The callback functions touchesBegan, touchesMoved and touchesEnded
are from now only used for mouse pointer movements. Only one touch
is then required to be tracked.

Disable multi-touch in view to accomplish this. The setting does
not affect the gesture recognizers attached to the view, only the
touchesBegan, touchesMoved and touchesEnded callbacks are affected
that only the actions for the first touch in view are sent.
2023-10-11 06:28:03 +02:00
Lars Sundström b2ba581917 IOS7: Remove old touch to mouse button translations
Remove the old translations from touch events to mouse button events.
These have been replaced with UIGestures.
2023-10-11 06:28:03 +02:00
Lars Sundström 4dae507f14 IOS7: Add UIGestures for left and right mouse clicks
On a touch based device the touches made must be translated to
different mouse events. For example when a touch starts and is
moved that should translate to a mouse pointer movement. A quick
tap should be translated to a mouse button click while holding a
touch for a longer time without movement should be translated to
that the mouse button is kept pressed.

Add UIGestures to replace the current mouse button handling, all
done using the callback functions touchesBegan, touchesMoved and
touchesEnded.

A tap gesture with one finger is a left mouse click

A tap gesture with two fingers is a right mouse click

A long press gesture with one finger is holding the left mouse
button down until the press is released. This is accomplished by
sending an button down event when the gesture is recognized and
changes state to UIGestureRecognizerStateBegan.
A button up event is sent when the same gesture changes state to
UIGestureRecognizerStateEnded.

A long press with two fingers is as above but for the right mouse
button.

This commit adds the gestures and their actions. The current
mouse button handling is removed in upcomming commit.
2023-10-11 06:28:03 +02:00
Lars Sundström 857b7553aa IOS7: Don't suspend the application in iOS when pressing menu
The Apple guidelines for Apple TV tells that when pressing the menu
button from the root view the user shall be brought to the "Home"
screen, suspending the app. Prevent this to be done in iOS.
2023-10-10 20:55:48 +02:00
Lars Sundström a2de9b0b4e IOS7: Handle HW keyboards better when using "Stage Manager"
When having a hardware keyboard connected to the iOS device the
software keyboard is not shown. However when using stage manager
the notification that the keyboard is shown is still triggered.
This results in that the game screen is resized even though no
keyboard is visible in the area below.

This is some kind of workaround for that where a check for any
connected hardware keyboard is made. If a keyboard is connected
then the screen is not resized, except if the accessory bar should
be shown. In that case the screen is resized only for the height
of the accessory bar.
2023-10-10 20:55:48 +02:00
Lars Sundström 40f382cace IOS7: Make it possible to toggle alphabetical <-> numpad keyboard
Some games have some actions mapped to the numeric keyboard, e.g.
Indiana Jones and the last crusade fight scenes.
The alphabetical keyboard doesn't have the numeric button row so
it's a bit tricky to play these scenes without holding the "number
button switch" at the same time you need to press the correct number
button being showed.

Make it possible to switch between an alphabetical keyboard layout
to a numpad layout by adding a button to the toolbar.
2023-10-10 20:55:48 +02:00
Lars Sundström 316352e868 IOS7: Toggle keyboard with on-screen control button
Add a long press gesture to the touch mode control button, which
when triggered, shows the keyboard. The image of the UI button
changes to the keyboard image asset as long as the keyboard is
visible. If pressing the touch mode control button while the
keyboard is visible it will dismiss the keyboard.

The updates of the on-screen button image is done in the general
"showKeyboard" and "hideKeyboard" functions which makes sure that
the button image is updated also if showing/hiding of the keyboard
is triggered by the OSystem callback.
2023-10-10 20:55:48 +02:00