1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

[Windows] Add tablet driver selection.

This commit is contained in:
bruvzg
2020-05-19 23:34:26 +03:00
parent cba1f492cc
commit d0b5174b6a
10 changed files with 218 additions and 39 deletions

View File

@@ -139,7 +139,6 @@ static DisplayServer::ScreenOrientation window_orientation = DisplayServer::SCRE
static uint32_t window_flags = 0;
static Size2i window_size = Size2i(1024, 600);
static bool window_vsync_via_compositor = false;
static bool disable_wintab = false;
static int init_screen = -1;
static bool init_fullscreen = false;
@@ -313,7 +312,13 @@ 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(" --disable-wintab Disable WinTab API and always use Windows Ink API for the pen input (Windows only).\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("\n");
#endif
@@ -438,6 +443,7 @@ 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 = "";
@@ -590,8 +596,26 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "--gpu-abort") { // force windowed window
Engine::singleton->abort_on_gpu_errors = true;
} else if (I->get() == "--disable-wintab") {
disable_wintab = true;
} 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");
goto error;
}
} else if (I->get() == "--single-window") { // force single window
single_window = true;
@@ -1056,12 +1080,20 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->_vsync_via_compositor = window_vsync_via_compositor;
if (!disable_wintab) {
// No "--disable_wintab" option
disable_wintab = GLOBAL_DEF("display/window/disable_wintab_api", false);
if (tablet_driver == "") { // specified in project.godot
tablet_driver = GLOBAL_DEF_RST("display/window/tablet_driver", OS::get_singleton()->get_tablet_driver_name(0));
}
OS::get_singleton()->_disable_wintab = disable_wintab;
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);
@@ -1175,6 +1207,7 @@ error:
display_driver = "";
audio_driver = "";
tablet_driver = "";
project_path = "";
args.clear();