Patch to fix the Linux 2.2 joysitck interface
David Hagood
wowbagger at sktc.net
Wed Jul 25 21:47:34 CDT 2001
The attached patch fixes a problem in Wine's use of the Linux V2.2
joystick API.
The problem is that the current implemtation closes the joystick file
(/dev/js[0-n]) after every operation. This resets the device, so that
the next time you open the device, you get nothing from it.
I've added a value in the private joystick structure to track the Linux
file descriptor, and modified the open function to see if the file is
already opened, and if so just return that file. I've also removed the
close's of the device (save on error conditions.)
I've tested this with HalfLife, and it will read the stick and allow me
to bind my stick to my favorite options.
To be done: the file descriptor is never closed under normal
circumstances - this might be a problem if a Wine app is opened and
accesses the stick, as the file descriptor will be open until that
process terminates. If this is viewed as a problem, it would be a simple
matter to add a device close function to the Wine driver to close the FD.
I've not tested this under anything other than Linux kernel V2.4.6. I
don't know if it will break *BSD, but I don't think so.
-------------- next part --------------
Index: dlls/winmm/joystick/joystick.c
===================================================================
RCS file: /home/wine/wine/dlls/winmm/joystick/joystick.c,v
retrieving revision 1.9
diff -r1.9 joystick.c
55a56
> int fd;
66d66
<
116a117,119
> if (jstick->fd > 0) /* already opened this? */
> return jstick->fd;
>
123c126
< return open(buf, flags);
---
> return jstick->fd = open(buf, flags);
188d190
< close(dev);
244c246
< if (ev.type == (JS_EVENT_AXIS | JS_EVENT_INIT)) {
---
> if (ev.type & JS_EVENT_AXIS) {
271c273,274
< } else if (ev.type == (JS_EVENT_BUTTON | JS_EVENT_INIT)) {
---
> }
> if (ev.type & JS_EVENT_BUTTON) {
291a295
> jstk->fd = -1; /* mark file descriptor as closed */
303,304d306
<
< close(dev);
More information about the wine-patches
mailing list