IOS7: Update virtual controller on orientation changes

The virtual controller layout is not updated properly on
orientation changes. Buttons can be placed outside the screen.
Make sure to set the GCControllerView properties on orientation
changes by connecting the virtual controller based on the
user settings.

On iPhones the virtual game controller buttons does not fit
within the screen borders in portrait mode. Disconnect the
virtual controller on iPhones when changing orientation to
portrait mode.
This commit is contained in:
Lars Sundström 2023-07-15 23:20:44 +02:00
parent 77244e516f
commit 1d63f4f0af

View File

@ -23,6 +23,7 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL
#include "common/events.h"
#include "common/config-manager.h"
#include "backends/platform/ios7/ios7_video.h"
#include "backends/platform/ios7/ios7_touch_controller.h"
#include "backends/platform/ios7/ios7_mouse_controller.h"
@ -331,6 +332,18 @@ bool iOS7_fetchEvent(InternalEvent *event) {
}
[self adjustViewFrameForSafeArea];
#if TARGET_OS_IOS
// The virtual controller does not fit in portrait orientation on iPhones
// Make sure to disconnect the virtual controller in those cases
if (!iOS7_isBigDevice() &&
(_currentOrientation == UIInterfaceOrientationPortrait ||
_currentOrientation == UIInterfaceOrientationPortraitUpsideDown)) {
[self virtualController:false];
} else {
// Connect or disconnect the virtual controller
[self virtualController:ConfMan.getBool("onscreen_control")];
}
#endif
}
#ifndef __has_builtin