[Mplayer-cvslog] CVS: main/input input.c,1.3,1.4 joystick.c,1.2,1.3 joystick.h,1.2,1.3
Alban Bedel CVS
albeu at mplayer.dev.hu
Mon Feb 4 15:20:17 CET 2002
Update of /cvsroot/mplayer/main/input
In directory mplayer:/var/tmp.root/cvs-serv28012
Modified Files:
input.c joystick.c joystick.h
Log Message:
Fix the bugs the previous version should fix (and those introduced
by the previous version ;) )
Index: input.c
===================================================================
RCS file: /cvsroot/mplayer/main/input/input.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- input.c 3 Feb 2002 19:13:00 -0000 1.3
+++ input.c 4 Feb 2002 14:19:54 -0000 1.4
@@ -76,10 +76,10 @@
{ KEY_DOWN, "DOWN" },
{ KEY_UP, "UP" },
#ifdef HAVE_JOYSTICK
- { JOY_AXIS1_PLUS, "JOY_UP" },
- { JOY_AXIS1_MINUS, "JOY_DOWN" },
- { JOY_AXIS0_PLUS, "JOY_LEFT" },
- { JOY_AXIS0_MINUS, "JOY_RIGHT" },
+ { JOY_AXIS1_MINUS, "JOY_UP" },
+ { JOY_AXIS1_PLUS, "JOY_DOWN" },
+ { JOY_AXIS0_MINUS, "JOY_LEFT" },
+ { JOY_AXIS0_PLUS, "JOY_RIGHT" },
{ JOY_AXIS0_PLUS, "JOY_AXIS0_PLUS" },
{ JOY_AXIS0_MINUS, "JOY_AXIS0_MINUS" },
@@ -817,7 +817,7 @@
if(fd < 0)
printf("Can't init input joystick\n");
else
- mp_input_add_key_fd(fd,1,mp_input_joystick_read,mp_input_joystick_close);
+ mp_input_add_key_fd(fd,1,mp_input_joystick_read,(mp_close_func_t)close);
}
#endif
Index: joystick.c
===================================================================
RCS file: /cvsroot/mplayer/main/input/joystick.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- joystick.c 3 Feb 2002 19:13:00 -0000 1.2
+++ joystick.c 4 Feb 2002 14:19:54 -0000 1.3
@@ -27,14 +27,10 @@
#include <linux/joystick.h>
-static int buttons = 0;
-static int* axis;
-
int mp_input_joystick_init(char* dev) {
int fd,l=0;
int inited = 0;
struct js_event ev;
- char n_axis;
printf("Opening joystick device %s\n",dev ? dev : JS_DEV);
@@ -43,15 +39,6 @@
printf("Can't open joystick device %s : %s\n",dev ? dev : JS_DEV,strerror(errno));
return -1;
}
-
- if(ioctl(fd, JSIOCGAXES, &n_axis) < 0) {
- printf("Joystick : can't get number of axis, %s\n",strerror(errno));
- close(fd);
- return -1;
- }
-
- axis = (int*)malloc(n_axis*sizeof(int));
-
while(! inited) {
l = 0;
@@ -73,16 +60,8 @@
if((unsigned int)l < sizeof(struct js_event)) {
if(l > 0)
printf("Joystick : we loose %d bytes of data\n",l);
- return fd;
+ break;
}
- if(ev.type & JS_EVENT_INIT) {
- ev.type &= ~JS_EVENT_INIT;
- if(ev.type & JS_EVENT_BUTTON)
- buttons |= (ev.value << ev.number);
- else if(ev.type & JS_EVENT_AXIS)
- axis[ev.number] = ev.value;
- } else
- printf("Joystick : Warning non-init event during init :-o\n");
}
return fd;
@@ -115,26 +94,17 @@
}
if(ev.type & JS_EVENT_INIT) {
- printf("Joystick : warning reinit (Can happend more than on time)\n");
- ev.type &= ~JS_EVENT_INIT;
- if(ev.type & JS_EVENT_BUTTON)
- buttons |= (ev.value << ev.number);
- else if(ev.type & JS_EVENT_AXIS)
- axis[ev.number] = ev.value;
- else
- printf("Joystick warning unknow event type %d\n",ev.type);
- return mp_input_joystick_read(fd);
+ printf("Joystick : warning init event, we have lost sync with driver\n");
+ return mp_input_joystick_read(fd);
}
-
- ev.type &= ~JS_EVENT_INIT;
if(ev.type & JS_EVENT_BUTTON) {
- if(ev.value != ( 1 & (buttons >> ev.number)))
+ if(ev.value == 1)
return JOY_BTN0+ev.number;
} else if(ev.type & JS_EVENT_AXIS) {
- if(ev.value - axis[ev.number] > JOY_AXIS_DELTA)
+ if(-ev.value > JOY_AXIS_DELTA)
return JOY_AXIS0_MINUS+(2*ev.number);
- else if(axis[ev.number] - ev.value > JOY_AXIS_DELTA)
+ else if(ev.value > JOY_AXIS_DELTA)
return JOY_AXIS0_PLUS+(2*ev.number);
} else {
printf("Joystick warning unknow event type %d\n",ev.type);
@@ -144,32 +114,6 @@
return MP_INPUT_NOTHING;
}
-void
-mp_input_joystick_close(int fd) {
- struct js_event ev;
- int l=0;
- fd_set fds;
- struct timeval tv;
-
- // Wait to see if there is any stale relaease event in the queue (when we quit we the joystick)
- FD_SET(fd,&fds);
- tv.tv_sec = 0;
- tv.tv_usec = 2000000;
- if(select(fd+1,&fds,NULL,NULL,&tv) > 0) {
- while((unsigned int)l < sizeof(struct js_event)) {
- int r = read(fd,&ev+l,sizeof(struct js_event)-l);
- if(r <= 0) {
- if(errno == EINTR)
- continue;
- else
- break;
- }
- l += r;
- }
- }
- close(fd);
-}
-
#else
// dummy function
@@ -181,11 +125,6 @@
int mp_input_joystick_read(int fd) {
return MP_INPUT_NOTHING;
-}
-
-void
-mp_input_joystick_close(int fd) {
-
}
#endif
Index: joystick.h
===================================================================
RCS file: /cvsroot/mplayer/main/input/joystick.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- joystick.h 3 Feb 2002 19:13:00 -0000 1.2
+++ joystick.h 4 Feb 2002 14:19:54 -0000 1.3
@@ -37,5 +37,3 @@
int mp_input_joystick_read(int fd);
-void
-mp_input_joystick_close(int fd);
More information about the MPlayer-cvslog
mailing list