Add default config for iOS devices

This commit is contained in:
Benau 2019-10-18 22:22:32 +08:00
parent 5bb9cd6492
commit 42d9e8967f
2 changed files with 85 additions and 0 deletions

View File

@ -15,6 +15,9 @@
#import <CoreMotion/CoreMotion.h>
#import <GLKit/GLKView.h>
#import <sys/utsname.h>
extern void getConfigForDevice(const char* dev);
/* Important information */
@ -187,6 +190,11 @@ namespace irr
name:UIDeviceOrientationDidChangeNotification
object:[UIDevice currentDevice]];
override_default_params_for_mobile();
struct utsname system_info;
uname(&system_info);
NSString* model = [NSString stringWithCString:system_info.machine
encoding:NSUTF8StringEncoding];
getConfigForDevice([model UTF8String]);
ios_main(0, {});
// App store may not like this
exit(0);

View File

@ -20,6 +20,7 @@
#include "config/user_config.hpp"
#include "graphics/irr_driver.hpp"
#include "utils/log.hpp"
#include "utils/string_utils.hpp"
#ifdef ANDROID
#include "../../../lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h"
@ -102,6 +103,82 @@ void override_default_params_for_mobile()
UserConfigParams::m_enforce_current_player = true;
}
#ifdef IOS_STK
void getConfigForDevice(const char* dev)
{
// Check browser.geekbench.com/ios-benchmarks metal benchmark
// https://gist.github.com/adamawolf/3048717 for device name mapping
std::string device = dev;
if (device.find("iPhone") != std::string::npos)
{
// Normal configuration default
UserConfigParams::m_multitouch_scale = 1.3f;
UserConfigParams::m_multitouch_sensitivity_x = 0.1f;
UserConfigParams::m_font_size = 5.0f;
device.erase(0, 6);
auto versions = StringUtils::splitToUInt(device, ',');
if (versions.size() == 2)
{
// A9 GPU
if (versions[0] >= 8)
{
UserConfigParams::m_dynamic_lights = true;
UserConfigParams::m_high_definition_textures = 1;
}
if (versions[0] < 7 || // iPhone 5s
(versions[0] == 7 && versions[1] == 2) || // iPhone 6
(versions[0] == 8 && versions[1] == 1) || // iPhone 6S
(versions[0] == 8 && versions[1] == 4) || // iPhone SE
(versions[0] == 9 && versions[1] == 1) || // iPhone 7
(versions[0] == 9 && versions[1] == 3) || // iPhone 7
(versions[0] == 10 && versions[1] == 1) || // iPhone 8
(versions[0] == 10 && versions[1] == 4) // iPhone 8
)
{
// Those phones have small screen
UserConfigParams::m_multitouch_scale = 1.45f;
}
}
}
else if (device.find("iPad") != std::string::npos)
{
// Normal configuration default
UserConfigParams::m_multitouch_scale = 1.1f;
UserConfigParams::m_multitouch_sensitivity_x = 0.2f;
UserConfigParams::m_font_size = 4.0f;
device.erase(0, 4);
auto versions = StringUtils::splitToUInt(device, ',');
if (versions.size() == 2)
{
if (versions[0] >= 7)
{
UserConfigParams::m_dynamic_lights = true;
UserConfigParams::m_high_definition_textures = 1;
}
}
}
else if (device.find("iPod") != std::string::npos)
{
// All iPod touch has small screen
UserConfigParams::m_font_size = 5.0f;
UserConfigParams::m_multitouch_scale = 1.45f;
UserConfigParams::m_multitouch_sensitivity_x = 0.1f;
device.erase(0, 4);
auto versions = StringUtils::splitToUInt(device, ',');
if (versions.size() == 2)
{
// iPod Touch 7th Generation (A10)
if (versions[0] >= 9)
{
UserConfigParams::m_dynamic_lights = true;
UserConfigParams::m_high_definition_textures = 1;
}
}
}
}
#endif
#ifdef ANDROID
void android_main(struct android_app* app)
{