Commit graph

138164 commits

Author SHA1 Message Date
Lothar Serra Mari
d48dd4dfa2
NEWS: Backport missing entries for 2.7.x in German NEWS file 2023-05-29 21:15:48 +02:00
PushmePullyu
7cf8c17039 SAGA: Fix use-after-free on handling actor action
On switching scenes:
Reset _actor->_lastZone in Actor::updateActorsScene().

Actors can store a pointer to a HitZone in _lastZone
(see Actor::handleActions()).

The HitZone pointed to is held by ObjectMap vm->_scene->_objectMap
in array _hitZoneList.

When changing scenes the array elements are cleared via
ObjectMap::clear() and _lastZone can become stale since
only some code paths reset it (e.g. Actor::takeExit()).

The stale pointer is then passed to Actor::stepZoneAction()
from Actor::handleActions() and dereferenced.

Fixes #13661

(cherry picked from commit bad85b3c9c)
2023-05-29 10:47:33 +02:00
PushmePullyu
7acecd9db4 SAGA: Fix memory and file handle leak in loadResource
Fixes #14334

(cherry picked from commit d2745ff37f)
2023-05-29 10:47:24 +02:00
Alexander Izmailov
92f6e6d630 XEEN: fix crash in MM4 ending cutscene 2023-05-14 12:18:39 +03:00
antoniou79
ebb6659446 TOON: Use nullptr instead of NULL
Also add some initializations for member and local variables
2023-05-11 22:19:22 +03:00
antoniou79
e18e33adeb TOON: Fix overreading Picture data
Problematic method was Animation::drawFrameWithMaskAndScale() with mask (Picture) pointer accessing beyond the data size

