--- src/linux/rw_x11.c.orig Wed Oct 9 03:54:25 2002 +++ src/linux/rw_x11.c Mon Jun 16 23:19:40 2003 @@ -53,7 +53,7 @@ #include #include #include -#include +#include #ifdef OPENGL #include #endif @@ -151,7 +151,7 @@ int config_notify_height; typedef unsigned short PIXEL16; -typedef unsigned long PIXEL24; +typedef unsigned int PIXEL24; #ifdef REDBLUE static PIXEL16 st2d_8to16table_s[2][256]; static PIXEL24 st2d_8to24table_s[2][256]; @@ -446,7 +446,7 @@ qboolean OpenJoystick(cvar_t *joy_dev) { int i, err; glob_t pglob; - struct js_event e; + struct joystick j; err = glob(joy_dev->string, 0, NULL, &pglob); @@ -461,7 +461,7 @@ default: ri.Con_Printf(PRINT_ALL, "Error #%d while looking for joysticks\n",err); } - return false; + goto out; } for (i=0;iKey_Event_fp (K_MWHEELUP, 1); else if (event.xbutton.button == 5) in_state->Key_Event_fp (K_MWHEELDOWN, 1); + else if (event.xbutton.button == 6) + in_state->Key_Event_fp (K_MOUSE4, 1); + else if (event.xbutton.button == 7) + in_state->Key_Event_fp (K_MOUSE5, 1); if (b>=0) mouse_buttonstate |= 1<Key_Event_fp (K_MWHEELUP, 0); else if (event.xbutton.button == 5) in_state->Key_Event_fp (K_MWHEELDOWN, 0); + else if (event.xbutton.button == 6) + in_state->Key_Event_fp (K_MOUSE4, 0); + else if (event.xbutton.button == 7) + in_state->Key_Event_fp (K_MOUSE5, 0); if (b>=0) mouse_buttonstate &= ~(1<Key_Event_fp (key_index + e.number, true); - } - else { - in_state->Key_Event_fp (key_index + e.number, false); - } - } - else if (JS_EVENT_AXIS & e.type) { - axis_vals[axis_map[e.number]] = e.value; - } + + /* + * FreeBSD does not fully support multi-buttoned joysticks. + */ + if (read(joy_fd, &j, sizeof(struct joystick)) != -1) { + if (j.b1) + in_state->Key_Event_fp (K_JOY1, true); + else + in_state->Key_Event_fp (K_JOY1, false); + if (j.b2) + in_state->Key_Event_fp (K_JOY2, true); + else + in_state->Key_Event_fp (K_JOY2, false); + axis_vals[axis_map[0]] = j.x; + axis_vals[axis_map[1]] = j.y; } } #endif