summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Hlusiak <saschahlusiak@arcor.de>2007-10-06 17:28:59 +0200
committerSascha Hlusiak <saschahlusiak@arcor.de>2007-10-06 17:28:59 +0200
commit15870ef9bf57475ad79b839613fabd951daceac6 (patch)
treea0314ccf46393d52688b425381b5ff061422e281
parent0897d8acdecf30f9496578019487263a22ed984b (diff)
Use XStringToKeysym to parse symbolic keys defined in xorg.conf.
Users can map buttons to "key=space" or "key=Left" to map them to XK_space or XK_Left. As fallback the numerical expression still works.
-rw-r--r--man/joystick.man32
-rw-r--r--src/Makefile.am9
-rw-r--r--src/jstk.c5
-rw-r--r--src/jstk_options.c24
4 files changed, 48 insertions, 22 deletions
diff --git a/man/joystick.man b/man/joystick.man
index d1e1622..06fb29f 100644
--- a/man/joystick.man
+++ b/man/joystick.man
@@ -64,7 +64,7 @@ The joystick button will generate a click with the specified button (starting wi
Where
.I <axis>
is one of:
-.B X, Y, ZX, ZY
+.B x, y, zx, zy
and
.I <factor>
@@ -116,7 +116,7 @@ will be reported as an additional valuator.
Where
.I <axis>
is one of:
-.B X, Y, ZX, ZY, KEY (see keylow/keyhigh)
+.B x, y, zx, zy, key (see keylow/keyhigh)
and
.I <factor>
@@ -161,7 +161,7 @@ Default: 1000
.RE
.PP
-The default configuration looks as follows:
+The default configuration looks like follows:
.nf
.BI " Option \*qMapButton1\*q \*q" button=1 \*q
@@ -169,8 +169,12 @@ The default configuration looks as follows:
.BI " Option \*qMapButton3\*q \*q" button=3 \*q
.BI " Option \*qMapButton4\*q \*q" none \*q
\ \ ...
-.BI " Option \*qMapAxis1\*q \*q" "mode=relative axis=+1x deadzone=1000" \*q
-.BI " Option \*qMapAxis2\*q \*q" "mode=relative axis=+1y deadzone=1000" \*q
+.BI " Option \*qMapAxis1\*q \*q" "mode=relative axis=+1x deadzone=1000" \*q
+.BI " Option \*qMapAxis2\*q \*q" "mode=relative axis=+1y deadzone=1000" \*q
+.BI " Option \*qMapAxis3\*q \*q" "mode=relative axis=+1zx deadzone=1000" \*q
+.BI " Option \*qMapAxis4\*q \*q" "mode=relative axis=+1zy deadzone=1000" \*q
+.BI " Option \*qMapAxis5\*q \*q" "mode=accelerated axis=+1x deadzone=1000" \*q
+.BI " Option \*qMapAxis6\*q \*q" "mode=accelerated axis=+1y deadzone=1000" \*q
.BI " Option \*qMapAxis3\*q \*q" "mode=none" \*q
\ \ ...
.fi
@@ -218,8 +222,9 @@ total range of 200 pixels, 100 to the top and 100 to the bottom:
Providing a \*qkey=<keysym>[,<keysym>[...]]\*q option will generate X Events with the specified keysyms
when the joystick button is pressed or the axis changed it's position. When the button/axis is released, the keys are released in the reverse order.
-The keysym parameter is defined as a numerical value, which can be looked up in the file
-.IR /usr/include/X11/keysymdef.h .
+The keysym parameter can be defined as a numerical value, which can be looked up in the file
+.IR /usr/include/X11/keysymdef.h ,
+or as the symbolic identifier (case sensitive, without the leading XK_).
You can specify up to 4 keysyms per joystick button/axis, which is useful to use modificators. Make sure you use the modificators
that are necessary to get a certain keysym.
@@ -227,6 +232,7 @@ that are necessary to get a certain keysym.
Examples:
.nf
.BI " Option \*qMapButton1\*q \*q" "key=0xffe9,0xff09" \*q
+.BI " Option \*qMapButton1\*q \*q" "key=Alt_L,Tab" \*q
.fi
will generate
.I "Alt_L+Tab"
@@ -234,22 +240,24 @@ when the button is pressed.
.nf
.BI " Option \*qMapButton1\*q \*q" "key=0xffe1,0x0064" \*q
+.BI " Option \*qMapButton1\*q \*q" "key=Shift_L,d" \*q
.fi
-will generate a lowercase
+will generate an uppercase
.IR d .
.nf
.BI " Option \*qMapButton1\*q \*q" "key=0x0020" \*q
.BI " Option \*qMapButton1\*q \*q" "key=32" \*q
+.BI " Option \*qMapButton1\*q \*q" "key=space" \*q
.fi
is for the
.IR "space " key.
.nf
-.BI " Option \*qMapAxis1\*q \*q" "mode=relative keylow=0xff51 keyhigh=0xff53 axis=0.5key" \*q
-.BI " Option \*qMapAxis2\*q \*q" "mode=relative keylow=0xff52 keyhigh=0xff54" \*q
-.BI " Option \*qMapAxis3\*q \*q" "mode=accelerated keylow=0xff51 keyhigh=0xff53" \*q
-.BI " Option \*qMapAxis4\*q \*q" "mode=accelerated keylow=0xff52 keyhigh=0xff54" \*q
+.BI " Option \*qMapAxis1\*q \*q" "mode=relative keylow=Left keyhigh=Right axis=0.5key" \*q
+.BI " Option \*qMapAxis2\*q \*q" "mode=relative keylow=Up keyhigh=Down" \*q
+.BI " Option \*qMapAxis3\*q \*q" "mode=accelerated keylow=Left keyhigh=Right" \*q
+.BI " Option \*qMapAxis4\*q \*q" "mode=accelerated keylow=Up keyhigh=Down" \*q
.fi
will map the first and third axis to the arrow keys
.IR left " and " right
diff --git a/src/Makefile.am b/src/Makefile.am
index 147c537..de208e0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -28,10 +28,11 @@
@DRIVER_NAME@_drv_la_LDFLAGS = -module -avoid-version
@DRIVER_NAME@_drv_ladir = @inputdir@
-@DRIVER_NAME@_drv_la_SOURCES = jstk.c jstk.h jstk_hw.h \
- jstk_axis.c jstk_axis.h \
- jstk_key.c jstk_key.h \
- jstk_options.c jstk_options.h
+@DRIVER_NAME@_drv_la_SOURCES = jstk.c jstk.h jstk_hw.h \
+ jstk_axis.c jstk_axis.h \
+ jstk_key.c jstk_key.h \
+ jstk_options.c jstk_options.h \
+ StrKeysym.c
BSD_SRCS = bsd_jstk.c
LINUX_SRCS = linux_jstk.c
diff --git a/src/jstk.c b/src/jstk.c
index 70cfcae..8ae506d 100644
--- a/src/jstk.c
+++ b/src/jstk.c
@@ -469,18 +469,19 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
priv->button[2].mapping = MAPPING_BUTTON;
priv->button[2].buttonnumber = 3;
- /* Two axes by default */
+ /* 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;
+ /* 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;
- /* Two axes by default */
+ /* 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;
diff --git a/src/jstk_options.c b/src/jstk_options.c
index 6a3cb01..66b8f37 100644
--- a/src/jstk_options.c
+++ b/src/jstk_options.c
@@ -35,6 +35,8 @@
#include <X11/XF86keysym.h>
#include "jstk.h"
#include "jstk_options.h"
+#include "StrKeysym.h"
+
@@ -149,7 +151,7 @@ jstkParseButtonOption(const char* org,
button = &priv->button[number];
param = xstrdup(org);
- for (tmp = param; *tmp; tmp++) *tmp = tolower(*tmp);
+/* for (tmp = param; *tmp; tmp++) *tmp = tolower(*tmp); */
if (strcmp(param, "none") == 0) {
button->mapping = MAPPING_NONE;
@@ -178,7 +180,11 @@ jstkParseButtonOption(const char* org,
unsigned key;
next = strchr(current, ',');
if (next) *(next++) = '\0';
- key = strtol(current, NULL, 0);
+#ifdef _STRKEYSYM_H_INCLUDED_
+ key = XStringToKeysym(current);
+ if (key == NoSymbol)
+#endif
+ key = strtol(current, NULL, 0);
DBG(3, ErrorF("Parsed %s to %d\n", current, key));
if (key == 0)
xf86Msg(X_WARNING, "%s: error parsing key value: %s.\n",
@@ -225,7 +231,8 @@ jstkParseAxisOption(const char* org,
float fvalue;
char p[64];
param = xstrdup(org);
- for (tmp = param; *tmp; tmp++) *tmp = tolower(*tmp);
+/* for (tmp for (tmp = param; *tmp; tmp++) *tmp = tolower(*tmp);
+= param; *tmp; tmp++) *tmp = tolower(*tmp); */
if ((tmp=strstr(param, "mode=")) != NULL) {
if (sscanf(tmp, "mode=%15s", p) == 1) {
@@ -280,7 +287,11 @@ jstkParseAxisOption(const char* org,
next = strchr(current, ',');
if (next) *(next++) = '\0';
- key = strtol(current, NULL, 0);
+#ifdef _STRKEYSYM_H_INCLUDED_
+ key = XStringToKeysym(current);
+ if (key == NoSymbol)
+#endif
+ key = strtol(current, NULL, 0);
DBG(3, ErrorF("Parsed %s to %d\n", current, key));
if (key == 0)
xf86Msg(X_WARNING, "%s: error parsing keylow value: %s.\n",
@@ -305,6 +316,11 @@ jstkParseAxisOption(const char* org,
next = strchr(current, ',');
if (next) *(next++) = '\0';
key = strtol(current, NULL, 0);
+#ifdef _STRKEYSYM_H_INCLUDED_
+ key = XStringToKeysym(current);
+ if (key == NoSymbol)
+#endif
+ key = strtol(current, NULL, 0);
DBG(3, ErrorF("Parsed %s to %d\n", current, key));
if (key == 0)
xf86Msg(X_WARNING, "%s: error parsing keyhigh value: %s.\n",