Caught on Android 13, reported on the forums here: https://forums.scummvm.org/viewtopic.php?p=98340#p98340
Also moved shadow animation check to loadAnimation (rather that doing it each time within drawFrameWithMaskAndScale()
2023-05-11 22:19:10 +03:00
Lars Sundström
920faab9a9 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-06 10:22:20 +02:00
Lars Sundström
a7d12394b0 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-06 10:22:09 +02:00
Lars Sundström
cf7e3256ee IOS7: Call correct delegate method
The wrong delegate method was called for touchesCancelled. This
led to button presses ended too early if moving the fingers.
2023-05-06 10:22:01 +02:00
Lars Sundström
7c903e4a55 IOS7: Write changes to mouse modes to ConfMan
When changing "Touchpad mode" or "Mouse-click-and-drag mode" by
swipe gestures, these changes must be stored in ConfMan.
2023-05-06 10:21:54 +02:00
Lars Sundström
560dfbf2bc IOS7: Don't disable "touchpad" mode when enabling "click-and-drag"
The "touchpad" mode and "click-and-drag" mode was mutual exclusive
when enabling "click-and-drag" using swipe gesture.

The difference between "touchpad" mode and "click-and-drag" mode
is how the button down/up events are sent. In touchpad mode the
button down and button up events are sent on touches ended, while
in click-and-drag the button down event is sent on touches began
and button up on touches ended.
2023-05-06 10:21:47 +02:00
Lars Sundström
806e7e4824 IOS7: Remove legacy gesture recognizers
These gesture recognizers were inherited from the iphone port. The
ios7 port use the UIGestureRecognizers to accomplish the same.
2023-05-06 10:21:38 +02:00
Lars Sundström
a9e44384e9 IOS7: Implement port-specifc option widget
Include the newly added ios7_options implementation to the project.
Change the file type to .mm which is Objective C++ to be able to use
the @availble mechanism.

Implement virtual functions and fix build errors in initial code.
Also add help section for the tvOS port when building for tvOS.

Add ios7_options to POTFILES to get automatic translation on the
help section.
2023-05-06 10:21:17 +02:00
Thierry Crozat
61bbe1187b IOS: Add back new delegate methods but keep old ones
On iOS 12 and below, the one delegate methods are called. On iOS13.2
and above if both sets are implemented only the new delegate methods
are called, which prevent getting the deprecation warning.
2023-05-06 10:21:08 +02:00
Eugene Sandulenko
f8c00b17e5 BACKENDS: IOS7: Add inital code for port-specifc options 2023-05-06 10:21:00 +02:00
Lars Sundström
29c017634a IOS7: Implement use of Timer Dispatch Sources to drive timeHandler
The timeHandler was driven by calls to the pollEvent callback function.
Each time pollEvent was called the timeHandler called the TimeManager
handle function to advance in time and make sure scheduled tasks were
triggered.

This worked good for most game engines but some, e.g. the Hypno engine
was using the TimeManager to schedule tasks without calling pollEvent
since it was expecting nor handling events at the specific point in
time.

Since iOS have threads the timerHandler can be called from a separate
thread and not rely on pollEvent.
Implement timerHandler to use a Timer Dispatch Source which and make
it operate on a background thread rather than the main thread.
Read more on Dispatch Sources here:
https://developer.apple.com/library/archive/documentation/General/
Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
2023-05-06 10:20:52 +02:00
Lars Sundström
811bb45997 CREATE_PROJECT: Set bitcode as disabled as default in Xcode
Apple never required bitcode to be enabled and with Xcode 14
bitcode is deprecated.

Set bitcode to disabled for iOS and tvOS projects. Else it will
be default on and give a build error due to the libraries in
scummvm-ios7-libs-v3 doesn't include bitcode.
2023-05-06 10:20:45 +02:00
Thierry Crozat
50c315e316 IOS7: Add check of size for log file to make sure it does not grow too much 2023-04-27 21:43:40 +01:00
Thierry Crozat
e3b643d9a6 IOS7: Fix orientation detection when the view becomes visible 2023-04-27 21:43:40 +01:00
Thierry Crozat
c1bcb0fd09 IOS7: Create log file in Document folder
Previously no log file was used as it attempted to create it in
a directory not accessible by the application. The commit also fixes
accessing the log file from the Options dialog (it needs the
sandboxed path and not the full path).
2023-04-27 21:43:40 +01:00
Thierry Crozat
aaf6ed536f IOS7: Cleanup code to access Document and app bundle paths 2023-04-27 21:43:40 +01:00
Thierry Crozat
f1f808f7a4 IOS7: Remove support for non-sandboxed mode 2023-04-27 21:43:40 +01:00
Thierry Crozat
5bfa6feaa1 IOS7: Fix missing override keyword 2023-04-27 21:43:40 +01:00
Thierry Crozat
1675496f01 IOS7: Remove checks that @available can be used
This was used in the past to make sure the code can be compiled
with old compilers that do not support using @available. But we
already dropped support for those old compilers, and in many
places already used @available without checking first that it can
be used.
2023-04-27 21:43:40 +01:00
Thierry Crozat
07652d9d82 IOS7: Fix detection of orientation on some devices
The main change in to use the interface orientation and not the device
orientation. This may be different for example when locking the orientation.
This also changes the way orientation changes are detected using the
documented method. However this means dropping support for iOS 7 as this
method is only available since iOS 8, and alternative methods available in
iOS 7 have been deprecated in iOS 13.

Another change is to properly detect the interface orientation instead of
infering it from the view bounds, which was incorrect on some devices.
2023-04-27 21:43:40 +01:00
Lars Sundström
fb79d61a31 DOCPORTAL: Update ios7 and tvos instructions
This updates the instructions for building the ios7 and tvos backends
using scummvm-ios7-libs-v3, utilizing the Apple XCFramework format for
the pre-compiled libraries.

Using scummvm-ios7-libs-v3 also enables use of the following
features:
 - faad
 - gif
 - mpeg2
 - theoradec

DOC
2023-04-27 21:43:28 +01:00
Walter Agazzi
5bc748a659 CREATE_PROJECT: Add option to use XCFramework in iOS, tvOS and macOS
The introduction of Apple M1 processor, which is based on the arm64
architecture, makes it impossible to use fat static libraries for iOS
and tvOS since building libraries for the simulators targeting the
arm64 architecture conflicts with the iOS and tvOS native arm64
libraries. It's not possible to have two arm64 libraries targeting
different platforms in the same fat library.

Apple resolves this problem with XCFrameworks. Each XCFramework
contain an Info.plist specifying which platforms and architectures it
targets.

The new iOS and tvOS library package, scummvm-ios7-libs-v3, utilize
the XCFramework format and includes pre-compiled libraries for both
iOS and tvOS with corresponding simulator.

Add the option to use XCFramework in create_project by passing the
switch '--use-xcframework'

Implement support to use XCFrameworks for iOS, tvOS and macOS. If not
passing '--use-xcframework' to create_project, legacy behaviour is
applied.

This commit also add support for mikmod for tvOS.
2023-04-27 21:35:02 +01:00
Cameron Cawley
4a864d8039 DOCS: Fix formatting in the tvOS documentation 2023-04-27 21:25:46 +01:00
Lars Sundström
2c60b9a4dc DOCS: Add draft documentation of Apple TV platform
Add basic documentation needed starting using or developing ScummVM on
the Apple TV.
2023-04-27 21:25:25 +01:00
Le Philousophe
c38c1512a9 IOS7: Add AppleTV support to configure 2023-04-27 21:24:16 +01:00
Lars Sundström
a5cc5e17b8 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-04-27 21:18:43 +01:00
Lars Sundström
1ace0305ce 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-04-27 21:18:34 +01:00
Lars Sundström
eb4028880e IOS7: Suspend application if menu key pressed and no game is running
Add isInGame property to track if the launcher is shown of if a game is
running. Handle press on menu key different depending on if launcher is
shown or not. If launcher is shown suspend the application to return to
Apple TV Home Screen since that is the parent view of the launcher. If
in game pause the game and show menu. This is according to Apple
guidelines which can ge read here:
https://developer.apple.com/design/human-interface-guidelines/inputs/remotes
2023-04-27 21:18:23 +01:00
Lars Sundström
2c351f85ee IOS7: Check keyboard visible if inputView being first responder
The keyboard can be presented and dismissed without being triggered by
the showKeyboard/hideKeyboard functions e.g. by pressing the menu button
on the Apple TV remote while the keyboard is shown.
If the keyboard visibility is not set entirely by the showKeyboard/
hideKeyboard functions that means that the _keyboardVisible state
variable can be out of sync.

Check if the keyboard is shown based on if the inputView is the first
responder or not. The check has to be made on the main thread.
2023-04-27 21:18:08 +01:00
Lars Sundström
80cb6427e1 IOS7: Trigger joystick presses only once for buttons A and B
All buttons and triggers on MFi game controllers are pressure sensitive
which means that when pressing buttons the registered
valueChangedHandler function is called multiple times providing updates
on the pressure value the button is pressed with. This causes multiple
kInputJoystickButtonDown events to be sent to the EventManager.
In adventure games the pressure value is not relevant and could cause
problems for the user that it triggers multiple presses on e.g. the B
button which often is mapped to the right mouse button. In some games
a click on the right mouse button changes what action that should be
performed.

Keep track on if the joystick buttons A or B (often mapped as left and
right mouse buttons) are being pressed. If the button is already
pressed do not add a new event until the button isn't pressed anymore.

To not interfere with any open dialog, don't send key events while the
keyboard is visible.
2023-04-27 21:17:58 +01:00
Lars Sundström
314590e654 IOS7: Show inputAccessoryView when hardware keyboad is connected
The inputAccessoryView is only shown if no hardware keyboard is
connected. Some hardware keyboards doesn't necessary have all keys,
e.g. the Apple magic keyboard to the iPads which lacks the escape
key and all function keys.

To give the user the possibility to use these buttons, always show
the inputAccessoryView.
2023-04-27 21:17:48 +01:00
Lars Sundström
a7c2a8b2d9 IOS7: Replace UIAlertView with UIAlertAction
The UIAlertView was deprecated in iOS 9 and therefore not supported in
tvOS. Replace the UIAlertView with the suggested UIAlertAction, which is
supported by both iOS and tvOS.

Define a macro to find the root view controller of a view. Use the view
controller of the iPhoneView to present the alert.
2023-04-27 21:17:36 +01:00
Lars Sundström
1ff4fe8149 IOS7: Forward backward key presses when textField is empty
There's a difference between UITextFields and UITextViews that the
delegate function textView:shouldChangeTextInRange:replacementText:
is called when pressing the backward button on a keyboard also when
the textView is empty. This is not the case for UITextFields, the
function textField:shouldChangeTextInRange:replacementText: is not
called if the textField is empty which is problematic in the cases
where there's already text in the open dialog (e.g. the save dialog
when the user wants to overwrite an existing slot). There's currently
no possibility to propagate existing text elements from dialog into
the textField. To be able to handle the cases where the user wants to
delete existing texts when the textField is empty the inputView has
to implement the UITextInput protocol function deleteBackward that is
called every time the backward key is pressed.
2023-04-27 21:17:22 +01:00
Lars Sundström
694345d8f8 IOS7: Implement keyboard support for Apple TV OS
The UITextView is becoming focused by default in iOS and brings up the
keyboard for user input. This is not the case in tvOS. UITextView in
tvOS is not becoming focused by default and if manually setting it to
focused it will still not bring up the keyboard screen.

