From d24aeec518240f4916b4c8e9f4f81a4aacd5b370 Mon Sep 17 00:00:00 2001 From: sorgelig Date: Tue, 23 Jan 2018 05:04:36 +0800 Subject: [PATCH] Implement mouse throttle. --- input.c | 21 +++++++++++++++++---- mist_cfg.c | 1 + mist_cfg.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/input.c b/input.c index 41010e2..c449acf 100644 --- a/input.c +++ b/input.c @@ -1131,6 +1131,8 @@ typedef struct char has_kbdmap; uint8_t kbdmap[256]; + + int accx, accy; } devInput; static devInput input[NUMDEV] = { 0 }; @@ -1575,15 +1577,26 @@ static void input_cb(struct input_event *ev, int dev) case EV_REL: { + int msval; + if (!mist_cfg.mouse_throttle) mist_cfg.mouse_throttle = 1; + switch (ev->code) { case 0: - //printf("Mouse PosX: %d\n", ev->value); - user_io_mouse(mouse_btn, ev->value, 0); + input[dev].accx += ev->value; + msval = input[dev].accx / mist_cfg.mouse_throttle; + input[dev].accx -= msval * mist_cfg.mouse_throttle; + + //printf("Mouse PosX: %d\n", msval); + user_io_mouse(mouse_btn, msval, 0); return; case 1: - //printf("Mouse PosY: %d\n", ev->value); - user_io_mouse(mouse_btn, 0, ev->value); + input[dev].accy += ev->value; + msval = input[dev].accy / mist_cfg.mouse_throttle; + input[dev].accy -= msval * mist_cfg.mouse_throttle; + + //printf("Mouse PosY: %d\n", msval); + user_io_mouse(mouse_btn, 0, msval); return; } } diff --git a/mist_cfg.c b/mist_cfg.c index ad5933a..7b0b5be 100644 --- a/mist_cfg.c +++ b/mist_cfg.c @@ -34,6 +34,7 @@ const ini_var_t mist_ini_vars[] = { { "HDMI_AUDIO_96K", (void*)(&(mist_cfg.hdmi_audio_96k)), UINT8, 0, 1, 1 }, { "DVI_MODE", (void*)(&(mist_cfg.dvi)), UINT8, 0, 1, 1 }, { "KBD_NOMOUSE", (void*)(&(mist_cfg.kbd_nomouse)), UINT8, 0, 1, 1 }, + { "MOUSE_THROTTLE", (void*)(&(mist_cfg.mouse_throttle)), UINT8, 1, 100, 1 }, }; // mist ini config diff --git a/mist_cfg.h b/mist_cfg.h index 706ebbb..2db7aba 100644 --- a/mist_cfg.h +++ b/mist_cfg.h @@ -24,6 +24,7 @@ typedef struct { uint8_t dvi; uint8_t video_mode; uint8_t kbd_nomouse; + uint8_t mouse_throttle; char video_conf[1024]; } mist_cfg_t;