Browse Source

Merge pull request #46131 from bruvzg/move_tablet_to_ds

Move tablet driver API from OS to DisplayServer
Rémi Verschelde 4 years ago
parent
commit
247b7e2448

+ 0 - 23
core/core_bind.cpp

@@ -681,22 +681,6 @@ String _OS::get_unique_id() const {
 	return OS::get_singleton()->get_unique_id();
 }
 
-int _OS::get_tablet_driver_count() const {
-	return OS::get_singleton()->get_tablet_driver_count();
-}
-
-String _OS::get_tablet_driver_name(int p_driver) const {
-	return OS::get_singleton()->get_tablet_driver_name(p_driver);
-}
-
-String _OS::get_current_tablet_driver() const {
-	return OS::get_singleton()->get_current_tablet_driver();
-}
-
-void _OS::set_current_tablet_driver(const String &p_driver) {
-	OS::get_singleton()->set_current_tablet_driver(p_driver);
-}
-
 _OS *_OS::singleton = nullptr;
 
 void _OS::_bind_methods() {
@@ -780,19 +764,12 @@ void _OS::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("request_permissions"), &_OS::request_permissions);
 	ClassDB::bind_method(D_METHOD("get_granted_permissions"), &_OS::get_granted_permissions);
 
-	ClassDB::bind_method(D_METHOD("get_tablet_driver_count"), &_OS::get_tablet_driver_count);
-	ClassDB::bind_method(D_METHOD("get_tablet_driver_name", "idx"), &_OS::get_tablet_driver_name);
-	ClassDB::bind_method(D_METHOD("get_current_tablet_driver"), &_OS::get_current_tablet_driver);
-	ClassDB::bind_method(D_METHOD("set_current_tablet_driver", "name"), &_OS::set_current_tablet_driver);
-
 	ADD_PROPERTY(PropertyInfo(Variant::INT, "exit_code"), "set_exit_code", "get_exit_code");
 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "low_processor_usage_mode"), "set_low_processor_usage_mode", "is_in_low_processor_usage_mode");
 	ADD_PROPERTY(PropertyInfo(Variant::INT, "low_processor_usage_mode_sleep_usec"), "set_low_processor_usage_mode_sleep_usec", "get_low_processor_usage_mode_sleep_usec");
-	ADD_PROPERTY(PropertyInfo(Variant::STRING, "tablet_driver"), "set_current_tablet_driver", "get_current_tablet_driver");
 
 	// Those default values need to be specified for the docs generator,
 	// to avoid using values from the documentation writer's own OS instance.
-	ADD_PROPERTY_DEFAULT("tablet_driver", "");
 	ADD_PROPERTY_DEFAULT("exit_code", 0);
 	ADD_PROPERTY_DEFAULT("low_processor_usage_mode", false);
 	ADD_PROPERTY_DEFAULT("low_processor_usage_mode_sleep_usec", 6900);

+ 0 - 5
core/core_bind.h

@@ -248,11 +248,6 @@ public:
 	bool request_permissions();
 	Vector<String> get_granted_permissions() const;
 
-	int get_tablet_driver_count() const;
-	String get_tablet_driver_name(int p_driver) const;
-	String get_current_tablet_driver() const;
-	void set_current_tablet_driver(const String &p_driver);
-
 	static _OS *get_singleton() { return singleton; }
 
 	_OS() { singleton = this; }

+ 0 - 5
core/os/os.h

@@ -149,11 +149,6 @@ public:
 	bool is_layered_allowed() const { return _allow_layered; }
 	bool is_hidpi_allowed() const { return _allow_hidpi; }
 
-	virtual int get_tablet_driver_count() const { return 0; };
-	virtual String get_tablet_driver_name(int p_driver) const { return ""; };
-	virtual String get_current_tablet_driver() const { return ""; };
-	virtual void set_current_tablet_driver(const String &p_driver){};
-
 	void ensure_user_data_dir();
 
 	virtual MainLoop *get_main_loop() const = 0;

+ 36 - 0
doc/classes/DisplayServer.xml

@@ -635,6 +635,42 @@
 			<description>
 			</description>
 		</method>
