summaryrefslogtreecommitdiff
path: root/devel/sdl12
diff options
context:
space:
mode:
authorMaxim Sobolev <sobomax@FreeBSD.org>2003-07-14 18:14:53 +0000
committerMaxim Sobolev <sobomax@FreeBSD.org>2003-07-14 18:14:53 +0000
commit4b11005db5fc9312c455cb273e4af01972bb60ec (patch)
tree46780609b8d0b05d974a8337e61e8f6922f1f7a6 /devel/sdl12
parentFix auto-kill option. (diff)
Add support for /dev/joy? style gameport joystics in addition to USB ones.
PR: 52875 Submitted by: Tony Voet <20030602@hoegisan.com>
Notes
Notes: svn path=/head/; revision=84888
Diffstat (limited to 'devel/sdl12')
-rw-r--r--devel/sdl12/Makefile2
-rw-r--r--devel/sdl12/files/patch-joystick::bsd::SDL_sysjoystick.c114
2 files changed, 108 insertions, 8 deletions
diff --git a/devel/sdl12/Makefile b/devel/sdl12/Makefile
index df89d4a50c01..a9710155b1f3 100644
--- a/devel/sdl12/Makefile
+++ b/devel/sdl12/Makefile
@@ -7,7 +7,7 @@
PORTNAME= sdl
PORTVERSION= 1.2.5
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= devel
MASTER_SITES= http://www.libsdl.org/release/ \
http://www.devolution.com/~slouken/SDL/release/
diff --git a/devel/sdl12/files/patch-joystick::bsd::SDL_sysjoystick.c b/devel/sdl12/files/patch-joystick::bsd::SDL_sysjoystick.c
index ee2ae32df19b..9dd750180e4f 100644
--- a/devel/sdl12/files/patch-joystick::bsd::SDL_sysjoystick.c
+++ b/devel/sdl12/files/patch-joystick::bsd::SDL_sysjoystick.c
@@ -1,17 +1,41 @@
---- src/joystick/bsd/SDL_sysjoystick.c.orig Sat Oct 5 01:32:49 2002
-+++ src/joystick/bsd/SDL_sysjoystick.c Sun Apr 6 23:40:03 2003
-@@ -53,6 +53,10 @@
+
+$FreeBSD$
+
+--- src/joystick/bsd/SDL_sysjoystick.c.orig Sat Oct 5 08:32:49 2002
++++ src/joystick/bsd/SDL_sysjoystick.c Mon Jul 14 21:12:23 2003
+@@ -53,6 +53,11 @@
#include <libusbhid.h>
#endif
+#ifdef __FreeBSD__
+#include <osreldate.h>
++#include <sys/joystick.h>
+#endif
+
#include "SDL_error.h"
#include "SDL_joystick.h"
#include "SDL_sysjoystick.h"
-@@ -201,6 +205,7 @@
+@@ -192,7 +197,18 @@
+ joy->hwdata = hw;
+ hw->fd = fd;
+ hw->path = strdup(path);
+- hw->type = BSDJOY_UHID;
++ if (! strncmp(path, "/dev/joy", 8))
++ {
++ hw->type = BSDJOY_JOY;
++ joy->naxes = 2;
++ joy->nbuttons = 2;
++ joy->nhats = 0;
++ joy->nballs = 0;
++ joydevnames[joy->index] = strdup("Gameport joystick");
++ goto usbend;
++ }
++ else
++ hw->type = BSDJOY_UHID;
+ hw->repdesc = hid_get_report_desc(fd);
+ if (hw->repdesc == NULL) {
+ SDL_SetError("%s: USB_GET_REPORT_DESC: %s", hw->path,
+@@ -201,6 +217,7 @@
}
rep = &hw->inreport;
@@ -19,7 +43,7 @@
if (report_alloc(rep, hw->repdesc, REPORT_INPUT) < 0) {
goto usberr;
}
-@@ -210,7 +215,7 @@
+@@ -210,7 +227,7 @@
goto usberr;
}
@@ -28,7 +52,70 @@
hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid);
#else
hdata = hid_start_parse(hw->repdesc, 1 << hid_input);
-@@ -300,7 +305,7 @@
+@@ -275,6 +292,7 @@
+ }
+ hid_end_parse(hdata);
+
++usbend:
+ /* The poll blocks the event thread. */
+ fcntl(fd, F_SETFL, O_NONBLOCK);
+
+@@ -294,13 +312,62 @@
+ struct report *rep;
+ int nbutton, naxe = -1;
+ Sint32 v;
++ struct joystick gameport;
++ static int x, y, xmin=0xffff, ymin=0xffff, xmax=0, ymax=0;
++
++ if (!strncmp(joy->hwdata->path, "/dev/joy", 8)) {
++ if (read(joy->hwdata->fd, &gameport, sizeof(gameport)) != sizeof(gameport)) {
++ return;
++ }
++ if (abs(x - gameport.x) > 8) {
++ x = gameport.x;
++ if (x < xmin) {
++ xmin = x;
++ }
++ if (x > xmax) {
++ xmax = x;
++ }
++ if (xmin == xmax) {
++ xmin--;
++ xmax++;
++ }
++ v = (Sint32)x;
++ v -= (xmax + xmin + 1)/2;
++ v *= 32768/((xmax - xmin + 1)/2);
++ SDL_PrivateJoystickAxis(joy, 0, v);
++ }
++ if (abs(y - gameport.y) > 8) {
++ y = gameport.y;
++ if (y < ymin) {
++ ymin = y;
++ }
++ if (y > ymax) {
++ ymax = y;
++ }
++ if (ymin == ymax) {
++ ymin--;
++ ymax++;
++ }
++ v = (Sint32)y;
++ v -= (ymax + ymin + 1)/2;
++ v *= 32768/((ymax - ymin + 1)/2);
++ SDL_PrivateJoystickAxis(joy, 1, v);
++ }
++ if (gameport.b1 != joy->buttons[0]) {
++ SDL_PrivateJoystickButton(joy, 0, gameport.b1);
++ }
++ if (gameport.b2 != joy->buttons[1]) {
++ SDL_PrivateJoystickButton(joy, 1, gameport.b2);
++ }
++ return;
++ }
+
+ rep = &joy->hwdata->inreport;
+
if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) {
return;
}
@@ -37,7 +124,20 @@
hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid);
#else
hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input);
-@@ -399,11 +404,24 @@
+@@ -370,8 +437,10 @@
+ void
+ SDL_SYS_JoystickClose(SDL_Joystick *joy)
+ {
+- report_free(&joy->hwdata->inreport);
+- hid_dispose_report_desc(joy->hwdata->repdesc);
++ if (strncmp(joy->hwdata->path, "/dev/joy", 8)) {
++ report_free(&joy->hwdata->inreport);
++ hid_dispose_report_desc(joy->hwdata->repdesc);
++ }
+ close(joy->hwdata->fd);
+ free(joy->hwdata->path);
+ free(joy->hwdata);
+@@ -399,11 +468,24 @@
{
int len;