Merge pull request #15864 from GodotExplorer/pr-get_unique_id-desktop-impl
Implement more methods for OS on Desktop platforms
This commit is contained in:
commit
7d7f8d9e54
|
@ -346,7 +346,8 @@
|
||||||
<return type="String">
|
<return type="String">
|
||||||
</return>
|
</return>
|
||||||
<description>
|
<description>
|
||||||
Returns a string that is unique to the device. Currently only works on Android and iOS. Returns empty string on other platforms.
|
Returns a string that is unique to the device.
|
||||||
|
Returns empty string on HTML5 and UWP which are not supported yet.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_unix_time" qualifiers="const">
|
<method name="get_unix_time" qualifiers="const">
|
||||||
|
|
|
@ -230,6 +230,8 @@ public:
|
||||||
virtual void set_ime_position(const Point2 &p_pos);
|
virtual void set_ime_position(const Point2 &p_pos);
|
||||||
virtual void set_ime_intermediate_text_callback(ImeCallback p_callback, void *p_inp);
|
virtual void set_ime_intermediate_text_callback(ImeCallback p_callback, void *p_inp);
|
||||||
|
|
||||||
|
virtual String get_unique_id() const;
|
||||||
|
|
||||||
virtual OS::PowerState get_power_state();
|
virtual OS::PowerState get_power_state();
|
||||||
virtual int get_power_seconds_left();
|
virtual int get_power_seconds_left();
|
||||||
virtual int get_power_percent_left();
|
virtual int get_power_percent_left();
|
||||||
|
|
|
@ -963,6 +963,30 @@ void OS_OSX::set_ime_intermediate_text_callback(ImeCallback p_callback, void *p_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String OS_OSX::get_unique_id() const {
|
||||||
|
|
||||||
|
static String serial_number;
|
||||||
|
|
||||||
|
if (serial_number.empty()) {
|
||||||
|
io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
|
||||||
|
CFStringRef serialNumberAsCFString = NULL;
|
||||||
|
if (platformExpert) {
|
||||||
|
serialNumberAsCFString = (CFStringRef)IORegistryEntryCreateCFProperty(platformExpert, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, 0);
|
||||||
|
IOObjectRelease(platformExpert);
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *serialNumberAsNSString = nil;
|
||||||
|
if (serialNumberAsCFString) {
|
||||||
|
serialNumberAsNSString = [NSString stringWithString:(NSString *)serialNumberAsCFString];
|
||||||
|
CFRelease(serialNumberAsCFString);
|
||||||
|
}
|
||||||
|
|
||||||
|
serial_number = [serialNumberAsNSString UTF8String];
|
||||||
|
}
|
||||||
|
|
||||||
|
return serial_number;
|
||||||
|
}
|
||||||
|
|
||||||
void OS_OSX::set_ime_position(const Point2 &p_pos) {
|
void OS_OSX::set_ime_position(const Point2 &p_pos) {
|
||||||
im_position = p_pos;
|
im_position = p_pos;
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@ def configure(env):
|
||||||
if env["bits"] == "64":
|
if env["bits"] == "64":
|
||||||
env.Append(CCFLAGS=['/D_WIN64'])
|
env.Append(CCFLAGS=['/D_WIN64'])
|
||||||
|
|
||||||
LIBS = ['winmm', 'opengl32', 'dsound', 'kernel32', 'ole32', 'oleaut32', 'user32', 'gdi32', 'IPHLPAPI', 'Shlwapi', 'wsock32', 'Ws2_32', 'shell32', 'advapi32', 'dinput8', 'dxguid']
|
LIBS = ['winmm', 'opengl32', 'dsound', 'kernel32', 'ole32', 'oleaut32', 'user32', 'gdi32', 'IPHLPAPI', 'Shlwapi', 'wsock32', 'Ws2_32', 'shell32', 'advapi32', 'dinput8', 'dxguid', 'Imm32']
|
||||||
env.Append(LINKFLAGS=[p + env["LIBSUFFIX"] for p in LIBS])
|
env.Append(LINKFLAGS=[p + env["LIBSUFFIX"] for p in LIBS])
|
||||||
|
|
||||||
env.Append(LIBPATH=[os.getenv("WindowsSdkDir") + "/Lib"])
|
env.Append(LIBPATH=[os.getenv("WindowsSdkDir") + "/Lib"])
|
||||||
|
@ -281,7 +281,7 @@ def configure(env):
|
||||||
env.Append(CCFLAGS=['-DRTAUDIO_ENABLED'])
|
env.Append(CCFLAGS=['-DRTAUDIO_ENABLED'])
|
||||||
env.Append(CCFLAGS=['-DWASAPI_ENABLED'])
|
env.Append(CCFLAGS=['-DWASAPI_ENABLED'])
|
||||||
env.Append(CCFLAGS=['-DWINVER=%s' % env['target_win_version'], '-D_WIN32_WINNT=%s' % env['target_win_version']])
|
env.Append(CCFLAGS=['-DWINVER=%s' % env['target_win_version'], '-D_WIN32_WINNT=%s' % env['target_win_version']])
|
||||||
env.Append(LIBS=['mingw32', 'opengl32', 'dsound', 'ole32', 'd3d9', 'winmm', 'gdi32', 'iphlpapi', 'shlwapi', 'wsock32', 'ws2_32', 'kernel32', 'oleaut32', 'dinput8', 'dxguid', 'ksuser'])
|
env.Append(LIBS=['mingw32', 'opengl32', 'dsound', 'ole32', 'd3d9', 'winmm', 'gdi32', 'iphlpapi', 'shlwapi', 'wsock32', 'ws2_32', 'kernel32', 'oleaut32', 'dinput8', 'dxguid', 'ksuser', 'Imm32'])
|
||||||
|
|
||||||
env.Append(CPPFLAGS=['-DMINGW_ENABLED'])
|
env.Append(CPPFLAGS=['-DMINGW_ENABLED'])
|
||||||
|
|
||||||
|
|
|
@ -2448,6 +2448,24 @@ String OS_Windows::get_user_data_dir() const {
|
||||||
return ProjectSettings::get_singleton()->get_resource_path();
|
return ProjectSettings::get_singleton()->get_resource_path();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String OS_Windows::get_unique_id() const {
|
||||||
|
|
||||||
|
HW_PROFILE_INFO HwProfInfo;
|
||||||
|
ERR_FAIL_COND_V(!GetCurrentHwProfile(&HwProfInfo), "");
|
||||||
|
return String(HwProfInfo.szHwProfileGuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OS_Windows::set_ime_position(const Point2 &p_pos) {
|
||||||
|
|
||||||
|
HIMC himc = ImmGetContext(hWnd);
|
||||||
|
COMPOSITIONFORM cps;
|
||||||
|
cps.dwStyle = CFS_FORCE_POSITION;
|
||||||
|
cps.ptCurrentPos.x = p_pos.x;
|
||||||
|
cps.ptCurrentPos.y = p_pos.y;
|
||||||
|
ImmSetCompositionWindow(himc, &cps);
|
||||||
|
ImmReleaseContext(hWnd, himc);
|
||||||
|
}
|
||||||
|
|
||||||
bool OS_Windows::is_joy_known(int p_device) {
|
bool OS_Windows::is_joy_known(int p_device) {
|
||||||
return input->is_joy_mapped(p_device);
|
return input->is_joy_mapped(p_device);
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,6 +270,10 @@ public:
|
||||||
virtual String get_system_dir(SystemDir p_dir) const;
|
virtual String get_system_dir(SystemDir p_dir) const;
|
||||||
virtual String get_user_data_dir() const;
|
virtual String get_user_data_dir() const;
|
||||||
|
|
||||||
|
virtual String get_unique_id() const;
|
||||||
|
|
||||||
|
virtual void set_ime_position(const Point2 &p_pos);
|
||||||
|
|
||||||
virtual void release_rendering_thread();
|
virtual void release_rendering_thread();
|
||||||
virtual void make_rendering_thread();
|
virtual void make_rendering_thread();
|
||||||
virtual void swap_buffers();
|
virtual void swap_buffers();
|
||||||
|
|
|
@ -549,6 +549,21 @@ void OS_X11::set_ime_position(const Point2 &p_pos) {
|
||||||
XFree(preedit_attr);
|
XFree(preedit_attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String OS_X11::get_unique_id() const {
|
||||||
|
|
||||||
|
static String machine_id;
|
||||||
|
if (machine_id.empty()) {
|
||||||
|
if (FileAccess *f = FileAccess::open("/etc/machine-id", FileAccess::READ)) {
|
||||||
|
while (machine_id.empty() && !f->eof_reached()) {
|
||||||
|
machine_id = f->get_line().strip_edges();
|
||||||
|
}
|
||||||
|
f->close();
|
||||||
|
memdelete(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return machine_id;
|
||||||
|
}
|
||||||
|
|
||||||
void OS_X11::finalize() {
|
void OS_X11::finalize() {
|
||||||
|
|
||||||
if (main_loop)
|
if (main_loop)
|
||||||
|
|
|
@ -267,6 +267,8 @@ public:
|
||||||
virtual bool get_borderless_window();
|
virtual bool get_borderless_window();
|
||||||
virtual void set_ime_position(const Point2 &p_pos);
|
virtual void set_ime_position(const Point2 &p_pos);
|
||||||
|
|
||||||
|
virtual String get_unique_id() const;
|
||||||
|
|
||||||
virtual void move_window_to_foreground();
|
virtual void move_window_to_foreground();
|
||||||
virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
|
virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue