1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-28 16:07:14 +00:00

[Windows] Read Wacom config to check if Windows Ink is disabled and auto switch to WinTab.

This commit is contained in:
bruvzg
2025-02-13 10:25:42 +02:00
committed by Pāvels Nadtočajevs
parent c2732ae4b6
commit 3f2a29cd9d
4 changed files with 48 additions and 6 deletions

View File

@@ -1429,9 +1429,14 @@
<member name="input_devices/pen_tablet/driver" type="String" setter="" getter="">
Specifies the tablet driver to use. If left empty, the default driver will be used.
[b]Note:[/b] The driver in use can be overridden at runtime via the [code]--tablet-driver[/code] [url=$DOCS_URL/tutorials/editor/command_line_tutorial.html]command line argument[/url].
[b]Note:[/b] Use [method DisplayServer.tablet_set_current_driver] to switch tablet driver in runtime.
</member>
<member name="input_devices/pen_tablet/driver.windows" type="String" setter="" getter="">
Override for [member input_devices/pen_tablet/driver] on Windows.
Override for [member input_devices/pen_tablet/driver] on Windows. Supported values are:
- [code]auto[/code] (default), uses [code]wintab[/code] if Windows Ink is disabled in the Wacom Tablet Properties or system settings, [code]winink[/code] otherwise.
- [code]winink[/code], uses Windows native "Windows Ink" driver.
- [code]wintab[/code], uses Wacom "WinTab" driver.
- [code]dummy[/code], tablet input is disabled.
</member>
<member name="input_devices/pointing/android/enable_long_press_as_right_click" type="bool" setter="" getter="" default="false">
If [code]true[/code], long press events on an Android touchscreen are transformed into right click events.

View File

@@ -3121,7 +3121,7 @@ Error Main::setup2(bool p_show_boot_logo) {
OS::get_singleton()->benchmark_begin_measure("Servers", "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, "winink,wintab,dummy"), "");
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "input_devices/pen_tablet/driver.windows", PROPERTY_HINT_ENUM, "auto,winink,wintab,dummy"), "");
if (tablet_driver.is_empty()) { // specified in project.godot
tablet_driver = GLOBAL_GET("input_devices/pen_tablet/driver");
@@ -3141,7 +3141,7 @@ Error Main::setup2(bool p_show_boot_logo) {
DisplayServer::get_singleton()->tablet_set_current_driver(DisplayServer::get_singleton()->tablet_get_driver_name(0));
}
print_verbose("Using \"" + tablet_driver + "\" pen tablet driver...");
print_verbose("Using \"" + DisplayServer::get_singleton()->tablet_get_current_driver() + "\" pen tablet driver...");
OS::get_singleton()->benchmark_end_measure("Servers", "Tablet Driver");
}

View File

@@ -36,6 +36,7 @@
#include "core/config/project_settings.h"
#include "core/io/marshalls.h"
#include "core/io/xml_parser.h"
#include "core/version.h"
#include "drivers/png/png_driver_common.h"
#include "main/main.h"
@@ -6528,15 +6529,27 @@ void DisplayServerWindows::tablet_set_current_driver(const String &p_driver) {
if (tablet_get_driver_count() == 0) {
return;
}
String driver = p_driver;
if (driver == "auto") {
if (winink_available && !winink_disabled) {
driver = "winink";
} else if (wintab_available) {
driver = "wintab";
} else {
driver = "dummy";
}
}
bool found = false;
for (int i = 0; i < tablet_get_driver_count(); i++) {
if (p_driver == tablet_get_driver_name(i)) {
if (driver == tablet_get_driver_name(i)) {
found = true;
}
}
if (found) {
_update_tablet_ctx(tablet_driver, p_driver);
tablet_driver = p_driver;
_update_tablet_ctx(tablet_driver, driver);
tablet_driver = driver;
} else {
ERR_PRINT("Unknown tablet driver " + p_driver + ".");
}
@@ -6635,6 +6648,8 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
}
}
tablet_drivers.push_back("auto");
// 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");
@@ -6669,6 +6684,27 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
tablet_drivers.push_back("dummy");
String wacom_cfg = OS::get_singleton()->get_config_path().path_join("WTablet").path_join("Wacom_Tablet.dat");
if (FileAccess::exists(wacom_cfg)) {
Ref<XMLParser> parser;
parser.instantiate();
if (parser->open(wacom_cfg) == OK) {
while (parser->read() == OK) {
if (parser->get_node_type() != XMLParser::NODE_ELEMENT) {
continue;
}
if (parser->get_node_name() == "WinUseInk") {
parser->read();
if (parser->get_node_type() == XMLParser::NODE_TEXT) {
winink_disabled = (parser->get_node_data().to_lower().strip_edges() != "true");
print_verbose(vformat("Wacom tablet config found at \"%s\", Windows Ink support is %s.", wacom_cfg, winink_disabled ? "disabled" : "enabled"));
break;
}
}
}
}
}
if (OS::get_singleton()->is_hidpi_allowed()) {
HMODULE Shcore = LoadLibraryW(L"Shcore.dll");

View File

@@ -405,6 +405,7 @@ class DisplayServerWindows : public DisplayServer {
void _update_tablet_ctx(const String &p_old_driver, const String &p_new_driver);
String tablet_driver;
Vector<String> tablet_drivers;
bool winink_disabled = false;
enum DriverID {
DRIVER_ID_COMPAT_OPENGL3 = 1 << 0,