diff --git a/VERSION b/VERSION
index 7371bb94..046c5181 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-a12-229-g196b27ee9c+1
\ No newline at end of file
+a12-230-gbffd02b8c7+1
\ No newline at end of file
diff --git a/client/README.md b/client/README.md
index b2775870..4decf9cc 100644
--- a/client/README.md
+++ b/client/README.md
@@ -42,10 +42,12 @@ Below are a list of current key bindings:
| Command | Description |
|-|-|
-| ScrLk | Toggle cursor screen capture |
-| ScrLk+F | Full Screen toggle |
-| ScrLk+I | Spice keyboard & mouse enable toggle |
-| ScrLk+N | Toggle night vision mode (EGL renderer only!) |
+| ScrLk | Toggle cursor screen capture |
+| ScrLk+F | Full Screen toggle |
+| ScrLk+I | Spice keyboard & mouse enable toggle |
+| ScrLk+N | Toggle night vision mode (EGL renderer only!) |
+| ScrLk+Insert | Increase mouse sensitivity (in caputre mode only) |
+| ScrLk+Del | Decrease mouse sensitivity (in caputre mode only) |
### Setting options via command line arguments
@@ -109,6 +111,7 @@ Command line arguments will override any options loaded from the config files.
| input:grabKeyboard | -G | yes | Grab the keyboard in capture mode |
| input:escapeKey | -m | 71 = ScrollLock | Specify the escape key, see https://wiki.libsdl.org/SDLScancodeLookup for valid values |
| input:hideCursor | -M | yes | Hide the local mouse cursor |
+| input:mouseSens | | 0 | Initial mouse sensitivity when in caputre mode (-9 to 9) |
|---------------------------------------------------------------------------------------------------------------------------------------|
|------------------------------------------------------------------------------------------------------------------|
diff --git a/client/src/config.c b/client/src/config.c
index e771357e..98d92a6f 100644
--- a/client/src/config.c
+++ b/client/src/config.c
@@ -234,6 +234,13 @@ static struct Option options[] =
.type = OPTION_TYPE_BOOL,
.value.x_bool = true,
},
+ {
+ .module = "input",
+ .name = "mouseSens",
+ .description = "Initial mouse sensitivity when in caputre mode (-9 to 9)",
+ .type = OPTION_TYPE_INT,
+ .value.x_int = 0,
+ },
// spice options
{
@@ -378,6 +385,7 @@ bool config_load(int argc, char * argv[])
params.grabKeyboard = option_get_bool ("input", "grabKeyboard");
params.escapeKey = option_get_int ("input", "escapeKey" );
params.hideMouse = option_get_bool ("input", "hideCursor" );
+ params.mouseSens = option_get_int ("input", "mouseSens" );
if (option_get_bool("spice", "enable"))
{
diff --git a/client/src/main.c b/client/src/main.c
index 8ba684bc..e977ef11 100644
--- a/client/src/main.c
+++ b/client/src/main.c
@@ -38,6 +38,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include "common/debug.h"
#include "common/crash.h"
#include "common/KVMFR.h"
+#include "common/stringutils.h"
#include "utils.h"
#include "kb.h"
#include "ll.h"
@@ -643,8 +644,10 @@ int eventFilter(void * userdata, SDL_Event * event)
x -= state.cursor.x;
y -= state.cursor.y;
realignGuest = false;
- state.accX = 0;
- state.accY = 0;
+ state.accX = 0;
+ state.accY = 0;
+ state.sensX = 0;
+ state.sensY = 0;
if (!spice_mouse_motion(x, y))
DEBUG_ERROR("SDL_MOUSEMOTION: failed to send message");
@@ -665,6 +668,16 @@ int eventFilter(void * userdata, SDL_Event * event)
state.accY -= y;
}
+ if (serverMode && state.mouseSens != 0)
+ {
+ state.sensX += ((float)x / 10.0f) * (state.mouseSens + 10);
+ state.sensY += ((float)y / 10.0f) * (state.mouseSens + 10);
+ x = floor(state.sensX);
+ y = floor(state.sensY);
+ state.sensX -= x;
+ state.sensY -= y;
+ }
+
if (!spice_mouse_motion(x, y))
{
DEBUG_ERROR("SDL_MOUSEMOTION: failed to send message");
@@ -902,10 +915,41 @@ static void toggle_input(SDL_Scancode key, void * opaque)
);
}
+static void mouse_sens_inc(SDL_Scancode key, void * opaque)
+{
+ char * msg;
+ if (state.mouseSens < 9)
+ ++state.mouseSens;
+
+ alloc_sprintf(&msg, "Sensitivity: %d", state.mouseSens);
+ app_alert(
+ LG_ALERT_INFO,
+ msg
+ );
+ free(msg);
+}
+
+static void mouse_sens_dec(SDL_Scancode key, void * opaque)
+{
+ char * msg;
+
+ if (state.mouseSens > -9)
+ --state.mouseSens;
+
+ alloc_sprintf(&msg, "Sensitivity: %d", state.mouseSens);
+ app_alert(
+ LG_ALERT_INFO,
+ msg
+ );
+ free(msg);
+}
+
static void register_key_binds()
{
- state.kbFS = app_register_keybind(SDL_SCANCODE_F, toggle_fullscreen, NULL);
- state.kbInput = app_register_keybind(SDL_SCANCODE_I, toggle_input , NULL);
+ state.kbFS = app_register_keybind(SDL_SCANCODE_F , toggle_fullscreen, NULL);
+ state.kbInput = app_register_keybind(SDL_SCANCODE_I , toggle_input , NULL);
+ state.kbMouseSensInc = app_register_keybind(SDL_SCANCODE_INSERT, mouse_sens_inc , NULL);
+ state.kbMouseSensDec = app_register_keybind(SDL_SCANCODE_DELETE, mouse_sens_dec , NULL);
}
static void release_key_binds()
@@ -925,6 +969,10 @@ int run()
state.scaleY = 1.0f;
state.frameTime = 1e9 / params.fpsLimit;
+ state.mouseSens = params.mouseSens;
+ if (state.mouseSens < -9) state.mouseSens = -9;
+ else if (state.mouseSens > 9) state.mouseSens = 9;
+
char* XDG_SESSION_TYPE = getenv("XDG_SESSION_TYPE");
if (XDG_SESSION_TYPE == NULL)
@@ -1282,9 +1330,7 @@ int main(int argc, char * argv[])
return -1;
if (params.grabKeyboard)
- {
SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, "1");
- }
const int ret = run();
release_key_binds();
diff --git a/client/src/main.h b/client/src/main.h
index f908c0c0..9cf5e7ff 100644
--- a/client/src/main.h
+++ b/client/src/main.h
@@ -66,6 +66,11 @@ struct AppState
KeybindHandle kbFS;
KeybindHandle kbInput;
+ KeybindHandle kbMouseSensInc;
+ KeybindHandle kbMouseSensDec;
+
+ int mouseSens;
+ float sensX, sensY;
};
struct AppParams
@@ -103,6 +108,7 @@ struct AppParams
unsigned int forceRendererIndex;
const char * windowTitle;
+ int mouseSens;
};
struct CBRequest