瀏覽代碼

[Windows] Make Windows Ink tablet API default, add dummy driver to disable tablet input.

bruvzg 1 年之前
父節點
當前提交
e01b22a69d
共有 3 個文件被更改,包括 22 次插入16 次删除
  1. 4 0
      doc/classes/DisplayServer.xml
  2. 1 1
      main/main.cpp
  3. 17 15
      platform/windows/display_server_windows.cpp

+ 4 - 0
doc/classes/DisplayServer.xml

@@ -1122,6 +1122,10 @@
 			<param index="0" name="name" type="String" />
 			<param index="0" name="name" type="String" />
 			<description>
 			<description>
 				Set active tablet driver name.
 				Set active tablet driver name.
+				Supported drivers:
+				- [code]winink[/code]: Windows Ink API, default (Windows 8.1+ required).
+				- [code]wintab[/code]: Wacom Wintab API (compatible device driver required).
+				- [code]dummy[/code]: Dummy driver, tablet input is disabled.
 				[b]Note:[/b] This method is implemented only on Windows.
 				[b]Note:[/b] This method is implemented only on Windows.
 			</description>
 			</description>
 		</method>
 		</method>

+ 1 - 1
main/main.cpp

@@ -2502,7 +2502,7 @@ Error Main::setup2() {
 		OS::get_singleton()->benchmark_begin_measure("Servers", "Tablet Driver");
 		OS::get_singleton()->benchmark_begin_measure("Servers", "Tablet Driver");
 
 
 		GLOBAL_DEF_RST_NOVAL("input_devices/pen_tablet/driver", "");
 		GLOBAL_DEF_RST_NOVAL("input_devices/pen_tablet/driver", "");
-		GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "input_devices/pen_tablet/driver.windows", PROPERTY_HINT_ENUM, "wintab,winink"), "");
+		GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "input_devices/pen_tablet/driver.windows", PROPERTY_HINT_ENUM, "winink,wintab,dummy"), "");
 
 
 		if (tablet_driver.is_empty()) { // specified in project.godot
 		if (tablet_driver.is_empty()) { // specified in project.godot
 			tablet_driver = GLOBAL_GET("input_devices/pen_tablet/driver");
 			tablet_driver = GLOBAL_GET("input_devices/pen_tablet/driver");

+ 17 - 15
platform/windows/display_server_windows.cpp

@@ -4606,6 +4606,22 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
 		}
 		}
 	}
 	}
 
 
+	// Note: Windows Ink API for pen input, available on Windows 8+ only.
+	// Note: DPI conversion API, available on Windows 8.1+ only.
+	HMODULE user32_lib = LoadLibraryW(L"user32.dll");
+	if (user32_lib) {
+		win8p_GetPointerType = (GetPointerTypePtr)GetProcAddress(user32_lib, "GetPointerType");
+		win8p_GetPointerPenInfo = (GetPointerPenInfoPtr)GetProcAddress(user32_lib, "GetPointerPenInfo");
+		win81p_LogicalToPhysicalPointForPerMonitorDPI = (LogicalToPhysicalPointForPerMonitorDPIPtr)GetProcAddress(user32_lib, "LogicalToPhysicalPointForPerMonitorDPI");
+		win81p_PhysicalToLogicalPointForPerMonitorDPI = (PhysicalToLogicalPointForPerMonitorDPIPtr)GetProcAddress(user32_lib, "PhysicalToLogicalPointForPerMonitorDPI");
+
+		winink_available = win8p_GetPointerType && win8p_GetPointerPenInfo;
+	}
+
+	if (winink_available) {
+		tablet_drivers.push_back("winink");
+	}
+
 	// Note: Wacom WinTab driver API for pen input, for devices incompatible with Windows Ink.
 	// Note: Wacom WinTab driver API for pen input, for devices incompatible with Windows Ink.
 	HMODULE wintab_lib = LoadLibraryW(L"wintab32.dll");
 	HMODULE wintab_lib = LoadLibraryW(L"wintab32.dll");
 	if (wintab_lib) {
 	if (wintab_lib) {
@@ -4622,21 +4638,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
 		tablet_drivers.push_back("wintab");
 		tablet_drivers.push_back("wintab");
 	}
 	}
 
 
-	// Note: Windows Ink API for pen input, available on Windows 8+ only.
-	// Note: DPI conversion API, available on Windows 8.1+ only.
-	HMODULE user32_lib = LoadLibraryW(L"user32.dll");
-	if (user32_lib) {
-		win8p_GetPointerType = (GetPointerTypePtr)GetProcAddress(user32_lib, "GetPointerType");
-		win8p_GetPointerPenInfo = (GetPointerPenInfoPtr)GetProcAddress(user32_lib, "GetPointerPenInfo");
-		win81p_LogicalToPhysicalPointForPerMonitorDPI = (LogicalToPhysicalPointForPerMonitorDPIPtr)GetProcAddress(user32_lib, "LogicalToPhysicalPointForPerMonitorDPI");
-		win81p_PhysicalToLogicalPointForPerMonitorDPI = (PhysicalToLogicalPointForPerMonitorDPIPtr)GetProcAddress(user32_lib, "PhysicalToLogicalPointForPerMonitorDPI");
-
-		winink_available = win8p_GetPointerType && win8p_GetPointerPenInfo;
-	}
-
-	if (winink_available) {
-		tablet_drivers.push_back("winink");
-	}
+	tablet_drivers.push_back("dummy");
 
 
 	if (OS::get_singleton()->is_hidpi_allowed()) {
 	if (OS::get_singleton()->is_hidpi_allowed()) {
 		HMODULE Shcore = LoadLibraryW(L"Shcore.dll");
 		HMODULE Shcore = LoadLibraryW(L"Shcore.dll");