The UITextField is however becoming focused in both iOS and tvOS and
requires basically the same implementation. So the UITextView is
replaced with UITextField to bring up keyboard in both iOS and tvOS.

The UIToolbar class is not supported in tvOS. Instead implement the
toolbar as a UITabBar. The UITabBar is set directly as the
inputAccessoryView to the keyboard view in tvOS while in iOS it's put in
a UIScrollView (as the previous UIToolbar) to be able to scale the
inputAccessoryView better for small screens.

The UITabBar behaves a little bit different on iOS and tvOS where in
tvOS the delegate function
-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
is called when navigated to a specific toolbar item, while in iOS called
when clicking on an item. To get the tvOS to trigger action on presses,
add a gesture recognizer to handle touch events.

Since the keyboard view on Apple TV always full screen prompted texts
gets hidden behind the keyboard. Delay the showing of the keyboard to
allow the user to understand what's requested as input.
2023-04-27 21:17:09 +01:00
Lars Sundström
255852c8e3 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-04-27 21:16:53 +01:00
Lars Sundström
0a9239ad7c IOS7: Put iOS specific code within platform specific macros
iOS and tvOS shares a lot of code. However some there are parts that are
specific to iOS, for instance handling of UI device orientation and
certain types of gestures.

Currently there are also some limitations on the Apple TV that needs to
be flagged to the  engine. There is no support for virtual keyboard, no
clipboard support and no possibility to open URLs.

