Respect window/handheld/orientation setting in iOS

This commit is contained in:
Yasha Borevich 2018-06-29 13:53:12 +03:00
parent b7f17a100d
commit f78e5e5725
4 changed files with 29 additions and 61 deletions

View file

@ -41,11 +41,15 @@
<array> <array>
<string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string> <string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array> </array>
<key>UISupportedInterfaceOrientations~ipad</key> <key>UISupportedInterfaceOrientations~ipad</key>
<array> <array>
<string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string> <string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array> </array>
$additional_plist_content $additional_plist_content
</dict> </dict>

View file

@ -64,11 +64,6 @@ OSIPhone *OSIPhone::get_singleton() {
return (OSIPhone *)OS::get_singleton(); return (OSIPhone *)OS::get_singleton();
}; };
uint8_t OSIPhone::get_orientations() const {
return supported_orientations;
};
extern int gl_view_base_fb; // from gl_view.mm extern int gl_view_base_fb; // from gl_view.mm
void OSIPhone::set_data_dir(String p_dir) { void OSIPhone::set_data_dir(String p_dir) {
@ -100,12 +95,6 @@ void OSIPhone::initialize_core() {
Error OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { Error OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
supported_orientations = 0;
supported_orientations |= ((GLOBAL_DEF("video_mode/allow_horizontal", true) ? 1 : 0) << LandscapeLeft);
supported_orientations |= ((GLOBAL_DEF("video_mode/allow_horizontal_flipped", false) ? 1 : 0) << LandscapeRight);
supported_orientations |= ((GLOBAL_DEF("video_mode/allow_vertical", false) ? 1 : 0) << PortraitDown);
supported_orientations |= ((GLOBAL_DEF("video_mode/allow_vertical_flipped", false) ? 1 : 0) << PortraitUp);
RasterizerGLES3::register_config(); RasterizerGLES3::register_config();
RasterizerGLES3::make_current(); RasterizerGLES3::make_current();

View file

@ -47,14 +47,6 @@
class OSIPhone : public OS_Unix { class OSIPhone : public OS_Unix {
public:
enum Orientations {
PortraitDown,
PortraitUp,
LandscapeLeft,
LandscapeRight,
};
private: private:
enum { enum {
MAX_MOUSE_COUNT = 8, MAX_MOUSE_COUNT = 8,
@ -64,8 +56,6 @@ private:
static HashMap<String, void *> dynamic_symbol_lookup_table; static HashMap<String, void *> dynamic_symbol_lookup_table;
friend void register_dynamic_symbol(char *name, void *address); friend void register_dynamic_symbol(char *name, void *address);
uint8_t supported_orientations;
VisualServer *visual_server; VisualServer *visual_server;
AudioDriverCoreAudio audio_driver; AudioDriverCoreAudio audio_driver;

View file

@ -83,48 +83,33 @@ int add_cmdline(int p_argc, char **p_args) {
printf("*********** did receive memory warning!\n"); printf("*********** did receive memory warning!\n");
}; };
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)p_orientation { - (BOOL)shouldAutorotate {
switch (OS::get_singleton()->get_screen_orientation()) {
if (/*OSIPhone::get_singleton() == NULL*/ TRUE) { case OS::SCREEN_SENSOR:
case OS::SCREEN_SENSOR_LANDSCAPE:
printf("checking on info.plist\n"); case OS::SCREEN_SENSOR_PORTRAIT:
NSArray *arr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UISupportedInterfaceOrientations"]; return YES;
switch (p_orientation) {
case UIInterfaceOrientationLandscapeLeft:
return [arr indexOfObject:@"UIInterfaceOrientationLandscapeLeft"] != NSNotFound ? YES : NO;
case UIInterfaceOrientationLandscapeRight:
return [arr indexOfObject:@"UIInterfaceOrientationLandscapeRight"] != NSNotFound ? YES : NO;
case UIInterfaceOrientationPortrait:
return [arr indexOfObject:@"UIInterfaceOrientationPortrait"] != NSNotFound ? YES : NO;
case UIInterfaceOrientationPortraitUpsideDown:
return [arr indexOfObject:@"UIInterfaceOrientationPortraitUpsideDown"] != NSNotFound ? YES : NO;
default: default:
return NO; return NO;
} }
}; };
uint8_t supported = OSIPhone::get_singleton()->get_orientations(); - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
switch (p_orientation) { switch (OS::get_singleton()->get_screen_orientation()) {
case OS::SCREEN_PORTRAIT:
case UIInterfaceOrientationLandscapeLeft: return UIInterfaceOrientationMaskPortrait;
return supported & (1 << OSIPhone::LandscapeLeft) ? YES : NO; case OS::SCREEN_REVERSE_LANDSCAPE:
return UIInterfaceOrientationMaskLandscapeRight;
case UIInterfaceOrientationLandscapeRight: case OS::SCREEN_REVERSE_PORTRAIT:
return supported & (1 << OSIPhone::LandscapeRight) ? YES : NO; return UIInterfaceOrientationMaskPortraitUpsideDown;
case OS::SCREEN_SENSOR_LANDSCAPE:
case UIInterfaceOrientationPortrait: return UIInterfaceOrientationMaskLandscape;
return supported & (1 << OSIPhone::PortraitDown) ? YES : NO; case OS::SCREEN_SENSOR_PORTRAIT:
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
case UIInterfaceOrientationPortraitUpsideDown: case OS::SCREEN_SENSOR:
return supported & (1 << OSIPhone::PortraitUp) ? YES : NO; return UIInterfaceOrientationMaskAll;
case OS::SCREEN_LANDSCAPE:
default: return UIInterfaceOrientationMaskLandscapeLeft;
return NO;
} }
}; };