Browse Source

Windows: implement OS.get_unique_id and OS.set_ime_position

geequlim 7 years ago
parent
commit
3be04f73f5
3 changed files with 24 additions and 2 deletions
  1. 2 2
      platform/windows/detect.py
  2. 18 0
      platform/windows/os_windows.cpp
  3. 4 0
      platform/windows/os_windows.h

+ 2 - 2
platform/windows/detect.py

@@ -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'])
 
 

+ 18 - 0
platform/windows/os_windows.cpp

@@ -2442,6 +2442,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);
 }
 }

+ 4 - 0
platform/windows/os_windows.h

@@ -269,6 +269,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();