Merge pull request #3210 from Hinsbart/x11_axis_fix

send axis events only once per frame on linux
This commit is contained in:
punto- 2016-01-02 23:06:54 -03:00
commit b9d5763b02
2 changed files with 13 additions and 1 deletions

View file

@ -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;

View file

@ -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;