diff options
author | Sascha Hlusiak <saschahlusiak@arcor.de> | 2007-04-12 18:12:29 -0400 |
---|---|---|
committer | Sascha Hlusiak <saschahlusiak@arcor.de> | 2007-04-12 18:12:29 -0400 |
commit | 886e418b89ac673df3e4be0f7a4b1b8c648cad80 (patch) | |
tree | fbf03cd53d754dec075ceb8f4f7897938ddeeff8 | |
parent | fa32161bc5b63baa22b78f25ec6daa4f8e53aa7a (diff) |
Wrapped enums and structs in typedefs
Removed xisb.h include, since we are not going to need it.
-rw-r--r-- | src/bsd_jstk.c | 19 | ||||
-rw-r--r-- | src/jstk.c | 11 | ||||
-rw-r--r-- | src/jstk.h | 101 | ||||
-rw-r--r-- | src/jstk_axis.c | 11 | ||||
-rw-r--r-- | src/jstk_hw.h | 7 | ||||
-rw-r--r-- | src/jstk_options.c | 15 | ||||
-rw-r--r-- | src/jstk_options.h | 2 | ||||
-rw-r--r-- | src/linux_jstk.c | 2 |
8 files changed, 88 insertions, 80 deletions
diff --git a/src/bsd_jstk.c b/src/bsd_jstk.c index b1d0602..0454528 100644 --- a/src/bsd_jstk.c +++ b/src/bsd_jstk.c @@ -49,14 +49,14 @@ struct jstk_bsd_hid_data { - int dlen; /* Length of one data chunk */ - char *data_buf; /* Data buffer with right size */ - struct hid_item axis_item[MAXAXES]; /* Axis HID items */ - struct hid_item button_item[MAXBUTTONS]; /* Button HID items */ - struct hid_item hat_item[MAXAXES]; /* HID items for hats */ - int hats; /* Number of hats */ - int hotdata; /* Is unprocessed data available - in data_buf? */ + int dlen; /* Length of one data chunk */ + char *data_buf; /* Data buffer with right size */ + struct hid_item axis_item[MAXAXES]; /* Axis HID items */ + struct hid_item button_item[MAXBUTTONS]; /* Button HID items */ + struct hid_item hat_item[MAXAXES]; /* HID items for hats */ + int hats; /* Number of hats */ + int hotdata; /* Is unprocessed data available + in data_buf? */ }; @@ -230,7 +230,7 @@ jstkCloseDevice(JoystickDevPtr joystick) int jstkReadData(JoystickDevPtr joystick, - enum JOYSTICKEVENT *event, + JOYSTICKEVENT *event, int *number) { int j,d; @@ -253,6 +253,7 @@ jstkReadData(JoystickDevPtr joystick, for (j=0; j<joystick->axes - (bsddata->hats * 2); j++) { d = hid_get_data(bsddata->data_buf, &bsddata->axis_item[j]); + /* Scale the range to our expected range of -32768 to 32767 */ d = d - (bsddata->axis_item[j].logical_maximum - bsddata->axis_item[j].logical_minimum) / 2; d = d * 65536 / (bsddata->axis_item[j].logical_maximum @@ -6,15 +6,15 @@ * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Sascha Hlusiak not be used in + * documentation, and that the names of copyright holders not be used in * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Sascha Hlusiak makes no + * specific, written prior permission. The copyright holders make no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * - * SASCHA HLUSIAK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL SASCHA HLUSIAK BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR @@ -32,7 +32,6 @@ #include <misc.h> #include <xf86.h> #include <xf86Xinput.h> -#include <xisb.h> #include <exevents.h> /* Needed for InitValuator/Proximity stuff */ #include <math.h> @@ -100,7 +99,7 @@ jstkConvertProc(LocalDevicePtr local, static void jstkReadProc(LocalDevicePtr local) { - enum JOYSTICKEVENT event; + JOYSTICKEVENT event; int number; int i; int r; @@ -56,66 +56,63 @@ extern int debug_level; #define MAXAXES 32 #define MAXKEYSPERBUTTON 4 -enum JOYSTICKTYPE { - TYPE_NONE, - TYPE_BYVALUE, /* Speed of cursor is relative to amplitude */ - TYPE_ACCELERATED, /* Speed is accelerated */ - TYPE_ABSOLUTE /* The amplitude defines the cursor position */ -}; - -enum JOYSTICKMAPPING { - MAPPING_NONE=0, - MAPPING_X, - MAPPING_Y, - MAPPING_ZX, - MAPPING_ZY, - MAPPING_BUTTON, - MAPPING_KEY, - MAPPING_SPEED_MULTIPLY, - MAPPING_DISABLE, - MAPPING_DISABLE_MOUSE, - MAPPING_DISABLE_KEYS -}; - -enum JOYSTICKEVENT { - EVENT_NONE=0, - EVENT_BUTTON, - EVENT_AXIS -}; +typedef enum { + TYPE_NONE, + TYPE_BYVALUE, /* Speed of cursor is relative to amplitude */ + TYPE_ACCELERATED, /* Speed is accelerated */ + TYPE_ABSOLUTE /* The amplitude defines the cursor position */ +} JOYSTICKTYPE; + +typedef enum { + MAPPING_NONE=0, + MAPPING_X, + MAPPING_Y, + MAPPING_ZX, + MAPPING_ZY, + MAPPING_BUTTON, + MAPPING_KEY, + MAPPING_SPEED_MULTIPLY, + MAPPING_DISABLE, + MAPPING_DISABLE_MOUSE, + MAPPING_DISABLE_KEYS +} JOYSTICKMAPPING ; +typedef struct +{ + int value; + int deadzone; + float temp,amplify; + JOYSTICKTYPE type; + JOYSTICKMAPPING mapping; +} AXIS; + +typedef struct +{ + char pressed; + int value; + unsigned int keys[MAXKEYSPERBUTTON]; + float temp; + JOYSTICKMAPPING mapping; +} BUTTON; + typedef struct { - int fd; /* Actual file descriptor */ - void *devicedata; /* Extra platform device dependend data */ - char *device; /* Name of the device */ + int fd; /* Actual file descriptor */ + void *devicedata; /* Extra platform device dependend data */ + char *device; /* Name of the device */ - OsTimerPtr timer; - Bool timerrunning; - float x,y,zx,zy; /* Pending subpixel movements */ + OsTimerPtr timer; + Bool timerrunning; + float x,y,zx,zy; /* Pending subpixel movements */ - Bool mouse_enabled, keys_enabled; - float amplify; /* Global amplifier of axis movement */ + Bool mouse_enabled, keys_enabled; + float amplify; /* Global amplifier of axis movement */ - struct AXIS - { - int value; - int deadzone; - float temp,amplify; - enum JOYSTICKTYPE type; - enum JOYSTICKMAPPING mapping; - }axis[MAXAXES]; /* Configuration per axis */ - - struct BUTTON - { - char pressed; - int value; - unsigned int keys[MAXKEYSPERBUTTON]; - float temp; - enum JOYSTICKMAPPING mapping; - }button[MAXBUTTONS]; /* Configuration per button */ - unsigned char axes, buttons; /* Number of axes and buttons */ + AXIS axis[MAXAXES]; /* Configuration per axis */ + BUTTON button[MAXBUTTONS]; /* Configuration per button */ + unsigned char axes, buttons; /* Number of axes and buttons */ } JoystickDevRec, *JoystickDevPtr; diff --git a/src/jstk_axis.c b/src/jstk_axis.c index 5969f0b..95a1894 100644 --- a/src/jstk_axis.c +++ b/src/jstk_axis.c @@ -68,7 +68,7 @@ jstkAxisTimer(OsTimerPtr timer, float p1 = 0.0f; /* Pixels to move cursor */ float p2 = 0.0f; /* Pixels to scroll */ float scale; - struct AXIS *axis; + AXIS *axis; axis = &priv->axis[i]; nexttimer = NEXTTIMER; @@ -207,7 +207,8 @@ jstkAxisTimer(OsTimerPtr timer, *********************************************************************** */ void -jstkStartAxisTimer(LocalDevicePtr device, int number) { +jstkStartAxisTimer(LocalDevicePtr device, int number) +{ int pixel; JoystickDevPtr priv = device->private; @@ -253,7 +254,8 @@ jstkStartAxisTimer(LocalDevicePtr device, int number) { */ void -jstkStartButtonAxisTimer(LocalDevicePtr device, int number) { +jstkStartButtonAxisTimer(LocalDevicePtr device, int number) +{ int pixel; JoystickDevPtr priv = device->private; @@ -298,7 +300,8 @@ jstkStartButtonAxisTimer(LocalDevicePtr device, int number) { *********************************************************************** */ void -jstkHandleAbsoluteAxis(LocalDevicePtr device, int number) { +jstkHandleAbsoluteAxis(LocalDevicePtr device, int number) +{ JoystickDevPtr priv = device->private; int i,x,y; diff --git a/src/jstk_hw.h b/src/jstk_hw.h index 4c89a7b..2a270e8 100644 --- a/src/jstk_hw.h +++ b/src/jstk_hw.h @@ -24,10 +24,15 @@ #ifndef _LINUX_JSTK_H_INCLUDED_ #define _LINUX_JSTK_H_INCLUDED_ +typedef enum { + EVENT_NONE=0, + EVENT_BUTTON, + EVENT_AXIS +} JOYSTICKEVENT; int jstkOpenDevice(JoystickDevPtr joystick); void jstkCloseDevice(JoystickDevPtr joystick); int jstkReadData(JoystickDevPtr joystick, - enum JOYSTICKEVENT *event, int *number); + JOYSTICKEVENT *event, int *number); #endif diff --git a/src/jstk_options.c b/src/jstk_options.c index 70e7e8a..c7a4f39 100644 --- a/src/jstk_options.c +++ b/src/jstk_options.c @@ -43,13 +43,14 @@ *********************************************************************** */ -static enum JOYSTICKMAPPING -jstkGetAxisMapping(float *value, const char* param, const char* name) { +static JOYSTICKMAPPING +jstkGetAxisMapping(float *value, const char* param, const char* name) +{ if (sscanf(param, "%f", value)==0) { if (param[0] == '-') *value *= -1.0; } -if (strstr(param, "zx") != NULL) + if (strstr(param, "zx") != NULL) return MAPPING_ZX; else if (strstr(param, "zy") != NULL) return MAPPING_ZY; @@ -77,13 +78,14 @@ void jstkParseButtonOption(const char* org, JoystickDevPtr priv, int number, - const char* name) { + const char* name) +{ char *param; char *tmp; int value; float fvalue; char p[64]; - struct BUTTON* button; + BUTTON* button; button = &priv->button[number]; @@ -143,7 +145,8 @@ jstkParseButtonOption(const char* org, */ void -jstkParseAxisOption(const char* org, struct AXIS *axis, const char *name) { +jstkParseAxisOption(const char* org, AXIS *axis, const char *name) +{ char *param; char *tmp; int value; diff --git a/src/jstk_options.h b/src/jstk_options.h index b6c2dfc..b19a160 100644 --- a/src/jstk_options.h +++ b/src/jstk_options.h @@ -29,7 +29,7 @@ void jstkParseButtonOption(const char* org, int number, const char* name); void jstkParseAxisOption(const char* org, - struct AXIS *axis, + AXIS *axis, const char* name); #endif diff --git a/src/linux_jstk.c b/src/linux_jstk.c index 2e630ce..3b89295 100644 --- a/src/linux_jstk.c +++ b/src/linux_jstk.c @@ -148,7 +148,7 @@ jstkCloseDevice(JoystickDevPtr joystick) int jstkReadData(JoystickDevPtr joystick, - enum JOYSTICKEVENT *event, + JOYSTICKEVENT *event, int *number) { struct js_event js; |