mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 14:57:20 +00:00
[client] main: new feature to increase/decrease mouse sensitivity
This commit is contained in:
parent
bffd02b8c7
commit
437ebf6265
@ -46,6 +46,8 @@ Below are a list of current key bindings:
|
|||||||
| <kbd>ScrLk</kbd>+<kbd>F</kbd> | Full Screen toggle |
|
| <kbd>ScrLk</kbd>+<kbd>F</kbd> | Full Screen toggle |
|
||||||
| <kbd>ScrLk</kbd>+<kbd>I</kbd> | Spice keyboard & mouse enable toggle |
|
| <kbd>ScrLk</kbd>+<kbd>I</kbd> | Spice keyboard & mouse enable toggle |
|
||||||
| <kbd>ScrLk</kbd>+<kbd>N</kbd> | Toggle night vision mode (EGL renderer only!) |
|
| <kbd>ScrLk</kbd>+<kbd>N</kbd> | Toggle night vision mode (EGL renderer only!) |
|
||||||
|
| <kbd>ScrLk</kbd>+<kbd>Insert</kbd> | Increase mouse sensitivity (in caputre mode only) |
|
||||||
|
| <kbd>ScrLk</kbd>+<kbd>Del</kbd> | Decrease mouse sensitivity (in caputre mode only) |
|
||||||
|
|
||||||
### Setting options via command line arguments
|
### 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: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: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:hideCursor | -M | yes | Hide the local mouse cursor |
|
||||||
|
| input:mouseSens | | 0 | Initial mouse sensitivity when in caputre mode (-9 to 9) |
|
||||||
|---------------------------------------------------------------------------------------------------------------------------------------|
|
|---------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
|
|
||||||
|------------------------------------------------------------------------------------------------------------------|
|
|------------------------------------------------------------------------------------------------------------------|
|
||||||
|
@ -234,6 +234,13 @@ static struct Option options[] =
|
|||||||
.type = OPTION_TYPE_BOOL,
|
.type = OPTION_TYPE_BOOL,
|
||||||
.value.x_bool = true,
|
.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
|
// spice options
|
||||||
{
|
{
|
||||||
@ -378,6 +385,7 @@ bool config_load(int argc, char * argv[])
|
|||||||
params.grabKeyboard = option_get_bool ("input", "grabKeyboard");
|
params.grabKeyboard = option_get_bool ("input", "grabKeyboard");
|
||||||
params.escapeKey = option_get_int ("input", "escapeKey" );
|
params.escapeKey = option_get_int ("input", "escapeKey" );
|
||||||
params.hideMouse = option_get_bool ("input", "hideCursor" );
|
params.hideMouse = option_get_bool ("input", "hideCursor" );
|
||||||
|
params.mouseSens = option_get_int ("input", "mouseSens" );
|
||||||
|
|
||||||
if (option_get_bool("spice", "enable"))
|
if (option_get_bool("spice", "enable"))
|
||||||
{
|
{
|
||||||
|
@ -38,6 +38,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
#include "common/crash.h"
|
#include "common/crash.h"
|
||||||
#include "common/KVMFR.h"
|
#include "common/KVMFR.h"
|
||||||
|
#include "common/stringutils.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "kb.h"
|
#include "kb.h"
|
||||||
#include "ll.h"
|
#include "ll.h"
|
||||||
@ -645,6 +646,8 @@ int eventFilter(void * userdata, SDL_Event * event)
|
|||||||
realignGuest = false;
|
realignGuest = false;
|
||||||
state.accX = 0;
|
state.accX = 0;
|
||||||
state.accY = 0;
|
state.accY = 0;
|
||||||
|
state.sensX = 0;
|
||||||
|
state.sensY = 0;
|
||||||
|
|
||||||
if (!spice_mouse_motion(x, y))
|
if (!spice_mouse_motion(x, y))
|
||||||
DEBUG_ERROR("SDL_MOUSEMOTION: failed to send message");
|
DEBUG_ERROR("SDL_MOUSEMOTION: failed to send message");
|
||||||
@ -665,6 +668,16 @@ int eventFilter(void * userdata, SDL_Event * event)
|
|||||||
state.accY -= y;
|
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))
|
if (!spice_mouse_motion(x, y))
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("SDL_MOUSEMOTION: failed to send message");
|
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()
|
static void register_key_binds()
|
||||||
{
|
{
|
||||||
state.kbFS = app_register_keybind(SDL_SCANCODE_F, toggle_fullscreen, NULL);
|
state.kbFS = app_register_keybind(SDL_SCANCODE_F , toggle_fullscreen, NULL);
|
||||||
state.kbInput = app_register_keybind(SDL_SCANCODE_I, toggle_input , 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()
|
static void release_key_binds()
|
||||||
@ -925,6 +969,10 @@ int run()
|
|||||||
state.scaleY = 1.0f;
|
state.scaleY = 1.0f;
|
||||||
state.frameTime = 1e9 / params.fpsLimit;
|
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");
|
char* XDG_SESSION_TYPE = getenv("XDG_SESSION_TYPE");
|
||||||
|
|
||||||
if (XDG_SESSION_TYPE == NULL)
|
if (XDG_SESSION_TYPE == NULL)
|
||||||
@ -1282,9 +1330,7 @@ int main(int argc, char * argv[])
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (params.grabKeyboard)
|
if (params.grabKeyboard)
|
||||||
{
|
|
||||||
SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, "1");
|
SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, "1");
|
||||||
}
|
|
||||||
|
|
||||||
const int ret = run();
|
const int ret = run();
|
||||||
release_key_binds();
|
release_key_binds();
|
||||||
|
@ -66,6 +66,11 @@ struct AppState
|
|||||||
|
|
||||||
KeybindHandle kbFS;
|
KeybindHandle kbFS;
|
||||||
KeybindHandle kbInput;
|
KeybindHandle kbInput;
|
||||||
|
KeybindHandle kbMouseSensInc;
|
||||||
|
KeybindHandle kbMouseSensDec;
|
||||||
|
|
||||||
|
int mouseSens;
|
||||||
|
float sensX, sensY;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AppParams
|
struct AppParams
|
||||||
@ -103,6 +108,7 @@ struct AppParams
|
|||||||
unsigned int forceRendererIndex;
|
unsigned int forceRendererIndex;
|
||||||
|
|
||||||
const char * windowTitle;
|
const char * windowTitle;
|
||||||
|
int mouseSens;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CBRequest
|
struct CBRequest
|
||||||
|
Loading…
Reference in New Issue
Block a user