diff options
author | hondres <liu.gam3@gmail.com> | 2016-01-03 02:24:43 +0100 |
---|---|---|
committer | hondres <liu.gam3@gmail.com> | 2016-01-03 02:24:43 +0100 |
commit | 17d664cf1d88244e8a7179c07b52b9d7fcd9b1bc (patch) | |
tree | ab69c45d4030bb05ae7b1738bb5b6478be5c3273 /platform/x11 | |
parent | eca92bb7acd9ff70957ca2f42bb41f2240d13bf3 (diff) |
send axis events only once per frame on linux
Diffstat (limited to 'platform/x11')
-rw-r--r-- | platform/x11/joystick_linux.cpp | 13 | ||||
-rw-r--r-- | platform/x11/joystick_linux.h | 1 |
2 files changed, 13 insertions, 1 deletions
diff --git a/platform/x11/joystick_linux.cpp b/platform/x11/joystick_linux.cpp index 050fdac2b8..6eb3671bc0 100644 --- a/platform/x11/joystick_linux.cpp +++ b/platform/x11/joystick_linux.cpp @@ -52,8 +52,13 @@ joystick_linux::Joystick::Joystick() { void joystick_linux::Joystick::reset() { dpad = 0; fd = -1; + + InputDefault::JoyAxis jx; + jx.min = -1; + jx.value = 0.0f; for (int i=0; i < MAX_ABS; i++) { abs_map[i] = -1; + curr_axis[i] = jx; } } @@ -390,7 +395,7 @@ uint32_t joystick_linux::process_joysticks(uint32_t p_event_id) { default: if (joy->abs_map[ev.code] != -1) { InputDefault::JoyAxis value = axis_correct(libevdev_get_abs_info(dev, ev.code), ev.value); - p_event_id = input->joy_axis(p_event_id, i, joy->abs_map[ev.code], value); + joy->curr_axis[joy->abs_map[ev.code]] = value; } break; } @@ -398,6 +403,12 @@ uint32_t joystick_linux::process_joysticks(uint32_t p_event_id) { } rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev); } + for (int j = 0; j < MAX_ABS; j++) { + int index = joy->abs_map[j]; + if (index != -1) { + p_event_id = input->joy_axis(p_event_id, i, index, joy->curr_axis[index]); + } + } } joy_mutex->unlock(); return p_event_id; diff --git a/platform/x11/joystick_linux.h b/platform/x11/joystick_linux.h index 9d22a6c754..ee9bd0352a 100644 --- a/platform/x11/joystick_linux.h +++ b/platform/x11/joystick_linux.h @@ -54,6 +54,7 @@ private: }; struct Joystick { + InputDefault::JoyAxis curr_axis[MAX_ABS]; int key_map[MAX_KEY - BT_MISC]; int abs_map[MAX_ABS]; int dpad; |