Merge pull request #102801 from bruvzg/tab_detect
[Windows] Read Wacom config to check if Windows Ink is disabled and auto switch to WinTab.
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user