+		<method name="tablet_get_current_driver" qualifiers="const">
+			<return type="String">
+			</return>
+			<description>
+				Returns current active tablet driver name.
+				[b]Note:[/b] This method is implemented on Windows.
+			</description>
+		</method>
+		<method name="tablet_get_driver_count" qualifiers="const">
+			<return type="int">
+			</return>
+			<description>
+				Returns the total number of available tablet drivers.
+				[b]Note:[/b] This method is implemented on Windows.
+			</description>
+		</method>
+		<method name="tablet_get_driver_name" qualifiers="const">
+			<return type="String">
+			</return>
+			<argument index="0" name="idx" type="int">
+			</argument>
+			<description>
+				Returns the tablet driver name for the given index.
+				[b]Note:[/b] This method is implemented on Windows.
+			</description>
+		</method>
+		<method name="tablet_set_current_driver">
+			<return type="void">
+			</return>
+			<argument index="0" name="name" type="String">
+			</argument>
+			<description>
+				Set active tablet driver name.
+				[b]Note:[/b] This method is implemented on Windows.
+			</description>
+		</method>
 		<method name="virtual_keyboard_get_height" qualifiers="const">
 			<return type="int">
 			</return>

+ 0 - 21
doc/classes/OS.xml

@@ -304,24 +304,6 @@
 				[b]Note:[/b] This method is implemented on Android, Linux, macOS and Windows.
 			</description>
 		</method>
-		<method name="get_tablet_driver_count" qualifiers="const">
-			<return type="int">
-			</return>
-			<description>
-				Returns the total number of available tablet drivers.
-				[b]Note:[/b] This method is implemented on Windows.
-			</description>
-		</method>
-		<method name="get_tablet_driver_name" qualifiers="const">
-			<return type="String">
-			</return>
-			<argument index="0" name="idx" type="int">
-			</argument>
-			<description>
-				Returns the tablet driver name for the given index.
-				[b]Note:[/b] This method is implemented on Windows.
-			</description>
-		</method>
 		<method name="get_thread_caller_id" qualifiers="const">
 			<return type="int">
 			</return>
@@ -563,9 +545,6 @@
 		<member name="low_processor_usage_mode_sleep_usec" type="int" setter="set_low_processor_usage_mode_sleep_usec" getter="get_low_processor_usage_mode_sleep_usec" default="6900">
 			The amount of sleeping between frames when the low-processor usage mode is enabled (in microseconds). Higher values will result in lower CPU usage.
 		</member>
-		<member name="tablet_driver" type="String" setter="set_current_tablet_driver" getter="get_current_tablet_driver" default="&quot;&quot;">
-			The current tablet driver in use.
-		</member>
 	</members>
 	<constants>
 		<constant name="VIDEO_DRIVER_GLES2" value="0" enum="VideoDriver">

+ 6 - 3
doc/classes/ProjectSettings.xml

@@ -469,6 +469,12 @@
 		<member name="display/mouse_cursor/tooltip_position_offset" type="Vector2" setter="" getter="" default="Vector2( 10, 10 )">
 			Position offset for tooltips, relative to the mouse cursor's hotspot.
 		</member>
+		<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.
+		</member>
+		<member name="input_devices/pen_tablet/driver.windows" type="String" setter="" getter="">
+			Override for [member input_devices/pen_tablet/driver] on Windows.
+		</member>
 		<member name="display/window/dpi/allow_hidpi" type="bool" setter="" getter="" default="false">
 			If [code]true[/code], allows HiDPI display on Windows and macOS. This setting has no effect on desktop Linux, as DPI-awareness fallbacks are not supported there.
 		</member>
@@ -513,9 +519,6 @@
 		<member name="display/window/size/width" type="int" setter="" getter="" default="1024">
 			Sets the game's main viewport width. On desktop platforms, this is the default window size. Stretch mode settings also use this as a reference when enabled.
 		</member>
-		<member name="display/window/tablet_driver" type="String" setter="" getter="">
-			Specifies the tablet driver to use. If left empty, the default driver will be used.
-		</member>
 		<member name="display/window/text_name" type="String" setter="" getter="" default="&quot;&quot;">
 			Specifies the [TextServer] to use. If left empty, the default will be used.
 		</member>

+ 32 - 45
main/main.cpp

