[MPlayer-dev-eng] [PATCH] joystick double events and keydown/keyup for axes
Mark Pustjens
pustjens at dds.nl
Fri Jan 14 14:24:50 CET 2005
On Fri, 14 Jan 2005, Ivo wrote:
> On Friday 14 January 2005 14:04, Mark Pustjens wrote:
>> I have attached the patch to this message.
>
> No, you haven't :-)
How stupid of me...
Have i now?
>
> --Ivo
>
> _______________________________________________
> MPlayer-dev-eng mailing list
> MPlayer-dev-eng at mplayerhq.hu
> http://mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
>
-------------- next part --------------
diff -Naur main.org/input/input.c main.new/input/input.c
--- main.org/input/input.c Mon Jan 3 14:56:48 2005
+++ main.new/input/input.c Fri Jan 14 13:57:59 2005
@@ -236,6 +236,8 @@
{ JOY_BTN7, "JOY_BTN7" },
{ JOY_BTN8, "JOY_BTN8" },
{ JOY_BTN9, "JOY_BTN9" },
+ { JOY_BTN10, "JOY_BTN10" },
+ { JOY_BTN11, "JOY_BTN11" },
{ KEY_XF86_PAUSE, "XF86_PAUSE" },
{ KEY_XF86_STOP, "XF86_STOP" },
@@ -1002,9 +1004,20 @@
num_key_down++;
last_key_down = 1;
}
- // We ignore key from last combination
- ret = last_key_down ? mp_input_get_cmd_from_keys(num_key_down,key_down,paused) : NULL;
- // Remove the key
+
+#ifdef HAVE_JOYSTICK
+ // ``normal'' input devices only send keydown events OR keyup events. the joystick
+ // routines send both. this check makes sure only key bindings for
+ // keydown events are executed.
+ if (!use_joystick || !(code >= JOY_AXIS0_PLUS && code <= JOY_AXIS9_MINUS)){
+#endif
+ // We ignore key from last combination
+ ret = last_key_down ? mp_input_get_cmd_from_keys(num_key_down,key_down,paused) : NULL;
+ // Remove the key
+#ifdef HAVE_JOYSTICK
+ }
+#endif
+
if(j+1 < num_key_down)
memmove(&key_down[j],&key_down[j+1],(num_key_down-(j+1))*sizeof(int));
num_key_down--;
diff -Naur main.org/input/joystick.c main.new/input/joystick.c
--- main.org/input/joystick.c Wed Jul 9 03:30:22 2003
+++ main.new/input/joystick.c Fri Jan 14 13:57:24 2005
@@ -15,8 +15,12 @@
#include <fcntl.h>
#include <errno.h>
-#ifndef JOY_AXIS_DELTA
-#define JOY_AXIS_DELTA 500
+#ifndef JOY_AXIS_KEYDOWN
+#define JOY_AXIS_KEYDOWN 30000
+#endif
+
+#ifndef JOY_AXIS_KEYUP
+#define JOY_AXIS_KEYUP 10000
#endif
#ifndef JS_DEV
@@ -108,14 +112,15 @@
int s = (btns >> ev.number) & 1;
if(s == ev.value) // State is the same : ignore
return MP_INPUT_NOTHING;
- }
- if(ev.type == JS_EVENT_AXIS) {
- if( ( axis[ev.number] == 1 && ev.value > JOY_AXIS_DELTA) ||
- (axis[ev.number] == -1 && ev.value < -JOY_AXIS_DELTA) ||
- (axis[ev.number] == 0 && ev.value >= -JOY_AXIS_DELTA && ev.value <= JOY_AXIS_DELTA)
+ } else if (ev.type == JS_EVENT_AXIS) {
+ if( ( axis[ev.number] == 1 && ev.value > JOY_AXIS_KEYUP) ||
+ (axis[ev.number] == -1 && ev.value < -JOY_AXIS_KEYUP) ||
+ (axis[ev.number] == 0 && ev.value >= -JOY_AXIS_KEYDOWN && ev.value <= JOY_AXIS_KEYDOWN)
) // State is the same : ignore
return MP_INPUT_NOTHING;
- }
+ } else {
+ printf("Joystick warning unknown event type %d\n",ev.type);
+ }
}
if(ev.type & JS_EVENT_BUTTON) {
@@ -126,13 +131,13 @@
else
return (JOY_BTN0+ev.number);
} else if(ev.type & JS_EVENT_AXIS) {
- if(ev.value < -JOY_AXIS_DELTA && axis[ev.number] != -1) {
+ if(ev.value < -JOY_AXIS_KEYDOWN && axis[ev.number] != -1) {
axis[ev.number] = -1;
return (JOY_AXIS0_MINUS+(2*ev.number)) | MP_KEY_DOWN;
- } else if(ev.value > JOY_AXIS_DELTA && axis[ev.number] != 1) {
+ } else if(ev.value > JOY_AXIS_KEYDOWN && axis[ev.number] != 1) {
axis[ev.number] = 1;
return (JOY_AXIS0_PLUS+(2*ev.number)) | MP_KEY_DOWN;
- } else if(ev.value <= JOY_AXIS_DELTA && ev.value >= -JOY_AXIS_DELTA && axis[ev.number] != 0) {
+ } else if(ev.value <= JOY_AXIS_KEYUP && ev.value >= -JOY_AXIS_KEYUP && axis[ev.number] != 0) {
int r = axis[ev.number] == 1 ? JOY_AXIS0_PLUS+(2*ev.number) : JOY_AXIS0_MINUS+(2*ev.number);
axis[ev.number] = 0;
return r;
diff -Naur main.org/input/joystick.h main.new/input/joystick.h
--- main.org/input/joystick.h Mon Feb 11 12:42:08 2002
+++ main.new/input/joystick.h Fri Jan 14 13:35:14 2005
@@ -32,6 +32,8 @@
#define JOY_BTN7 (JOY_BTN_BASE+7)
#define JOY_BTN8 (JOY_BTN_BASE+8)
#define JOY_BTN9 (JOY_BTN_BASE+9)
+#define JOY_BTN10 (JOY_BTN_BASE+10)
+#define JOY_BTN11 (JOY_BTN_BASE+11)
int mp_input_joystick_init(char* dev);
More information about the MPlayer-dev-eng
mailing list