diff options
author | Sascha Hlusiak <saschahlusiak@arcor.de> | 2007-04-29 21:59:54 -0400 |
---|---|---|
committer | Sascha Hlusiak <saschahlusiak@arcor.de> | 2007-04-29 21:59:54 -0400 |
commit | 2bbc03ef668bc450fd50ecbbaa6f19398e994f74 (patch) | |
tree | 5c1701cc389e514fd4adc1f3fea94765800b2765 | |
parent | 461b57cdb14e6bc2fe27f5351c2c3bd66aa1786a (diff) |
Removed unnamed unions to compile with gcc 2.95
Only report correct amount of buttons to xorg-server-1.3
Call InitButtonClassDeviceStruct with right number of buttons and right mapping. Works correctly
since xorg-server-1.3.
-rw-r--r-- | src/jstk.c | 33 | ||||
-rw-r--r-- | src/jstk.h | 20 |
2 files changed, 28 insertions, 25 deletions
@@ -245,24 +245,32 @@ jstkDeviceControlProc(DeviceIntPtr pJstk, int what) { int i; - CARD8 map[MAXBUTTONS]; + CARD8 map[MAXBUTTONS+1]; LocalDevicePtr local = (LocalDevicePtr)pJstk->public.devicePrivate; JoystickDevPtr priv = (JoystickDevPtr)XI_PRIVATE(pJstk); switch (what) { - case DEVICE_INIT: + case DEVICE_INIT: { + int m; DBG(1, ErrorF("jstkDeviceControlProc what=INIT\n")); - for (i=1; i<MAXBUTTONS; i++) map[i] = i; - - if (InitButtonClassDeviceStruct(pJstk, MAXBUTTONS, map) == FALSE) { - ErrorF("unable to allocate Button class device\n"); - return !Success; + m=0; + for (i=0; i<MAXBUTTONS; i++) + if (priv->button[i].mapping == MAPPING_BUTTON) + { + m++; + map[m] = priv->button[i].buttonnumber; + priv->button[i].buttonnumber = m; } - - if (InitFocusClassDeviceStruct(pJstk) == FALSE) { - ErrorF("unable to init Focus class device\n"); - return !Success; + if (m != 0) { + if (InitButtonClassDeviceStruct(pJstk, m, map) == FALSE) { + ErrorF("unable to allocate Button class device\n"); + return !Success; + } + if (InitFocusClassDeviceStruct(pJstk) == FALSE) { + ErrorF("unable to init Focus class device\n"); + return !Success; + } } if (InitValuatorClassDeviceStruct(pJstk, @@ -291,7 +299,8 @@ jstkDeviceControlProc(DeviceIntPtr pJstk, /* allocate the motion history buffer if needed */ xf86MotionHistoryAllocate(local); } - break; + break; + } case DEVICE_ON: DBG(1, ErrorF("jstkDeviceControlProc what=ON name=%s\n", priv->device)); @@ -78,10 +78,8 @@ typedef struct _AXIS { JOYSTICKMAPPING mapping; int value; int deadzone; - union { - float currentspeed; - float previousposition; - }; + float currentspeed; + float previousposition; float amplify; } AXIS; @@ -90,15 +88,11 @@ typedef struct _AXIS { typedef struct _BUTTON { JOYSTICKMAPPING mapping; char pressed; - union { - int buttonnumber; /* MAPPING_BUTTON */ - struct { - float amplify; /* MAPPING_X/Y/ZX/ZY, - MAPPING_SPEED_MULTIPLY */ - float currentspeed; /* MAPPING_X/Y/ZX/ZY */ - }; - unsigned int keys[MAXKEYSPERBUTTON]; /* MAPPING_KEY */ - }; + int buttonnumber; /* MAPPING_BUTTON */ + float amplify; /* MAPPING_X/Y/ZX/ZY, + MAPPING_SPEED_MULTIPLY */ + float currentspeed; /* MAPPING_X/Y/ZX/ZY */ + unsigned int keys[MAXKEYSPERBUTTON]; /* MAPPING_KEY */ } BUTTON; #define MAXBUTTONS 32 |