Put code specific for iOS within the ObjC platfrom macro TARGET_OS_IOS.
The code specific for tvOS are put within the macro TARGET_OS_TV.
2023-04-27 21:16:10 +01:00
Lars Sundström
a836661511 CREATE_PROJECT: Add Apple TV OS XCode target
Add Apple TV OS as a new target to the xcode project creator utility.
Make sure that TV OS specific files are not part of the iOS and macOS
targets and the other way around.
The TV OS project will utilize the same source code files as the iOS
project but will instead use the tvos dist files.
2023-04-27 21:14:19 +01:00
Lars Sundström
4d774e2fc3 TVOS: Add Apple TV OS as a separate dist
The Apple TV OS requires a different type of storyboard than iOS. Also,
the Info.plist file differ since the tvOS platform doesn't handle
different orientations.

The Apple TV OS also need a different set of icons with different
resolutions more suitable for TV screens.

The application icons are required to be of layered type, which means
that a single PNG file is not accepted as an icon file. The icons must
have at least two layers, hence the ScummVM icon is defined by a back
image with just the background color and a front image with the ScummVM
logo.

The icons are then put together when archiving the application in Xcode
to an Assets.car file. However the linux builds are not building the
application using Xcode. Therefore a pre-compiled Assets.car file
containing the image assets (icons, splash screen etc) is added to the
tvos folder. This file is copied to the application bundle. If the icons
are changed in the future a new Assets.car file has to be compiled. This
can only be done on a computer with Xcode installed. To compile run the
following command in the tvos folder:
xcrun actool ./Images.xcassets --compile build --platform appletvos \
--minimum-deployment-target 9.0 --app-icon AppIcon \
--output-partial-info-plist build/partial.plist \
--launch-image LaunchImage

