From c4766dc3c6233d3353b79fbd226202e7b8e3fc46 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 1 Jul 2013 23:54:59 +0200 Subject: input: require VOs to send key up events, redo input key lookup Making key up events implicit was sort-of a nice idea, but it's too tricky and unreliable and makes the key lookup code (interpret_keys()) hard to reason about. See e.g. previous commit for subtle bugs and issues this caused. Make key-up events explicit instead. Add key up events to all VOs. Any time MP_KEY_STATE_DOWN is used, the matching key up event must use MP_KEY_STATE_UP. Rewrite the key lookup code. It should be simpler and more robust now. (Even though the LOC increases, because the new code is less "compact".) --- core/input/joystick.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/input/joystick.c') diff --git a/core/input/joystick.c b/core/input/joystick.c index 17b4279c39..e8330ffaeb 100644 --- a/core/input/joystick.c +++ b/core/input/joystick.c @@ -139,7 +139,7 @@ int mp_input_joystick_read(void *ctx, int fd) { if(ev.value == 1) return (MP_JOY_BTN0 + ev.number) | MP_KEY_STATE_DOWN; else - return MP_JOY_BTN0 + ev.number; + return (MP_JOY_BTN0 + ev.number) | MP_KEY_STATE_UP; } else if(ev.type & JS_EVENT_AXIS) { if(ev.value < -JOY_AXIS_DELTA && axis[ev.number] != -1) { axis[ev.number] = -1; @@ -150,7 +150,7 @@ int mp_input_joystick_read(void *ctx, int fd) { } else if(ev.value <= JOY_AXIS_DELTA && ev.value >= -JOY_AXIS_DELTA && axis[ev.number] != 0) { int r = axis[ev.number] == 1 ? MP_JOY_AXIS0_PLUS+(2*ev.number) : MP_JOY_AXIS0_MINUS+(2*ev.number); axis[ev.number] = 0; - return r; + return r | MP_KEY_STATE_UP; } else return MP_INPUT_NOTHING; } else { -- cgit v1.2.3