1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-14 00:14:18 +00:00

iOS: Return the device model name from SystemStats::getDeviceDescription() when running in the simulator

This commit is contained in:
ed 2019-03-01 10:54:10 +00:00
parent 80c5f5e15e
commit 1bc7fdd1ec

View file

@ -159,11 +159,28 @@ String SystemStats::getDeviceDescription()
#endif
size_t size;
if (sysctlbyname (name, nullptr, &size, nullptr, 0) >= 0)
{
HeapBlock<char> model (size);
if (sysctlbyname (name, model, &size, nullptr, 0) >= 0)
return model.get();
if (sysctlbyname (name, model, &size, nullptr, 0) >= 0)
{
String description (model.get());
#if JUCE_IOS
if (description == "x86_64") // running in the simulator
{
if (auto* userInfo = [[NSProcessInfo processInfo] environment])
{
if (auto* simDeviceName = [userInfo objectForKey: @"SIMULATOR_DEVICE_NAME"])
return nsStringToJuce (simDeviceName);
}
}
#endif
return description;
}
}
return {};