mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-15 14:59:37 +00:00
(iOS) Add system settings to enable or disable certain orientations while a game is running
This commit is contained in:
parent
8aff61c4e6
commit
2fcc99a4f9
@ -39,6 +39,7 @@
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
|
@ -216,6 +216,7 @@ static void event_reload_config(void* userdata)
|
||||
bool _isPaused;
|
||||
bool _isRunning;
|
||||
uint32_t _settingMenusInBackStack;
|
||||
uint32_t _enabledOrientations;
|
||||
|
||||
RAModuleInfo* _module;
|
||||
}
|
||||
@ -298,6 +299,33 @@ static void event_reload_config(void* userdata)
|
||||
return [super popViewControllerAnimated:animated && !_isGameTop];
|
||||
}
|
||||
|
||||
// NOTE: This version only runs on iOS6
|
||||
- (NSUInteger)supportedInterfaceOrientations
|
||||
{
|
||||
return _isGameTop ? _enabledOrientations
|
||||
: UIInterfaceOrientationMaskAll;
|
||||
}
|
||||
|
||||
// NOTE: This version runs on iOS2-iOS5, but not iOS6
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
||||
{
|
||||
if (_isGameTop)
|
||||
switch (interfaceOrientation)
|
||||
{
|
||||
case UIInterfaceOrientationPortrait:
|
||||
return (_enabledOrientations & UIInterfaceOrientationMaskPortrait);
|
||||
case UIInterfaceOrientationPortraitUpsideDown:
|
||||
return (_enabledOrientations & UIInterfaceOrientationMaskPortraitUpsideDown);
|
||||
case UIInterfaceOrientationLandscapeLeft:
|
||||
return (_enabledOrientations & UIInterfaceOrientationMaskLandscapeLeft);
|
||||
case UIInterfaceOrientationLandscapeRight:
|
||||
return (_enabledOrientations & UIInterfaceOrientationMaskLandscapeRight);
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark EMULATION
|
||||
- (void)runGame:(NSString*)path withModule:(RAModuleInfo*)module
|
||||
{
|
||||
@ -370,6 +398,27 @@ static void event_reload_config(void* userdata)
|
||||
|
||||
if (conf)
|
||||
{
|
||||
// Get enabled orientations
|
||||
static const struct { const char* setting; uint32_t orientation; } orientationSettings[4] =
|
||||
{
|
||||
{ "ios_allow_portrait", UIInterfaceOrientationMaskPortrait },
|
||||
{ "ios_allow_portrait_upside_down", UIInterfaceOrientationMaskPortraitUpsideDown },
|
||||
{ "ios_allow_landscape_left", UIInterfaceOrientationMaskLandscapeLeft },
|
||||
{ "ios_allow_landscape_right", UIInterfaceOrientationMaskLandscapeRight }
|
||||
};
|
||||
|
||||
_enabledOrientations = 0;
|
||||
|
||||
for (int i = 0; i < 4; i ++)
|
||||
{
|
||||
bool enabled = false;
|
||||
bool found = config_get_bool(conf, orientationSettings[i].setting, &enabled);
|
||||
|
||||
if (!found || enabled)
|
||||
_enabledOrientations |= orientationSettings[i].orientation;
|
||||
}
|
||||
|
||||
//
|
||||
config_get_bool(conf, "ios_use_icade", &use_icade);
|
||||
config_get_bool(conf, "ios_use_btstack", &enable_btstack);
|
||||
|
||||
|
@ -297,6 +297,12 @@ static RASettingData* custom_action(NSString* action, id data)
|
||||
// TODO: Make this option only if BTstack is available
|
||||
boolean_setting(config, @"ios_use_btstack", @"Enable BTstack", @"false"),
|
||||
nil],
|
||||
[NSArray arrayWithObjects:@"Orientations",
|
||||
boolean_setting(config, @"ios_allow_portrait", @"Portrait", @"true"),
|
||||
boolean_setting(config, @"ios_allow_portrait_upside_down", @"Portrait Upside Down", @"true"),
|
||||
boolean_setting(config, @"ios_allow_landscape_left", @"Landscape Left", @"true"),
|
||||
boolean_setting(config, @"ios_allow_landscape_right", @"Landscape Right", @"true"),
|
||||
nil],
|
||||
modules,
|
||||
nil
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user