@@ -123,7 +123,9 @@ static bool _start_success = false;
 
 // Drivers
 
+String tablet_driver = "";
 String text_driver = "";
+
 static int text_driver_idx = -1;
 static int display_driver_idx = -1;
 static int audio_driver_idx = -1;
@@ -329,13 +331,7 @@ void Main::print_help(const char *p_binary) {
 	OS::get_singleton()->print("  --enable-vsync-via-compositor                When vsync is enabled, vsync via the OS' window compositor (Windows only).\n");
 	OS::get_singleton()->print("  --disable-vsync-via-compositor               Disable vsync via the OS' window compositor (Windows only).\n");
 	OS::get_singleton()->print("  --single-window                              Use a single window (no separate subwindows).\n");
-	OS::get_singleton()->print("  --tablet-driver                              Tablet input driver (");
-	for (int i = 0; i < OS::get_singleton()->get_tablet_driver_count(); i++) {
-		if (i != 0)
-			OS::get_singleton()->print(", ");
-		OS::get_singleton()->print("'%s'", OS::get_singleton()->get_tablet_driver_name(i).utf8().get_data());
-	}
-	OS::get_singleton()->print(") (Windows only).\n");
+	OS::get_singleton()->print("  --tablet-driver                              Pen tablet input driver.\n");
 	OS::get_singleton()->print("\n");
 #endif
 
@@ -556,7 +552,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
 
 	String display_driver = "";
 	String audio_driver = "";
-	String tablet_driver = "";
 	String project_path = ".";
 	bool upwards = false;
 	String debug_uri = "";
@@ -725,19 +720,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
 		} else if (I->get() == "--tablet-driver") {
 			if (I->next()) {
 				tablet_driver = I->next()->get();
-				bool found = false;
-				for (int i = 0; i < OS::get_singleton()->get_tablet_driver_count(); i++) {
-					if (tablet_driver == OS::get_singleton()->get_tablet_driver_name(i)) {
-						found = true;
-					}
-				}
-
-				if (!found) {
-					OS::get_singleton()->print("Unknown tablet driver '%s', aborting.\n",
-							tablet_driver.utf8().get_data());
-					goto error;
-				}
-
 				N = I->next()->next();
 			} else {
 				OS::get_singleton()->print("Missing tablet driver argument, aborting.\n");
@@ -1267,29 +1249,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
 
 	OS::get_singleton()->_vsync_via_compositor = window_vsync_via_compositor;
 
-	{
-		GLOBAL_DEF_RST_NOVAL("input_devices/tablet/driver", "");
-		GLOBAL_DEF_RST_NOVAL("input_devices/tablet/driver.windows", "");
-		ProjectSettings::get_singleton()->set_custom_property_info("input_devices/tablet/driver.windows", PropertyInfo(Variant::STRING, "input_devices/tablet/driver.windows", PROPERTY_HINT_ENUM, "wintab,winink"));
-	}
-	if (tablet_driver == "") { // specified in project.godot
-		tablet_driver = GLOBAL_GET("input_devices/tablet/driver");
-		if (tablet_driver == "") {
-			tablet_driver = OS::get_singleton()->get_tablet_driver_name(0);
-		}
-	}
-
-	for (int i = 0; i < OS::get_singleton()->get_tablet_driver_count(); i++) {
-		if (tablet_driver == OS::get_singleton()->get_tablet_driver_name(i)) {
-			OS::get_singleton()->set_current_tablet_driver(OS::get_singleton()->get_tablet_driver_name(i));
-			break;
-		}
-	}
-
-	if (tablet_driver == "") {
-		OS::get_singleton()->set_current_tablet_driver(OS::get_singleton()->get_tablet_driver_name(0));
-	}
-
 	/* todo restore
     OS::get_singleton()->_allow_layered = GLOBAL_DEF("display/window/per_pixel_transparency/allowed", false);
     video_mode.layered = GLOBAL_DEF("display/window/per_pixel_transparency/enabled", false);
@@ -1511,7 +1470,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
 			}
 		}
 	}
-	printf("Using %s text server...\n", TextServerManager::get_interface_name(text_driver_idx).utf8().get_data());
+	print_verbose("Using \"" + TextServerManager::get_interface_name(text_driver_idx) + "\" text server...");
 
 	/* Initialize Text Server */
 
@@ -1571,6 +1530,34 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
 		display_server->screen_set_orientation(window_orientation);
 	}
 
+	/* Initialize Pen Table Driver */
+
+	{
+		GLOBAL_DEF_RST_NOVAL("input_devices/pen_tablet/driver", "");
+		GLOBAL_DEF_RST_NOVAL("input_devices/pen_tablet/driver.windows", "");
+		ProjectSettings::get_singleton()->set_custom_property_info("input_devices/pen_tablet/driver.windows", PropertyInfo(Variant::STRING, "input_devices/pen_tablet/driver.windows", PROPERTY_HINT_ENUM, "wintab,winink"));
+	}
+
+	if (tablet_driver == "") { // specified in project.godot
+		tablet_driver = GLOBAL_GET("input_devices/pen_tablet/driver");
+		if (tablet_driver == "") {
+			tablet_driver = DisplayServer::get_singleton()->tablet_get_driver_name(0);
+		}
+	}
+
+	for (int i = 0; i < DisplayServer::get_singleton()->tablet_get_driver_count(); i++) {
+		if (tablet_driver == DisplayServer::get_singleton()->tablet_get_driver_name(i)) {
+			DisplayServer::get_singleton()->tablet_set_current_driver(DisplayServer::get_singleton()->tablet_get_driver_name(i));
+			break;
+		}
+	}
+
+	if (DisplayServer::get_singleton()->tablet_get_current_driver() == "") {
+		DisplayServer::get_singleton()->tablet_set_current_driver(DisplayServer::get_singleton()->tablet_get_driver_name(0));
+	}
+
+	print_verbose("Using \"" + tablet_driver + "\" pen tablet driver...");
+
 	/* Initialize Visual Server */
 
 	rendering_server = memnew(RenderingServerDefault(OS::get_singleton()->get_render_thread_mode() == OS::RENDER_SEPARATE_THREAD));

+ 71 - 8
platform/windows/display_server_windows.cpp

@@ -535,7 +535,7 @@ void DisplayServerWindows::delete_sub_window(WindowID p_window) {
 	}
 #endif
 
-	if ((OS::get_singleton()->get_current_tablet_driver() == "wintab") && wintab_available && windows[p_window].wtctx) {
+	if ((tablet_get_current_driver() == "wintab") && wintab_available && windows[p_window].wtctx) {
 		wintab_WTClose(windows[p_window].wtctx);
 		windows[p_window].wtctx = 0;
 	}
@@ -2021,7 +2021,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
 		} break;
 		case WT_CSRCHANGE:
 		case WT_PROXIMITY: {
-			if ((OS::get_singleton()->get_current_tablet_driver() == "wintab") && wintab_available && windows[window_id].wtctx) {
+			if ((tablet_get_current_driver() == "wintab") && wintab_available && windows[window_id].wtctx) {
 				AXIS pressure;
 				if (wintab_WTInfo(WTI_DEVICES + windows[window_id].wtlc.lcDevice, DVC_NPRESSURE, &pressure)) {
 					windows[window_id].min_pressure = int(pressure.axMin);
@@ -2035,7 +2035,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
 			}
 		} break;
 		case WT_PACKET: {
-			if ((OS::get_singleton()->get_current_tablet_driver() == "wintab") && wintab_available && windows[window_id].wtctx) {
+			if ((tablet_get_current_driver() == "wintab") && wintab_available && windows[window_id].wtctx) {
 				PACKET packet;
 				if (wintab_WTPacket(windows[window_id].wtctx, wParam, &packet)) {
 					float pressure = float(packet.pkNormalPressure - windows[window_id].min_pressure) / float(windows[window_id].max_pressure - windows[window_id].min_pressure);
@@ -2114,7 +2114,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
 				break;
 			}
 
-			if ((OS::get_singleton()->get_current_tablet_driver() != "winink") || !winink_available) {
+			if ((tablet_get_current_driver() != "winink") || !winink_available) {
 				break;
 			}
 
@@ -2140,7 +2140,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
 				break;
 			}
 
-			if ((OS::get_singleton()->get_current_tablet_driver() != "winink") || !winink_available) {
+			if ((tablet_get_current_driver() != "winink") || !winink_available) {
 				break;
 			}
 
@@ -2304,7 +2304,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
 			mm->set_shift((wParam & MK_SHIFT) != 0);
 			mm->set_alt(alt_mem);
 
-			if ((OS::get_singleton()->get_current_tablet_driver() == "wintab") && wintab_available && windows[window_id].wtctx) {
+			if ((tablet_get_current_driver() == "wintab") && wintab_available && windows[window_id].wtctx) {
 				// Note: WinTab sends both WT_PACKET and WM_xBUTTONDOWN/UP/MOUSEMOVE events, use mouse 1/0 pressure only when last_pressure was not update recently.
 				if (windows[window_id].last_pressure_update < 10) {
 					windows[window_id].last_pressure_update++;
@@ -2799,7 +2799,7 @@ void DisplayServerWindows::_process_activate_event(WindowID p_window_id, WPARAM
 		alt_mem = false;
 	}
 
-	if ((OS::get_singleton()->get_current_tablet_driver() == "wintab") && wintab_available && windows[p_window_id].wtctx) {
+	if ((tablet_get_current_driver() == "wintab") && wintab_available && windows[p_window_id].wtctx) {
 		wintab_WTEnable(windows[p_window_id].wtctx, GET_WM_ACTIVATE_STATE(wParam, lParam));
 	}
 }
@@ -3037,7 +3037,7 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode,
 
 		DragAcceptFiles(wd.hWnd, true);
 
-		if ((OS::get_singleton()->get_current_tablet_driver() == "wintab") && wintab_available) {
+		if ((tablet_get_current_driver() == "wintab") && wintab_available) {
 			wintab_WTInfo(WTI_DEFSYSCTX, 0, &wd.wtlc);
 			wd.wtlc.lcOptions |= CXO_MESSAGES;
 			wd.wtlc.lcPktData = PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE | PK_ORIENTATION;
@@ -3104,6 +3104,40 @@ typedef enum _SHC_PROCESS_DPI_AWARENESS {
 	SHC_PROCESS_PER_MONITOR_DPI_AWARE = 2
 } SHC_PROCESS_DPI_AWARENESS;
 
+int DisplayServerWindows::tablet_get_driver_count() const {
+	return tablet_drivers.size();
+}
+
+String DisplayServerWindows::tablet_get_driver_name(int p_driver) const {
+	if (p_driver < 0 || p_driver >= tablet_drivers.size()) {
+		return "";
+	} else {
+		return tablet_drivers[p_driver];
+	}
+}
+
+String DisplayServerWindows::tablet_get_current_driver() const {
+	return tablet_driver;
+}
+
+void DisplayServerWindows::tablet_set_current_driver(const String &p_driver) {
+	if (tablet_get_driver_count() == 0) {
+		return;
+	}
+	bool found = false;
+	for (int i = 0; i < tablet_get_driver_count(); i++) {
+		if (p_driver == tablet_get_driver_name(i)) {
+			found = true;
+		}
+	}
+	if (found) {
+		_update_tablet_ctx(tablet_driver, p_driver);
+		tablet_driver = p_driver;
+	} else {
+		ERR_PRINT("Unknown tablet driver " + p_driver + ".");
+	}
+}
+
 DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
 	drop_events = false;
 	key_event_pos = 0;
@@ -3122,6 +3156,35 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
 
 	outside = true;
 
+	//Note: Wacom WinTab driver API for pen input, for devices incompatible with Windows Ink.
+	HMODULE wintab_lib = LoadLibraryW(L"wintab32.dll");
+	if (wintab_lib) {
+		wintab_WTOpen = (WTOpenPtr)GetProcAddress(wintab_lib, "WTOpenW");
+		wintab_WTClose = (WTClosePtr)GetProcAddress(wintab_lib, "WTClose");
+		wintab_WTInfo = (WTInfoPtr)GetProcAddress(wintab_lib, "WTInfoW");
+		wintab_WTPacket = (WTPacketPtr)GetProcAddress(wintab_lib, "WTPacket");
+		wintab_WTEnable = (WTEnablePtr)GetProcAddress(wintab_lib, "WTEnable");
+
+		wintab_available = wintab_WTOpen && wintab_WTClose && wintab_WTInfo && wintab_WTPacket && wintab_WTEnable;
+	}
+
+	if (wintab_available) {
+		tablet_drivers.push_back("wintab");
+	}
+
+	//Note: Windows Ink API for pen input, available on Windows 8+ 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");
+
+		winink_available = win8p_GetPointerType && win8p_GetPointerPenInfo;
+	}
+
+	if (winink_available) {
+		tablet_drivers.push_back("winink");
+	}
+
 	if (OS::get_singleton()->is_hidpi_allowed()) {
 		HMODULE Shcore = LoadLibraryW(L"Shcore.dll");
 

+ 7 - 2
platform/windows/display_server_windows.h

@@ -264,7 +264,6 @@ class DisplayServerWindows : public DisplayServer {
 
 	_THREAD_SAFE_CLASS_
 
-public:
 	// WinTab API
 	static bool wintab_available;
 	static WTOpenPtr wintab_WTOpen;
@@ -279,8 +278,9 @@ public:
 	static GetPointerPenInfoPtr win8p_GetPointerPenInfo;
 
 	void _update_tablet_ctx(const String &p_old_driver, const String &p_new_driver);
+	String tablet_driver;
+	Vector<String> tablet_drivers;
 
-private:
 	void GetMaskBitmaps(HBITMAP hSourceBitmap, COLORREF clrTransparent, OUT HBITMAP &hAndMaskBitmap, OUT HBITMAP &hXorMaskBitmap);
 
 	enum {
@@ -542,6 +542,11 @@ public:
 	virtual String keyboard_get_layout_language(int p_index) const;
 	virtual String keyboard_get_layout_name(int p_index) const;
 
+	virtual int tablet_get_driver_count() const;
+	virtual String tablet_get_driver_name(int p_driver) const;
+	virtual String tablet_get_current_driver() const;
+	virtual void tablet_set_current_driver(const String &p_driver);
+
 	virtual void process_events();
 
 	virtual void force_process_and_drop_events();

+ 0 - 65
platform/windows/os_windows.cpp

@@ -765,77 +765,12 @@ Error OS_Windows::move_to_trash(const String &p_path) {
 	return OK;
 }
 
-int OS_Windows::get_tablet_driver_count() const {
-	return tablet_drivers.size();
-}
-
-String OS_Windows::get_tablet_driver_name(int p_driver) const {
-	if (p_driver < 0 || p_driver >= tablet_drivers.size()) {
-		return "";
-	} else {
-		return tablet_drivers[p_driver];
-	}
-}
-
-String OS_Windows::get_current_tablet_driver() const {
-	return tablet_driver;
-}
-
-void OS_Windows::set_current_tablet_driver(const String &p_driver) {
-	if (get_tablet_driver_count() == 0) {
-		return;
-	}
-	bool found = false;
-	for (int i = 0; i < get_tablet_driver_count(); i++) {
-		if (p_driver == get_tablet_driver_name(i)) {
-			found = true;
-		}
-	}
-	if (found) {
-		if (DisplayServerWindows::get_singleton()) {
-			((DisplayServerWindows *)DisplayServerWindows::get_singleton())->_update_tablet_ctx(tablet_driver, p_driver);
-		}
-		tablet_driver = p_driver;
-	} else {
-		ERR_PRINT("Unknown tablet driver " + p_driver + ".");
-	}
-}
-
 OS_Windows::OS_Windows(HINSTANCE _hInstance) {
 	ticks_per_second = 0;
 	ticks_start = 0;
 	main_loop = nullptr;
 	process_map = nullptr;
 
-	//Note: Wacom WinTab driver API for pen input, for devices incompatible with Windows Ink.
-	HMODULE wintab_lib = LoadLibraryW(L"wintab32.dll");
-	if (wintab_lib) {
-		DisplayServerWindows::wintab_WTOpen = (WTOpenPtr)GetProcAddress(wintab_lib, "WTOpenW");
-		DisplayServerWindows::wintab_WTClose = (WTClosePtr)GetProcAddress(wintab_lib, "WTClose");
-		DisplayServerWindows::wintab_WTInfo = (WTInfoPtr)GetProcAddress(wintab_lib, "WTInfoW");
-		DisplayServerWindows::wintab_WTPacket = (WTPacketPtr)GetProcAddress(wintab_lib, "WTPacket");
-		DisplayServerWindows::wintab_WTEnable = (WTEnablePtr)GetProcAddress(wintab_lib, "WTEnable");
-
-		DisplayServerWindows::wintab_available = DisplayServerWindows::wintab_WTOpen && DisplayServerWindows::wintab_WTClose && DisplayServerWindows::wintab_WTInfo && DisplayServerWindows::wintab_WTPacket && DisplayServerWindows::wintab_WTEnable;
-	}
-
-	if (DisplayServerWindows::wintab_available) {
-		tablet_drivers.push_back("wintab");
-	}
-
-	//Note: Windows Ink API for pen input, available on Windows 8+ only.
-	HMODULE user32_lib = LoadLibraryW(L"user32.dll");
-	if (user32_lib) {
-		DisplayServerWindows::win8p_GetPointerType = (GetPointerTypePtr)GetProcAddress(user32_lib, "GetPointerType");
-		DisplayServerWindows::win8p_GetPointerPenInfo = (GetPointerPenInfoPtr)GetProcAddress(user32_lib, "GetPointerPenInfo");
-
-		DisplayServerWindows::winink_available = DisplayServerWindows::win8p_GetPointerType && DisplayServerWindows::win8p_GetPointerPenInfo;
-	}
-
-	if (DisplayServerWindows::winink_available) {
-		tablet_drivers.push_back("winink");
-	}
-
 	force_quit = false;
 
 	hInstance = _hInstance;

+ 0 - 8
platform/windows/os_windows.h

@@ -73,9 +73,6 @@ class OS_Windows : public OS {
 	HINSTANCE hInstance;
 	MainLoop *main_loop;
 
-	String tablet_driver;
-	Vector<String> tablet_drivers;
-
 #ifdef WASAPI_ENABLED
 	AudioDriverWASAPI driver_wasapi;
 #endif
@@ -119,11 +116,6 @@ public:
 
 	virtual String get_name() const override;
 
-	virtual int get_tablet_driver_count() const override;
-	virtual String get_tablet_driver_name(int p_driver) const override;
-	virtual String get_current_tablet_driver() const override;
-	virtual void set_current_tablet_driver(const String &p_driver) override;
-
 	virtual void initialize_joypads() override {}
 
 	virtual Date get_date(bool utc) const override;

+ 5 - 0
servers/display_server.cpp

@@ -504,6 +504,11 @@ void DisplayServer::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("set_native_icon", "filename"), &DisplayServer::set_native_icon);
 	ClassDB::bind_method(D_METHOD("set_icon", "image"), &DisplayServer::set_icon);
 
+	ClassDB::bind_method(D_METHOD("tablet_get_driver_count"), &DisplayServer::tablet_get_driver_count);
+	ClassDB::bind_method(D_METHOD("tablet_get_driver_name", "idx"), &DisplayServer::tablet_get_driver_name);
+	ClassDB::bind_method(D_METHOD("tablet_get_current_driver"), &DisplayServer::tablet_get_current_driver);
+	ClassDB::bind_method(D_METHOD("tablet_set_current_driver", "name"), &DisplayServer::tablet_set_current_driver);
+
 	BIND_ENUM_CONSTANT(FEATURE_GLOBAL_MENU);
 	BIND_ENUM_CONSTANT(FEATURE_SUBWINDOWS);
 	BIND_ENUM_CONSTANT(FEATURE_TOUCHSCREEN);

+ 5 - 0
servers/display_server.h

@@ -340,6 +340,11 @@ public:
 	virtual String keyboard_get_layout_language(int p_index) const;
 	virtual String keyboard_get_layout_name(int p_index) const;
 
+	virtual int tablet_get_driver_count() const { return 1; };
+	virtual String tablet_get_driver_name(int p_driver) const { return "default"; };
+	virtual String tablet_get_current_driver() const { return "default"; };
+	virtual void tablet_set_current_driver(const String &p_driver){};
+
 	virtual void process_events() = 0;
 
 	virtual void force_process_and_drop_events();