From 526572c9c94cb0465909ba2934d7331e8d53c203 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Fri, 8 Jan 2021 03:12:42 +1100 Subject: [PATCH] [client] added new feature input:rawMouse for RAW mouse input This option allows those that want it (gamers) to bypass all X11 mouse acceleration and smoothing giving true 1:1 input to the guest while in capture mode. Note: only supported for X11! --- client/src/config.c | 22 +++++++++++++++------- client/src/main.c | 22 ++++++++++------------ client/src/main.h | 1 + 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/client/src/config.c b/client/src/config.c index c62e0638..c63a22c3 100644 --- a/client/src/config.c +++ b/client/src/config.c @@ -282,6 +282,13 @@ static struct Option options[] = .type = OPTION_TYPE_INT, .value.x_int = 0, }, + { + .module = "input", + .name = "rawMouse", + .description = "Use RAW mouse input when in capture mode (good for gaming)", + .type = OPTION_TYPE_BOOL, + .value.x_bool = false, + }, { .module = "input", .name = "mouseRedraw", @@ -447,13 +454,14 @@ bool config_load(int argc, char * argv[]) params.showAlerts = option_get_bool ("win", "alerts" ); params.quickSplash = option_get_bool ("win", "quickSplash" ); - params.grabKeyboard = option_get_bool ("input", "grabKeyboard" ); - params.grabKeyboardOnFocus = option_get_bool ("input", "grabKeyboardOnFocus"); - params.escapeKey = option_get_int ("input", "escapeKey" ); - params.ignoreWindowsKeys = option_get_bool ("input", "ignoreWindowsKeys" ); - params.hideMouse = option_get_bool ("input", "hideCursor" ); - params.mouseSens = option_get_int ("input", "mouseSens" ); - params.mouseRedraw = option_get_bool ("input", "mouseRedraw" ); + params.grabKeyboard = option_get_bool("input", "grabKeyboard" ); + params.grabKeyboardOnFocus = option_get_bool("input", "grabKeyboardOnFocus"); + params.escapeKey = option_get_int ("input", "escapeKey" ); + params.ignoreWindowsKeys = option_get_bool("input", "ignoreWindowsKeys" ); + params.hideMouse = option_get_bool("input", "hideCursor" ); + params.mouseSens = option_get_int ("input", "mouseSens" ); + params.rawMouse = option_get_bool("input", "rawMouse" ); + params.mouseRedraw = option_get_bool("input", "mouseRedraw" ); params.minimizeOnFocusLoss = option_get_bool("win", "minimizeOnFocusLoss"); diff --git a/client/src/main.c b/client/src/main.c index f78c80a7..1f0e10f2 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -1254,24 +1254,21 @@ int eventFilter(void * userdata, SDL_Event * event) break; XIRawEvent *raw = cookie->data; + double axis[2]; -#if 0 - /* true RAW mode, however the UX is pretty poor with it, perhaps - * make this an option later? */ - const double x = raw->raw_values[0]; - const double y = raw->raw_values[1]; - handleMouseRawEvent(x, y); -#else /* select the active validators for the X & Y axis */ double *valuator = raw->valuators.values; double *value = raw->raw_values; int count = 0; - double axis[2]; for(int i = 0; i < raw->valuators.mask_len * 8; ++i) { if (XIMaskIsSet(raw->valuators.mask, i)) { - axis[count++] = *valuator; + if (params.rawMouse) + axis[count++] = *value; + else + axis[count++] = *valuator; + if (count == 2) break; ++valuator; @@ -1282,15 +1279,16 @@ int eventFilter(void * userdata, SDL_Event * event) /* filter out duplicate events */ static Time prev_time = 0; static double prev_axis[2] = {0}; - if (raw->time == prev_time && axis[0] == prev_axis[0] && axis[1] == prev_axis[1]) + if (raw->time == prev_time && + axis[0] == prev_axis[0] && + axis[1] == prev_axis[1]) break; + prev_time = raw->time; prev_axis[0] = axis[0]; prev_axis[1] = axis[1]; - handleMouseRawEvent(axis[0], axis[1]); -#endif } else { diff --git a/client/src/main.h b/client/src/main.h index 250520d1..8b86270f 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -138,6 +138,7 @@ struct AppParams const char * windowTitle; bool mouseRedraw; int mouseSens; + bool rawMouse; }; struct CBRequest