summaryrefslogtreecommitdiff
path: root/platform/iphone
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2020-12-27 01:50:21 +0100
committerHugo Locurcio <hugo.locurcio@hugo.pro>2022-02-15 20:55:53 +0100
commitee7cd9a3a14415722c1086a3bde02c2e4d0fd0eb (patch)
treed9d653e44615c17cc3b33d47997ee0cc4ff7009a /platform/iphone
parent171021145d49ffdda9110869d35ee63a946af9f8 (diff)
Add an `OS.get_processor_name()` method
This method can be used to get the CPU model name. It can be used in conjunction with `RenderingServer.get_video_adapter_name()` and `RenderingServer.get_video_adapter_vendor()` for annotating benchmarks and automatic graphics quality configuration.
Diffstat (limited to 'platform/iphone')
-rw-r--r--platform/iphone/os_iphone.h1
-rw-r--r--platform/iphone/os_iphone.mm10
2 files changed, 11 insertions, 0 deletions
diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h
index aca6f5fe2b..3281ff0cdb 100644
--- a/platform/iphone/os_iphone.h
+++ b/platform/iphone/os_iphone.h
@@ -109,6 +109,7 @@ public:
virtual String get_locale() const override;
virtual String get_unique_id() const override;
+ virtual String get_processor_name() const override;
virtual void vibrate_handheld(int p_duration_ms = 500) override;
diff --git a/platform/iphone/os_iphone.mm b/platform/iphone/os_iphone.mm
index 8350365d88..9fb6426b21 100644
--- a/platform/iphone/os_iphone.mm
+++ b/platform/iphone/os_iphone.mm
@@ -45,6 +45,7 @@
#import <AudioToolbox/AudioServices.h>
#import <UIKit/UIKit.h>
#import <dlfcn.h>
+#include <sys/sysctl.h>
#if defined(VULKAN_ENABLED)
#include "servers/rendering/renderer_rd/renderer_compositor_rd.h"
@@ -287,6 +288,15 @@ String OSIPhone::get_unique_id() const {
return String::utf8([uuid UTF8String]);
}
+String OSIPhone::get_processor_name() const {
+ char buffer[256];
+ size_t buffer_len = 256;
+ if (sysctlbyname("machdep.cpu.brand_string", &buffer, &buffer_len, NULL, 0) == 0) {
+ return String::utf8(buffer, buffer_len);
+ }
+ ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name. Returning an empty string."));
+}
+
void OSIPhone::vibrate_handheld(int p_duration_ms) {
// iOS does not support duration for vibration
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);