The partial.plist file generated will show what to add to the Info.plist
and if something must be changed in the ports.mk section for the
tvosbundle.
2023-04-27 21:13:27 +01:00
antoniou79
4a35d90191 ANDROID: Prevent getPath() when getExternalFilesDir(null) returns null
According to documentation getExternalFilesDir returns the absolute path to application-specific directory

May return null if shared storage is not currently available.
This will not happen for getFilesDir() which returns the internal app path (always guaranteed to be available)
2023-04-23 13:39:55 +03:00
antoniou79
61822421e1 ANDROID: Update versioncodes reservation for 2.7.0.5 2023-04-22 14:32:41 +03:00
Le Philousophe
122ddf1f26 ANDROID: Fix assertion fault and missing initializer 2023-04-22 12:29:01 +02:00
sluicebox
7bfd1efc70 AUDIO: Fix crash when OPL driver isn't loaded
Fixes segfault when logging that an OPL driver doesn't support the
emulation type requested by a game.

The code used driver id as an array index, but this is incorrect
because array indexes depends on which drivers are compiled in.

This issue was identified and fixed in 2015, but this line was missed:
6f01600e12

Fixes the crash in bug #14413
2023-04-15 17:15:36 -07:00
Thierry Crozat
794ada8c44 AGS: Fix video stretch
The original AGS uses a proportional stretch that preserves the
video aspect ratio, but we were doing a stretch to the full game
screen. As a result if the video and game do not have the same
aspect ratio we were losing the video aspect ratio. This could
for example be seen with the AGDI logo at the start of all the
AGDI games. The games re at 320x200, but the video are 320x160.
Before this commit the video was stretched incorrectly to
320x200.
2023-04-14 01:16:37 +01:00
Thierry Crozat
09c49871fd GUI: Add guard to prevent recursive call of handleMouseWheel in dialogs
This fixes bug #14404.

The rercusive call was introduced with commit 325260f that changed
the implementation of Widget::handleMouseWheel to call handleMouseWheel
on the widget boss. If the widget boss is a dialog, its implementation
is to call handleMouseWheel on the widget under the cursor. And
we can end up with an infinite loop.

As indicated in bug #13106, which was fixed by commit 325260f, a
similar infinite loop when using the mouse wheel to scroll tabs in
the options dialog was caused by the commit and quickly fixed. But
the fix was only for that particular case. Here the fix should
be more global.
2023-04-12 23:41:05 +01:00
Donovan Watteau
f6ca571c87 BUILD: MACOS: Fix/simplify the xattr check for older OSX
Just reuse the MACOSX_LEOPARD_OR_BELOW define, since TextEdit isn't able
to make anything out of this attribute on Leopard or below anyway.

Fixes a GNU make mistake of mine in commit
cdbdb58e07.

(cherry picked from commit ad42ff82d3)
2023-04-13 00:20:47 +02:00