xserver-xorg-input-joystick: Changes to 'upstream-unstable'
.gitignore | 2
Makefile.am | 7
config/50-x11-input-joystick.fdi | 41 ++++
configure.ac | 18 +-
include/Makefile.am | 23 ++
include/joystick-properties.h | 123 +++++++++++++
man/joystick.man | 25 +-
src/Makefile.am | 3
src/backend_bsd.c | 44 ++--
src/backend_bsd.h | 6
src/backend_evdev.c | 27 ++-
src/backend_evdev.h | 6
src/backend_joystick.c | 26 ++
src/backend_joystick.h | 6
src/jstk.c | 224 +++++++++++++++----------
src/jstk.h | 51 ++---
src/jstk_axis.c | 83 ++++-----
src/jstk_axis.h | 1
src/jstk_key.c | 180 ++++++++++++++++++--
src/jstk_key.h | 4
src/jstk_options.c | 88 ++++-----
src/jstk_options.h | 3
src/jstk_properties.c | 347 +++++++++++++++++++++++++++++++++++++++
src/jstk_properties.h | 31 +++
xorg-joystick.pc.in | 7
25 files changed, 1079 insertions(+), 297 deletions(-)
New commits:
commit 43e2f0526894cb5eacac8730a21ccdf415421d72
Author: Sascha Hlusiak <saschahlusiak@arcor.de>
Date: Sun Dec 28 18:57:36 2008 +0100
Prepare for 1.4.0 release
diff --git a/configure.ac b/configure.ac
index 62a29c5..45a021a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
AC_PREREQ(2.57)
AC_INIT([xf86-input-joystick],
- 1.3.3,
+ 1.4.0,
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
xf86-input-joystick)
commit fd80f1c2b5b91e0260dc28e9b5e259025ea379e5
Author: Sascha Hlusiak <saschahlusiak@arcor.de>
Date: Sun Dec 28 17:32:44 2008 +0100
Matched comments in joystick-properties.h with previous commit
diff --git a/include/joystick-properties.h b/include/joystick-properties.h
index 603394d..8dc5447 100644
--- a/include/joystick-properties.h
+++ b/include/joystick-properties.h
@@ -82,11 +82,11 @@ typedef enum _JSTK_MAPPING {
#define JSTK_PROP_AXIS_DEADZONE "Axis Deadzone"
/** Set axis type to none, byvalue, accelerated, absolute */
-/* 8 bit, one of enum _JOYSTICKTYPE @ jstk.h per axis*/
+/* 8 bit, one of enum _JSTK_TYPE per axis*/
#define JSTK_PROP_AXIS_TYPE "Axis Type"
/** Set mapping of axis to none, x, y, zx, zy, key */
-/* 8 bit, one of enum _JOYSTICKMAPPING @ jstk.h per axis */
+/* 8 bit, one of enum _JSTK_MAPPING per axis */
#define JSTK_PROP_AXIS_MAPPING "Axis Mapping"
/** Set movement factor of axis (default 1.0f) */
@@ -104,7 +104,7 @@ typedef enum _JSTK_MAPPING {
/** Set the mapping of each button to
none, x, y, zx, zy, button, key, speed_multiply,
disable, disable_mouse, disable_keys */
-/* 8 bit, one of enum _JOYSTICKMAPPING @ jstk.h per button */
+/* 8 bit, one of enum _JSTK_MAPPING per button */
#define JSTK_PROP_BUTTON_MAPPING "Button Mapping"
/** Set the logical button to report for this physical button */
commit f81b9077d13b614262556a7401068f016fe2b365
Author: Sascha Hlusiak <saschahlusiak@arcor.de>
Date: Sun Dec 28 17:28:50 2008 +0100
Export JSTK_* constants with joystick-properties.h
diff --git a/include/joystick-properties.h b/include/joystick-properties.h
index 178df26..603394d 100644
--- a/include/joystick-properties.h
+++ b/include/joystick-properties.h
@@ -30,6 +30,33 @@
*/
+
+/** To be used with property JSTK_PROP_AXIS_TYPE **/
+typedef enum _JSTK_TYPE {
+ JSTK_TYPE_NONE=0, /* Axis value is not relevant */
+ JSTK_TYPE_BYVALUE, /* Speed of cursor is relative to amplitude */
+ JSTK_TYPE_ACCELERATED, /* Speed is accelerated */
+ JSTK_TYPE_ABSOLUTE /* The amplitude defines the cursor position */
+} JSTK_TYPE;
+
+
+/** To be used with properties JSTK_PROP_AXIS_MAPPING, JSTK_PROP_BUTTON_MAPPING */
+typedef enum _JSTK_MAPPING {
+ JSTK_MAPPING_NONE=0, /* Nothing */
+ JSTK_MAPPING_X, /* X-Axis */
+ JSTK_MAPPING_Y, /* Y-Axis */
+ JSTK_MAPPING_ZX, /* Horizontal scrolling */
+ JSTK_MAPPING_ZY, /* Vertical scrolling */
+ JSTK_MAPPING_BUTTON, /* Mouse button */
+ JSTK_MAPPING_KEY, /* Keyboard event */
+ JSTK_MAPPING_SPEED_MULTIPLY, /* Will amplify all axis movement */
+ JSTK_MAPPING_DISABLE, /* Disable mouse and key events */
+ JSTK_MAPPING_DISABLE_MOUSE, /* Disable only mouse events */
+ JSTK_MAPPING_DISABLE_KEYS /* Disable only key events */
+} JSTK_MAPPING;
+
+
+
/** Controls the verbosity of the driver */
/* 8 bit (0..20) */
#define JSTK_PROP_DEBUGLEVEL "Debug Level"
diff --git a/src/jstk.h b/src/jstk.h
index 3e8d891..694ae45 100644
--- a/src/jstk.h
+++ b/src/jstk.h
@@ -26,6 +26,7 @@
#include <xf86Xinput.h>
#include <X11/extensions/XIproto.h>
+#include "joystick-properties.h" /* definitions */
#define MAXBUTTONS 32
@@ -68,28 +69,6 @@ typedef void(*jstkCloseDeviceProc)(JoystickDevPtr joystick);
typedef int(*jstkReadDataProc)(JoystickDevPtr joystick,
JOYSTICKEVENT *event, int *number);
-
-typedef enum _JSTK_TYPE {
- JSTK_TYPE_NONE=0, /* Axis value is not relevant */
- JSTK_TYPE_BYVALUE, /* Speed of cursor is relative to amplitude */
- JSTK_TYPE_ACCELERATED, /* Speed is accelerated */
- JSTK_TYPE_ABSOLUTE /* The amplitude defines the cursor position */
-} JSTK_TYPE;
-
-typedef enum _JSTK_MAPPING {
- JSTK_MAPPING_NONE=0, /* Nothing */
- JSTK_MAPPING_X, /* X-Axis */
- JSTK_MAPPING_Y, /* Y-Axis */
- JSTK_MAPPING_ZX, /* Horizontal scrolling */
- JSTK_MAPPING_ZY, /* Vertical scrolling */
- JSTK_MAPPING_BUTTON, /* Mouse button */
- JSTK_MAPPING_KEY, /* Keyboard event */
- JSTK_MAPPING_SPEED_MULTIPLY, /* Will amplify all axis movement */
- JSTK_MAPPING_DISABLE, /* Disable mouse and key events */
- JSTK_MAPPING_DISABLE_MOUSE, /* Disable only mouse events */
- JSTK_MAPPING_DISABLE_KEYS /* Disable only key events */
-} JSTK_MAPPING;
-
typedef unsigned int KEYSCANCODES [MAXKEYSPERBUTTON];
typedef struct _AXIS {
commit 79028fc80fe7cbd452a18b4ddf92c328a1fe1393
Author: Sascha Hlusiak <saschahlusiak@arcor.de>
Date: Sun Dec 28 17:24:08 2008 +0100
Rename constants for better distinction
@jstk.h:
TYPE_* -> JSTK_TYPE_*
MAPPING_* -> JSTK_MAPPING_*
diff --git a/src/jstk.c b/src/jstk.c
index e749b8d..44acc48 100644
--- a/src/jstk.c
+++ b/src/jstk.c
@@ -169,7 +169,7 @@ jstkReadProc(LocalDevicePtr local)
priv->button[number].mapping));
switch (priv->button[number].mapping) {
- case MAPPING_BUTTON:
+ case JSTK_MAPPING_BUTTON:
if (priv->mouse_enabled == TRUE) {
xf86PostButtonEvent(local->dev, 0,
priv->button[number].buttonnumber,
@@ -177,35 +177,35 @@ jstkReadProc(LocalDevicePtr local)
}
break;
- case MAPPING_X:
- case MAPPING_Y:
- case MAPPING_ZX:
- case MAPPING_ZY:
+ case JSTK_MAPPING_X:
+ case JSTK_MAPPING_Y:
+ case JSTK_MAPPING_ZX:
+ case JSTK_MAPPING_ZY:
if (priv->button[number].pressed == 0)
priv->button[number].currentspeed = 1.0;
else if (priv->mouse_enabled == TRUE)
jstkStartButtonAxisTimer(local, number);
break;
- case MAPPING_KEY:
+ case JSTK_MAPPING_KEY:
if (priv->keys_enabled == TRUE)
jstkGenerateKeys(priv->keyboard_device,
priv->button[number].keys,
priv->button[number].pressed);
break;
- case MAPPING_SPEED_MULTIPLY:
+ case JSTK_MAPPING_SPEED_MULTIPLY:
priv->amplify = 1.0;
/* Calculate new amplify value by multiplying them all */
for (i=0; i<MAXAXES; i++) {
if ((priv->button[i].pressed) &&
- (priv->button[i].mapping == MAPPING_SPEED_MULTIPLY))
+ (priv->button[i].mapping == JSTK_MAPPING_SPEED_MULTIPLY))
priv->amplify *= priv->button[i].amplify;
}
DBG(2, ErrorF("Amplify is now %.3f\n", priv->amplify));
break;
- case MAPPING_DISABLE:
+ case JSTK_MAPPING_DISABLE:
if (priv->button[number].pressed == 1) {
if ((priv->mouse_enabled == TRUE) ||
(priv->keys_enabled == TRUE))
@@ -220,7 +220,7 @@ jstkReadProc(LocalDevicePtr local)
}
}
break;
- case MAPPING_DISABLE_MOUSE:
+ case JSTK_MAPPING_DISABLE_MOUSE:
if (priv->button[number].pressed == 1) {
if (priv->mouse_enabled == TRUE)
priv->mouse_enabled = FALSE;
@@ -229,7 +229,7 @@ jstkReadProc(LocalDevicePtr local)
priv->mouse_enabled ? "enabled" : "disabled"));
}
break;
- case MAPPING_DISABLE_KEYS:
+ case JSTK_MAPPING_DISABLE_KEYS:
if (priv->button[number].pressed == 1) {
if (priv->keys_enabled == TRUE)
priv->keys_enabled = FALSE;
@@ -246,7 +246,7 @@ jstkReadProc(LocalDevicePtr local)
/* An axis was moved */
if ((event == EVENT_AXIS) &&
- (priv->axis[number].type != TYPE_NONE))
+ (priv->axis[number].type != JSTK_TYPE_NONE))
{
DBG(5, ErrorF("Axis %d moved to %d. Type: %d, Mapping: %d\n",
number,
@@ -259,30 +259,30 @@ jstkReadProc(LocalDevicePtr local)
1, priv->axis[number].value);
switch (priv->axis[number].mapping) {
- case MAPPING_X:
- case MAPPING_Y:
- case MAPPING_ZX:
- case MAPPING_ZY:
+ case JSTK_MAPPING_X:
+ case JSTK_MAPPING_Y:
+ case JSTK_MAPPING_ZX:
+ case JSTK_MAPPING_ZY:
switch (priv->axis[number].type) {
- case TYPE_BYVALUE:
- case TYPE_ACCELERATED:
+ case JSTK_TYPE_BYVALUE:
+ case JSTK_TYPE_ACCELERATED:
if (priv->axis[number].value == 0)
priv->axis[number].currentspeed = 1.0;
if (priv->mouse_enabled == TRUE)
jstkStartAxisTimer(local, number);
break;
- case TYPE_ABSOLUTE:
+ case JSTK_TYPE_ABSOLUTE:
if (priv->mouse_enabled == TRUE)
jstkHandleAbsoluteAxis(local, number);
break;
default:
break;
} /* switch (priv->axis[number].type) */
- break; /* case MAPPING_ZY */
+ break; /* case JSTK_MAPPING_ZY */
- case MAPPING_KEY: if (priv->keys_enabled == TRUE) {
- if (priv->axis[number].type == TYPE_ACCELERATED) {
+ case JSTK_MAPPING_KEY: if (priv->keys_enabled == TRUE) {
+ if (priv->axis[number].type == JSTK_TYPE_ACCELERATED) {
if ((priv->axis[number].value > 0) !=
(priv->axis[number].oldvalue > 0))
jstkGenerateKeys(priv->keyboard_device,
@@ -294,14 +294,14 @@ jstkReadProc(LocalDevicePtr local)
jstkGenerateKeys(priv->keyboard_device,
priv->axis[number].keys_low,
(priv->axis[number].value < 0) ? 1:0);
- } else if (priv->axis[number].type == TYPE_BYVALUE) {
+ } else if (priv->axis[number].type == JSTK_TYPE_BYVALUE) {
if (priv->keys_enabled == TRUE)
jstkStartAxisTimer(local, number);
}
break;
}
- case MAPPING_NONE:
+ case JSTK_MAPPING_NONE:
default:
break;
} /* switch (priv->axis[number].mapping) */
@@ -469,7 +469,7 @@ jstkDeviceControlProc(DeviceIntPtr pJstk,
-_X_EXPORT InputDriverRec JOYSTICK_KEYBOARD = {
+_X_EXPORT InputDriverRec JSTK_KEYBOARD = {
1,
"joystick_keyboard",
NULL,
@@ -546,8 +546,8 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
priv->axis[i].value = 0;
priv->axis[i].oldvalue = 0;
priv->axis[i].deadzone = 5000;
- priv->axis[i].type = TYPE_NONE;
- priv->axis[i].mapping = MAPPING_NONE;
+ priv->axis[i].type = JSTK_TYPE_NONE;
+ priv->axis[i].mapping = JSTK_MAPPING_NONE;
priv->axis[i].currentspeed = 0.0f;
priv->axis[i].amplify = 1.0f;
priv->axis[i].valuator = -1;
@@ -558,7 +558,7 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
for (i=0; i<MAXBUTTONS; i++) {
priv->button[i].pressed = 0;
priv->button[i].buttonnumber = 0;
- priv->button[i].mapping = MAPPING_NONE;
+ priv->button[i].mapping = JSTK_MAPPING_NONE;
priv->button[i].currentspeed = 1.0f;
priv->button[i].subpixel = 0.0f;
for (j=0; j<MAXKEYSPERBUTTON; j++)
@@ -566,30 +566,30 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
}
/* First three joystick buttons generate mouse clicks */
- priv->button[0].mapping = MAPPING_BUTTON;
+ priv->button[0].mapping = JSTK_MAPPING_BUTTON;
priv->button[0].buttonnumber = 1;
- priv->button[1].mapping = MAPPING_BUTTON;
+ priv->button[1].mapping = JSTK_MAPPING_BUTTON;
priv->button[1].buttonnumber = 2;
- priv->button[2].mapping = MAPPING_BUTTON;
+ priv->button[2].mapping = JSTK_MAPPING_BUTTON;
priv->button[2].buttonnumber = 3;
/* First two axes are a stick for moving */
- priv->axis[0].type = TYPE_BYVALUE;
- priv->axis[0].mapping = MAPPING_X;
- priv->axis[1].type = TYPE_BYVALUE;
- priv->axis[1].mapping = MAPPING_Y;
+ priv->axis[0].type = JSTK_TYPE_BYVALUE;
+ priv->axis[0].mapping = JSTK_MAPPING_X;
+ priv->axis[1].type = JSTK_TYPE_BYVALUE;
+ priv->axis[1].mapping = JSTK_MAPPING_Y;
/* Next two axes are a stick for scrolling */
- priv->axis[2].type = TYPE_BYVALUE;
- priv->axis[2].mapping = MAPPING_ZX;
- priv->axis[3].type = TYPE_BYVALUE;
- priv->axis[3].mapping = MAPPING_ZY;
+ priv->axis[2].type = JSTK_TYPE_BYVALUE;
+ priv->axis[2].mapping = JSTK_MAPPING_ZX;
+ priv->axis[3].type = JSTK_TYPE_BYVALUE;
+ priv->axis[3].mapping = JSTK_MAPPING_ZY;
/* Next two axes are a pad for moving */
- priv->axis[4].type = TYPE_ACCELERATED;
- priv->axis[4].mapping = MAPPING_X;
- priv->axis[5].type = TYPE_ACCELERATED;
- priv->axis[5].mapping = MAPPING_Y;
+ priv->axis[4].type = JSTK_TYPE_ACCELERATED;
+ priv->axis[4].mapping = JSTK_MAPPING_X;
+ priv->axis[5].type = JSTK_TYPE_ACCELERATED;
+ priv->axis[5].mapping = JSTK_MAPPING_Y;
xf86CollectInputOptions(local, NULL, NULL);
xf86OptionListReport(local->options);
@@ -669,7 +669,7 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
/* return the LocalDevice */
local->flags |= XI86_CONFIGURED;
- priv->keyboard_device = jstkKeyboardPreInit(&JOYSTICK_KEYBOARD, dev, flags);
+ priv->keyboard_device = jstkKeyboardPreInit(&JSTK_KEYBOARD, dev, flags);
if (priv->keyboard_device) {
priv->keyboard_device->private = priv;
}
@@ -746,7 +746,7 @@ jstkDriverPlug(pointer module,
int *errmin)
{
xf86AddInputDriver(&JOYSTICK, module, 0);
- xf86AddInputDriver(&JOYSTICK_KEYBOARD, module, 0);
+ xf86AddInputDriver(&JSTK_KEYBOARD, module, 0);
return module;
}
diff --git a/src/jstk.h b/src/jstk.h
index ec1a6f7..3e8d891 100644
--- a/src/jstk.h
+++ b/src/jstk.h
@@ -69,32 +69,32 @@ typedef int(*jstkReadDataProc)(JoystickDevPtr joystick,
JOYSTICKEVENT *event, int *number);
-typedef enum _JOYSTICKTYPE{
- TYPE_NONE=0, /* Axis value is not relevant */
- 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 _JOYSTICKMAPPING{
- MAPPING_NONE=0, /* Nothing */
- MAPPING_X, /* X-Axis */
- MAPPING_Y, /* Y-Axis */
- MAPPING_ZX, /* Horizontal scrolling */
- MAPPING_ZY, /* Vertical scrolling */
- MAPPING_BUTTON, /* Mouse button */
- MAPPING_KEY, /* Keyboard event */
- MAPPING_SPEED_MULTIPLY, /* Will amplify all axis movement */
- MAPPING_DISABLE, /* Disable mouse and key events */
- MAPPING_DISABLE_MOUSE, /* Disable only mouse events */
- MAPPING_DISABLE_KEYS /* Disable only key events */
-} JOYSTICKMAPPING;
+typedef enum _JSTK_TYPE {
+ JSTK_TYPE_NONE=0, /* Axis value is not relevant */
+ JSTK_TYPE_BYVALUE, /* Speed of cursor is relative to amplitude */
+ JSTK_TYPE_ACCELERATED, /* Speed is accelerated */
+ JSTK_TYPE_ABSOLUTE /* The amplitude defines the cursor position */
+} JSTK_TYPE;
+
+typedef enum _JSTK_MAPPING {
+ JSTK_MAPPING_NONE=0, /* Nothing */
+ JSTK_MAPPING_X, /* X-Axis */
+ JSTK_MAPPING_Y, /* Y-Axis */
+ JSTK_MAPPING_ZX, /* Horizontal scrolling */
+ JSTK_MAPPING_ZY, /* Vertical scrolling */
+ JSTK_MAPPING_BUTTON, /* Mouse button */
+ JSTK_MAPPING_KEY, /* Keyboard event */
+ JSTK_MAPPING_SPEED_MULTIPLY, /* Will amplify all axis movement */
+ JSTK_MAPPING_DISABLE, /* Disable mouse and key events */
+ JSTK_MAPPING_DISABLE_MOUSE, /* Disable only mouse events */
+ JSTK_MAPPING_DISABLE_KEYS /* Disable only key events */
+} JSTK_MAPPING;
typedef unsigned int KEYSCANCODES [MAXKEYSPERBUTTON];
typedef struct _AXIS {
- JOYSTICKTYPE type;
- JOYSTICKMAPPING mapping;
+ JSTK_TYPE type;
+ JSTK_MAPPING mapping;
int value, oldvalue;
int valuator;
int deadzone;
@@ -106,7 +106,7 @@ typedef struct _AXIS {
} AXIS;
typedef struct _BUTTON {
- JOYSTICKMAPPING mapping;
+ JSTK_MAPPING mapping;
char pressed;
int buttonnumber; /* MAPPING_BUTTON */
float amplify; /* MAPPING_X/Y/ZX/ZY,
diff --git a/src/jstk_axis.c b/src/jstk_axis.c
index 4b46af1..3c49bd3 100644
--- a/src/jstk_axis.c
+++ b/src/jstk_axis.c
@@ -67,7 +67,7 @@ jstkAxisTimer(OsTimerPtr timer,
sigstate = xf86BlockSIGIO();
for (i=0; i<MAXAXES; i++) if ((priv->axis[i].value != 0) &&
- (priv->axis[i].type != TYPE_NONE)) {
+ (priv->axis[i].type != JSTK_TYPE_NONE)) {
float p1 = 0.0f; /* Pixels to move cursor */
float p2 = 0.0f; /* Pixels to scroll */
float scale;
@@ -76,7 +76,7 @@ jstkAxisTimer(OsTimerPtr timer,
nexttimer = NEXTTIMER;
- if (priv->axis[i].type == TYPE_BYVALUE) {
+ if (priv->axis[i].type == JSTK_TYPE_BYVALUE) {
/* Calculate scale value, so we get a range from 0 to 32768 */
scale = (32768.0f / (float)(32768 - axis->deadzone));
@@ -88,7 +88,7 @@ jstkAxisTimer(OsTimerPtr timer,
p2 = ((pow((abs((float)axis->value) - (float)axis->deadzone) *
scale / 1000.0f, 2.5f)) + 200.0f) *
((float)NEXTTIMER / 200000.0f);
- } else if (axis->type == TYPE_ACCELERATED) {
+ } else if (axis->type == JSTK_TYPE_ACCELERATED) {
/* Stop to accelerate at a certain speed */
if (axis->currentspeed < 100.0f)
axis->currentspeed = (axis->currentspeed + 3.0f) * 1.07f - 3.0f;
@@ -104,13 +104,13 @@ jstkAxisTimer(OsTimerPtr timer,
/* Apply movement to global amount of pixels to move */
switch (axis->mapping) {
- case MAPPING_X:
- case MAPPING_Y:
+ case JSTK_MAPPING_X:
+ case JSTK_MAPPING_Y:
axis->subpixel += p1;
break;
- case MAPPING_ZX:
- case MAPPING_ZY:
- case MAPPING_KEY:
+ case JSTK_MAPPING_ZX:
+ case JSTK_MAPPING_ZY:
+ case JSTK_MAPPING_KEY:
axis->subpixel += p2;
break;
default:
@@ -118,21 +118,21 @@ jstkAxisTimer(OsTimerPtr timer,
}
if ((int)axis->subpixel != 0) {
switch (axis->mapping) {
- case MAPPING_X:
+ case JSTK_MAPPING_X:
movex += (int)axis->subpixel;
break;
- case MAPPING_Y:
+ case JSTK_MAPPING_Y:
movey += (int)axis->subpixel;
break;
- case MAPPING_ZX:
+ case JSTK_MAPPING_ZX:
movezx += (int)axis->subpixel;
break;
- case MAPPING_ZY:
+ case JSTK_MAPPING_ZY:
movezy += (int)axis->subpixel;
break;
- case MAPPING_KEY: if ((priv->keys_enabled == TRUE) &&
- (priv->axis[i].type == TYPE_BYVALUE)) {
+ case JSTK_MAPPING_KEY: if ((priv->keys_enabled == TRUE) &&
+ (priv->axis[i].type == JSTK_TYPE_BYVALUE)) {
int num;
num = abs((int)axis->subpixel);
if ((int)axis->subpixel < 0) {
@@ -169,13 +169,13 @@ jstkAxisTimer(OsTimerPtr timer,
/* Apply movement to amount of pixels to move */
switch (priv->button[i].mapping) {
- case MAPPING_X:
- case MAPPING_Y:
+ case JSTK_MAPPING_X:
+ case JSTK_MAPPING_Y:
priv->button[i].subpixel += p1;
nexttimer = NEXTTIMER;
break;
- case MAPPING_ZX:
- case MAPPING_ZY:
+ case JSTK_MAPPING_ZX:
+ case JSTK_MAPPING_ZY:
priv->button[i].subpixel += p2;
nexttimer = NEXTTIMER;
break;
@@ -184,16 +184,16 @@ jstkAxisTimer(OsTimerPtr timer,
}
if ((int)priv->button[i].subpixel != 0) {
switch (priv->button[i].mapping) {
- case MAPPING_X:
+ case JSTK_MAPPING_X:
movex += (int)priv->button[i].subpixel;
break;
- case MAPPING_Y:
+ case JSTK_MAPPING_Y:
movey += (int)priv->button[i].subpixel;
break;
- case MAPPING_ZX:
+ case JSTK_MAPPING_ZX:
movezx += (int)priv->button[i].subpixel;
break;
- case MAPPING_ZY:
+ case JSTK_MAPPING_ZY:
movezy += (int)priv->button[i].subpixel;
break;
default:
@@ -309,10 +309,10 @@ jstkStartButtonAxisTimer(LocalDevicePtr device, int number)
pixel = 1;
if (priv->button[number].amplify < 0) pixel = -1;
switch (priv->button[number].mapping) {
- case MAPPING_X:
- case MAPPING_Y:
- case MAPPING_ZX:
- case MAPPING_ZY:
+ case JSTK_MAPPING_X:
+ case JSTK_MAPPING_Y:
+ case JSTK_MAPPING_ZX:
+ case JSTK_MAPPING_ZY:
priv->button[number].subpixel += pixel;
break;
default:
@@ -347,7 +347,7 @@ jstkHandleAbsoluteAxis(LocalDevicePtr device, int number)
y=0;
for (i=0; i<MAXAXES; i++)
- if (priv->axis[i].type == TYPE_ABSOLUTE)
+ if (priv->axis[i].type == JSTK_TYPE_ABSOLUTE)
{
float rel;
int dif;
@@ -366,11 +366,11 @@ jstkHandleAbsoluteAxis(LocalDevicePtr device, int number)
/* Calculate difference to previous position on screen in pixels */
dif = (int)(rel - priv->axis[i].previousposition + 0.5f);
if ((dif >= 1)||(dif <= -1)) {
- if (priv->axis[i].mapping == MAPPING_X) {
+ if (priv->axis[i].mapping == JSTK_MAPPING_X) {
x += (dif);
priv->axis[i].previousposition += (float)dif;
}
- if (priv->axis[i].mapping == MAPPING_Y) {
+ if (priv->axis[i].mapping == JSTK_MAPPING_Y) {
y += (int)(dif);
priv->axis[i].previousposition += (float)dif;
}
diff --git a/src/jstk_options.c b/src/jstk_options.c
index c7b4722..309175e 100644
--- a/src/jstk_options.c
+++ b/src/jstk_options.c
@@ -77,7 +77,7 @@ jstkGetKeyNumberInMap(JoystickDevPtr priv,
***********************************************************************
*/
-static JOYSTICKMAPPING
+static JSTK_MAPPING
jstkGetAxisMapping(float *value, const char* param, const char* name)
{
if (sscanf(param, "%f", value)==0) {
@@ -85,17 +85,17 @@ jstkGetAxisMapping(float *value, const char* param, const char* name)
*value *= -1.0;
}
if (strstr(param, "key") != NULL)
- return MAPPING_KEY;
+ return JSTK_MAPPING_KEY;
else if (strstr(param, "zx") != NULL)
- return MAPPING_ZX;
+ return JSTK_MAPPING_ZX;
else if (strstr(param, "zy") != NULL)
- return MAPPING_ZY;
+ return JSTK_MAPPING_ZY;
else if (strstr(param, "x") != NULL)
- return MAPPING_X;
+ return JSTK_MAPPING_X;
else if (strstr(param, "y") != NULL)
- return MAPPING_Y;
+ return JSTK_MAPPING_Y;
- return MAPPING_NONE;
+ return JSTK_MAPPING_NONE;
}
@@ -128,13 +128,13 @@ jstkParseButtonOption(const char* org,
/* for (tmp = param; *tmp; tmp++) *tmp = tolower(*tmp); */
if (strcmp(param, "none") == 0) {
- button->mapping = MAPPING_NONE;
+ button->mapping = JSTK_MAPPING_NONE;
} else if (sscanf(param, "button=%d", &value) == 1) {
if (value<0 || value >BUTTONMAP_SIZE) {
xf86Msg(X_WARNING, "%s: button number out of range (0..%d): %d.\n",
name, BUTTONMAP_SIZE, value);
} else {
- button->mapping = MAPPING_BUTTON;
+ button->mapping = JSTK_MAPPING_BUTTON;
button->buttonnumber = value;
}
} else if (sscanf(param, "axis=%15s", p) == 1) {
@@ -143,17 +143,17 @@ jstkParseButtonOption(const char* org,
button->mapping = jstkGetAxisMapping(&fvalue, p, name);
button->amplify = fvalue;
button->currentspeed = 1.0f;
- if (button->mapping == MAPPING_NONE)
+ if (button->mapping == JSTK_MAPPING_NONE)
xf86Msg(X_WARNING, "%s: error parsing axis: %s.\n",
name, p);
} else if (sscanf(param, "amplify=%f", &fvalue) == 1) {
- button->mapping = MAPPING_SPEED_MULTIPLY;
+ button->mapping = JSTK_MAPPING_SPEED_MULTIPLY;
button->amplify = fvalue;
} else if (sscanf(param, "key=%30s", p) == 1) {
char *current, *next;
p[30]='\0';
current = p;
- button->mapping = MAPPING_KEY;
+ button->mapping = JSTK_MAPPING_KEY;
for (value = 0; value < MAXKEYSPERBUTTON; value++) if (current != NULL) {
unsigned key;
@@ -175,11 +175,11 @@ jstkParseButtonOption(const char* org,
current = next;
} else button->keys[value] = 0;
} else if (strcmp(param, "disable-all") == 0) {
- button->mapping = MAPPING_DISABLE;
+ button->mapping = JSTK_MAPPING_DISABLE;
} else if (strcmp(param, "disable-mouse") == 0) {
- button->mapping = MAPPING_DISABLE_MOUSE;
+ button->mapping = JSTK_MAPPING_DISABLE_MOUSE;
} else if (strcmp(param, "disable-keys") == 0) {
- button->mapping = MAPPING_DISABLE_KEYS;
+ button->mapping = JSTK_MAPPING_DISABLE_KEYS;
} else {
xf86Msg(X_WARNING, "%s: error parsing button parameter.\n",
name);
@@ -218,16 +218,16 @@ jstkParseAxisOption(const char* org,
if (sscanf(tmp, "mode=%15s", p) == 1) {
p[15] = '\0';
if (strcmp(p, "relative") == 0) {
- axis->type = TYPE_BYVALUE;
+ axis->type = JSTK_TYPE_BYVALUE;
} else if (strcmp(p, "accelerated") == 0) {
- axis->type = TYPE_ACCELERATED;
+ axis->type = JSTK_TYPE_ACCELERATED;
axis->currentspeed = 1.0f;
} else if (strcmp(p, "absolute") == 0) {
- axis->type = TYPE_ABSOLUTE;
+ axis->type = JSTK_TYPE_ABSOLUTE;
} else if (strcmp(p, "none") == 0) {
- axis->type = TYPE_NONE;
+ axis->type = JSTK_TYPE_NONE;
} else {
- axis->type = TYPE_NONE;
+ axis->type = JSTK_TYPE_NONE;
xf86Msg(X_WARNING, "%s: \"%s\": error parsing mode.\n",
name, param);
}
@@ -240,15 +240,15 @@ jstkParseAxisOption(const char* org,
p[15] = '\0';
fvalue = 1.0f;
axis->mapping = jstkGetAxisMapping(&fvalue, p, name);
- if ((axis->type == TYPE_ABSOLUTE) &&
+ if ((axis->type == JSTK_TYPE_ABSOLUTE) &&
((fvalue <= 1.1)&&(fvalue >= -1.1))) {
- if (axis->mapping == MAPPING_X)
+ if (axis->mapping == JSTK_MAPPING_X)
fvalue *= (int)screenInfo.screens[0]->width;
- if (axis->mapping == MAPPING_Y)
+ if (axis->mapping == JSTK_MAPPING_Y)
fvalue *= (int)screenInfo.screens[0]->height;
}
axis->amplify = fvalue;
- if (axis->mapping == MAPPING_NONE)
+ if (axis->mapping == JSTK_MAPPING_NONE)
xf86Msg(X_WARNING, "%s: error parsing axis: %s.\n",
name, p);
}else xf86Msg(X_WARNING, "%s: error parsing axis.\n",
@@ -265,7 +265,7 @@ jstkParseAxisOption(const char* org,
unsigned int key;
p[30]='\0';
current = p;
- axis->mapping = MAPPING_KEY;
+ axis->mapping = JSTK_MAPPING_KEY;
for (value = 0; value < MAXKEYSPERBUTTON; value++)
if (current != NULL) {
next = strchr(current, ',');
@@ -295,7 +295,7 @@ jstkParseAxisOption(const char* org,
unsigned int key;
p[30]='\0';
current = p;
- axis->mapping = MAPPING_KEY;
+ axis->mapping = JSTK_MAPPING_KEY;
for (value = 0; value < MAXKEYSPERBUTTON; value++)
if (current != NULL) {
next = strchr(current, ',');
commit 38b4c9b3bd814296971abfe6ef01f531367a43bb
Author: Peter Hutterer <peter.hutterer@redhat.com>
Date: Mon Oct 13 10:46:10 2008 +1030
properties: handle checkonly flag in SetProperty.
If checkonly is TRUE, don't touch any values, just check vor validity of the
data.
Signed-off-by: Sascha Hlusiak <saschahlusiak@arcor.de>
diff --git a/src/jstk_properties.c b/src/jstk_properties.c
index ae161a6..98f85c5 100644
--- a/src/jstk_properties.c
+++ b/src/jstk_properties.c
@@ -60,7 +60,8 @@ static Atom prop_button_keys = 0;
static int
-jstkSetProperty(DeviceIntPtr pJstk, Atom atom, XIPropertyValuePtr val)
+jstkSetProperty(DeviceIntPtr pJstk, Atom atom, XIPropertyValuePtr val,
+ BOOL checkonly)
{
InputInfoPtr pInfo = pJstk->public.devicePrivate;
JoystickDevPtr priv = pInfo->private;
@@ -71,8 +72,11 @@ jstkSetProperty(DeviceIntPtr pJstk, Atom atom, XIPropertyValuePtr val)
#if DEBUG
if (val->size != 1 || val->format != 8 || val->type != XA_INTEGER)
return BadMatch;
- debug_level = *((INT8*)val->data);
- ErrorF("JOYSTICK: DebugLevel set to %d\n", debug_level);
+ if (!checkonly)
+ {
+ debug_level = *((INT8*)val->data);
+ ErrorF("JOYSTICK: DebugLevel set to %d\n", debug_level);
+ }
#endif
}else if (atom == prop_numbuttons)
{
@@ -92,14 +96,20 @@ jstkSetProperty(DeviceIntPtr pJstk, Atom atom, XIPropertyValuePtr val)
{
if (val->size != 1 || val->format != 8 || val->type != XA_INTEGER)
return BadMatch;
- priv->mouse_enabled = (*((INT8*)val->data)) != 0;
- DBG(1, ErrorF("mouse_enabled set to %d\n", priv->mouse_enabled));
+ if (!checkonly)
+ {
+ priv->mouse_enabled = (*((INT8*)val->data)) != 0;
+ DBG(1, ErrorF("mouse_enabled set to %d\n", priv->mouse_enabled));
+ }
}else if (atom == prop_keys_enabled)
{
if (val->size != 1 || val->format != 8 || val->type != XA_INTEGER)
return BadMatch;
- priv->keys_enabled = (*((INT8*)val->data)) != 0;
- DBG(1, ErrorF("keys_enabled set to %d\n", priv->keys_enabled));
+ if (!checkonly)
+ {
+ priv->keys_enabled = (*((INT8*)val->data)) != 0;
+ DBG(1, ErrorF("keys_enabled set to %d\n", priv->keys_enabled));
+ }
}else if (atom == prop_axis_deadzone)
{
INT32 *values;
@@ -109,29 +119,38 @@ jstkSetProperty(DeviceIntPtr pJstk, Atom atom, XIPropertyValuePtr val)
for (i =0; i<val->size; i++) /* Fail, if one value is out of range */
if (values[i] > 30000 || values[i] < -30000)
return BadValue;
- for (i =0; i<val->size; i++) {
- priv->axis[i].deadzone = (values[i]<0)?(-values[i]):(values[i]);
- DBG(1, ErrorF("Deadzone of axis %d set to %d\n",i, priv->axis[i].deadzone));
+ if (!checkonly)
+ {
+ for (i =0; i<val->size; i++) {
+ priv->axis[i].deadzone = (values[i]<0)?(-values[i]):(values[i]);
+ DBG(1, ErrorF("Deadzone of axis %d set to %d\n",i, priv->axis[i].deadzone));
+ }
}
}else if (atom == prop_axis_type)
{
INT8 *values;
if (val->size != priv->num_axes || val->format != 8 || val->type != XA_INTEGER)
return BadMatch;
- values = (INT8*)val->data;
- for (i =0; i<val->size; i++) {
- priv->axis[i].type = values[i];
- DBG(1, ErrorF("Type of axis %d set to %d\n",i, priv->axis[i].type));
+ if (!checkonly)
+ {
+ values = (INT8*)val->data;
+ for (i =0; i<val->size; i++) {
+ priv->axis[i].type = values[i];
+ DBG(1, ErrorF("Type of axis %d set to %d\n",i, priv->axis[i].type));
+ }
}
}else if (atom == prop_axis_mapping)
{
INT8 *values;
if (val->size != priv->num_axes || val->format != 8 || val->type != XA_INTEGER)
return BadMatch;
- values = (INT8*)val->data;
- for (i =0; i<val->size; i++) {
- priv->axis[i].mapping = values[i];
- DBG(1, ErrorF("Mapping of axis %d set to %d\n",i, priv->axis[i].mapping));
+ if (!checkonly)
+ {
+ values = (INT8*)val->data;
+ for (i =0; i<val->size; i++) {
+ priv->axis[i].mapping = values[i];
+ DBG(1, ErrorF("Mapping of axis %d set to %d\n",i, priv->axis[i].mapping));
+ }
}
}else if (atom == prop_axis_amplify)
{
@@ -150,10 +169,13 @@ jstkSetProperty(DeviceIntPtr pJstk, Atom atom, XIPropertyValuePtr val)
INT8 *values;
if (val->size != priv->num_buttons || val->format != 8 || val->type != XA_INTEGER)
return BadMatch;
- values = (INT8*)val->data;
- for (i =0; i<val->size; i++) {
- priv->button[i].mapping = values[i];
- DBG(1, ErrorF("Mapping of button %d set to %d\n",i, priv->button[i].mapping));
+ if (!checkonly)
+ {
+ values = (INT8*)val->data;
+ for (i =0; i<val->size; i++) {
+ priv->button[i].mapping = values[i];
+ DBG(1, ErrorF("Mapping of button %d set to %d\n",i, priv->button[i].mapping));
+ }
}
}else if (atom == prop_button_buttonnumber)
{
@@ -168,12 +190,15 @@ jstkSetProperty(DeviceIntPtr pJstk, Atom atom, XIPropertyValuePtr val)
return BadValue;
}
}
- for (i = 0; i<val->size; i++) {
- priv->button[i].buttonnumber =
- values[i];
- DBG(1, ErrorF("Button number of button %d set to %d\n",
- i,
- priv->button[i].buttonnumber));
+ if (!checkonly)
+ {
+ for (i = 0; i<val->size; i++) {
+ priv->button[i].buttonnumber =
+ values[i];
+ DBG(1, ErrorF("Button number of button %d set to %d\n",
+ i,
+ priv->button[i].buttonnumber));
+ }
}
return Success;
}else if (atom == prop_button_amplify)
commit 0da072fde42d899b56cc7b05d7b3db2815ac3b9a
Author: Sascha Hlusiak <saschahlusiak@arcor.de>
Date: Wed Oct 1 23:14:22 2008 +0200
Install joystick-properties.h and xorg-joystick.pc for clients.
Let's clients be aware of properties made available by the driver.
diff --git a/.gitignore b/.gitignore
index 9e5c3ec..c96e99e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,4 @@ stamp-h1
xf86-input-joystick-*.tar.bz2
xf86-input-joystick-*.tar.gz
ChangeLog
+*.pc
diff --git a/Makefile.am b/Makefile.am
index ac7f45b..bc41c7c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,7 +19,10 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AUTOMAKE_OPTIONS = foreign
-SUBDIRS = src man config
+SUBDIRS = src man config include
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = xorg-joystick.pc
EXTRA_DIST = autogen.sh ChangeLog
diff --git a/configure.ac b/configure.ac
index ed4d1de..62a29c5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,6 +73,7 @@ XORG_DRIVER_CHECK_EXT(XKB, kbproto)
PKG_CHECK_MODULES(XORG,
[xorg-server >= 1.3.99.901] xproto $REQUIRED_MODULES)
sdkdir=$(pkg-config --variable=sdkdir xorg-server)
+AC_SUBST(sdkdir)
CFLAGS="$CFLAGS $XORG_CFLAGS "' -I$(top_srcdir)/src'
AC_SUBST([CFLAGS])
@@ -112,7 +113,12 @@ AC_HEADER_STDC
XORG_MANPAGE_SECTIONS
XORG_RELEASE_VERSION
-AC_OUTPUT([Makefile src/Makefile man/Makefile config/Makefile])
+AC_OUTPUT([Makefile
+ src/Makefile
+ man/Makefile
+ config/Makefile
+ include/Makefile
+ xorg-joystick.pc])
echo
echo Building Linux joystick backend: $linux_backend
Reply to: