diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2011-07-02 21:03:44 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2011-07-02 21:03:44 +0000 |
commit | e6d41a75a2c945bcb7a2015aee3e1b704afaa3fe (patch) | |
tree | 94e1b382a6eb39de0a09129ba9d57158bf1b9377 /driver/xf86-input-joystick/src | |
parent | a6bef7241c3f005494bc833ddb226839552e7e76 (diff) |
Update to xf86-input-joystick 1.6.0
Diffstat (limited to 'driver/xf86-input-joystick/src')
-rw-r--r-- | driver/xf86-input-joystick/src/Makefile.am | 3 | ||||
-rw-r--r-- | driver/xf86-input-joystick/src/Makefile.in | 29 | ||||
-rw-r--r-- | driver/xf86-input-joystick/src/backend_bsd.c | 1 | ||||
-rw-r--r-- | driver/xf86-input-joystick/src/backend_evdev.c | 1 | ||||
-rw-r--r-- | driver/xf86-input-joystick/src/backend_joystick.c | 1 | ||||
-rw-r--r-- | driver/xf86-input-joystick/src/jstk.c | 319 | ||||
-rw-r--r-- | driver/xf86-input-joystick/src/jstk.h | 13 | ||||
-rw-r--r-- | driver/xf86-input-joystick/src/jstk_axis.c | 15 | ||||
-rw-r--r-- | driver/xf86-input-joystick/src/jstk_axis.h | 8 | ||||
-rw-r--r-- | driver/xf86-input-joystick/src/jstk_key.c | 482 | ||||
-rw-r--r-- | driver/xf86-input-joystick/src/jstk_key.h | 9 | ||||
-rw-r--r-- | driver/xf86-input-joystick/src/jstk_options.c | 5 | ||||
-rw-r--r-- | driver/xf86-input-joystick/src/jstk_properties.c | 7 |
13 files changed, 258 insertions, 635 deletions
diff --git a/driver/xf86-input-joystick/src/Makefile.am b/driver/xf86-input-joystick/src/Makefile.am index 1f8898eb5..21cdf3235 100644 --- a/driver/xf86-input-joystick/src/Makefile.am +++ b/driver/xf86-input-joystick/src/Makefile.am @@ -24,7 +24,8 @@ # -avoid-version prevents gratuitous .0.0.0 version numbers on the end # _ladir passes a dummy rpath to libtool so the thing will actually link # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. -AM_CFLAGS = $(XORG_CFLAGS) + +AM_CFLAGS = $(XORG_CFLAGS) $(CWARNFLAGS) @DRIVER_NAME@_drv_la_LTLIBRARIES = @DRIVER_NAME@_drv.la @DRIVER_NAME@_drv_la_LDFLAGS = -module -avoid-version diff --git a/driver/xf86-input-joystick/src/Makefile.in b/driver/xf86-input-joystick/src/Makefile.in index 254804072..dac59c2f8 100644 --- a/driver/xf86-input-joystick/src/Makefile.in +++ b/driver/xf86-input-joystick/src/Makefile.in @@ -34,6 +34,12 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# this is obnoxious: +# -module lets us name the module exactly how we want +# -avoid-version prevents gratuitous .0.0.0 version numbers on the end +# _ladir passes a dummy rpath to libtool so the thing will actually link +# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. + srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ @@ -43,9 +49,9 @@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c +install_sh_DATA = ${SHELL} $(install_sh) -c -m 644 +install_sh_PROGRAM = ${SHELL} $(install_sh) -c +install_sh_SCRIPT = ${SHELL} $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : @@ -116,6 +122,7 @@ ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ APP_MAN_DIR = @APP_MAN_DIR@ APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ AR = @AR@ @@ -158,6 +165,7 @@ FFLAGS = @FFLAGS@ FILE_MAN_DIR = @FILE_MAN_DIR@ FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ GREP = @GREP@ +INSTALL_CMD = @INSTALL_CMD@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ @@ -176,6 +184,7 @@ MAINT = @MAINT@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ +MAN_SUBSTS = @MAN_SUBSTS@ MISC_MAN_DIR = @MISC_MAN_DIR@ MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ NMEDIT = @NMEDIT@ @@ -196,6 +205,7 @@ STRIP = @STRIP@ VERSION = @VERSION@ XORG_CFLAGS = @XORG_CFLAGS@ XORG_LIBS = @XORG_LIBS@ +XORG_MAN_PAGE = @XORG_MAN_PAGE@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_F77 = @ac_ct_F77@ @@ -216,7 +226,6 @@ build_os = @build_os@ build_vendor = @build_vendor@ datadir = @datadir@ datarootdir = @datarootdir@ -distcleancheck_listfiles = @distcleancheck_listfiles@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ @@ -246,13 +255,7 @@ sdkdir = @sdkdir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ - -# this is obnoxious: -# -module lets us name the module exactly how we want -# -avoid-version prevents gratuitous .0.0.0 version numbers on the end -# _ladir passes a dummy rpath to libtool so the thing will actually link -# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(XORG_CFLAGS) $(CWARNFLAGS) @DRIVER_NAME@_drv_la_LTLIBRARIES = @DRIVER_NAME@_drv.la @DRIVER_NAME@_drv_la_LDFLAGS = -module -avoid-version $(am__append_2) @DRIVER_NAME@_drv_ladir = @inputdir@ @@ -278,9 +281,9 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/Makefile + $(AUTOMAKE) --foreign src/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ diff --git a/driver/xf86-input-joystick/src/backend_bsd.c b/driver/xf86-input-joystick/src/backend_bsd.c index 71f4168dc..c6ce7b4c5 100644 --- a/driver/xf86-input-joystick/src/backend_bsd.c +++ b/driver/xf86-input-joystick/src/backend_bsd.c @@ -30,6 +30,7 @@ #include "config.h" #endif +#include <xorg-server.h> #include <unistd.h> #include <sys/types.h> #include <sys/ioctl.h> diff --git a/driver/xf86-input-joystick/src/backend_evdev.c b/driver/xf86-input-joystick/src/backend_evdev.c index de061d3dc..c506167fd 100644 --- a/driver/xf86-input-joystick/src/backend_evdev.c +++ b/driver/xf86-input-joystick/src/backend_evdev.c @@ -29,6 +29,7 @@ #include "config.h" #endif +#include <xorg-server.h> #include <unistd.h> #include <sys/types.h> #include <sys/ioctl.h> diff --git a/driver/xf86-input-joystick/src/backend_joystick.c b/driver/xf86-input-joystick/src/backend_joystick.c index b69f932c2..e61d90842 100644 --- a/driver/xf86-input-joystick/src/backend_joystick.c +++ b/driver/xf86-input-joystick/src/backend_joystick.c @@ -32,6 +32,7 @@ #include "config.h" #endif +#include <xorg-server.h> #include <unistd.h> #include <sys/types.h> #include <sys/ioctl.h> diff --git a/driver/xf86-input-joystick/src/jstk.c b/driver/xf86-input-joystick/src/jstk.c index a2e927c08..ec6b79ad0 100644 --- a/driver/xf86-input-joystick/src/jstk.c +++ b/driver/xf86-input-joystick/src/jstk.c @@ -26,6 +26,7 @@ #include "config.h" #endif +#include <xorg-server.h> #include <stdio.h> #include <xorgVersion.h> @@ -44,9 +45,7 @@ #include "jstk_key.h" #include "jstk_options.h" #include "jstk_properties.h" -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3 - #include <xserver-properties.h> -#endif +#include <xserver-properties.h> #ifdef LINUX_BACKEND #include "backend_joystick.h" @@ -63,40 +62,6 @@ char debug_level = 0; #endif - -/* - *************************************************************************** - * - * jstkConvertProc -- - * - * Convert valuators to X and Y. - * - *************************************************************************** - */ - -static Bool -jstkConvertProc(LocalDevicePtr local, - int first, - int num, - int v0, - int v1, - int v2, - int v3, - int v4, - int v5, - int* x, - int* y) -{ - if (first != 0 || num != 2) - return FALSE; - - *x = v0; - *y = v1; - - return TRUE; -} - - /* *************************************************************************** * @@ -147,21 +112,21 @@ jstkOpenDevice(JoystickDevPtr priv, BOOL probe) */ static void -jstkReadProc(LocalDevicePtr local) +jstkReadProc(InputInfoPtr pInfo) { JOYSTICKEVENT event; int number; int i, r; - JoystickDevPtr priv = local->private; + JoystickDevPtr priv = pInfo->private; do { if ((priv->read_proc == NULL) || ((r=priv->read_proc(priv, &event, &number))==0)) { xf86Msg(X_WARNING, "JOYSTICK: Read failed. Deactivating device.\n"); - if (local->fd >= 0) - RemoveEnabledDevice(local->fd); + if (pInfo->fd >= 0) + RemoveEnabledDevice(pInfo->fd); return; } @@ -174,7 +139,7 @@ jstkReadProc(LocalDevicePtr local) switch (priv->button[number].mapping) { case JSTK_MAPPING_BUTTON: if (priv->mouse_enabled == TRUE) { - xf86PostButtonEvent(local->dev, 0, + xf86PostButtonEvent(pInfo->dev, 0, priv->button[number].buttonnumber, priv->button[number].pressed, 0, 0); } @@ -187,7 +152,7 @@ jstkReadProc(LocalDevicePtr local) if (priv->button[number].pressed == 0) priv->button[number].currentspeed = 1.0; else if (priv->mouse_enabled == TRUE) - jstkStartButtonAxisTimer(local, number); + jstkStartButtonAxisTimer(pInfo, number); break; case JSTK_MAPPING_KEY: @@ -258,7 +223,7 @@ jstkReadProc(LocalDevicePtr local) priv->axis[number].mapping)); if (priv->axis[number].valuator != -1) - xf86PostMotionEvent(local->dev, 1, priv->axis[number].valuator, + xf86PostMotionEvent(pInfo->dev, 1, priv->axis[number].valuator, 1, priv->axis[number].value); switch (priv->axis[number].mapping) { @@ -272,12 +237,12 @@ jstkReadProc(LocalDevicePtr local) if (priv->axis[number].value == 0) priv->axis[number].currentspeed = 1.0; if (priv->mouse_enabled == TRUE) - jstkStartAxisTimer(local, number); + jstkStartAxisTimer(pInfo, number); break; case JSTK_TYPE_ABSOLUTE: if (priv->mouse_enabled == TRUE) - jstkHandleAbsoluteAxis(local, number); + jstkHandleAbsoluteAxis(pInfo, number); break; default: break; @@ -286,9 +251,9 @@ jstkReadProc(LocalDevicePtr local) case JSTK_MAPPING_KEY: if (priv->keys_enabled == TRUE) { if (priv->axis[number].type == JSTK_TYPE_ACCELERATED) { - jstkHandlePWMAxis(local, number); + jstkHandlePWMAxis(pInfo, number); } else if (priv->axis[number].type == JSTK_TYPE_BYVALUE) { - jstkStartAxisTimer(local, number); + jstkStartAxisTimer(pInfo, number); } break; } @@ -327,12 +292,10 @@ jstkDeviceControlProc(DeviceIntPtr pJstk, int what) { int i; - LocalDevicePtr local = (LocalDevicePtr)pJstk->public.devicePrivate; - JoystickDevPtr priv = (JoystickDevPtr)XI_PRIVATE(pJstk); -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 + InputInfoPtr pInfo = (InputInfoPtr)pJstk->public.devicePrivate; + JoystickDevPtr priv = pInfo->private; Atom btn_labels[BUTTONMAP_SIZE+1] = {0}; /* TODO: fillme */ Atom axes_labels[MAXAXES] = {0}; /* TODO: fillme */ -#endif switch (what) { case DEVICE_INIT: { @@ -355,9 +318,7 @@ jstkDeviceControlProc(DeviceIntPtr pJstk, if (InitButtonClassDeviceStruct(pJstk, BUTTONMAP_SIZE, -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 btn_labels, -#endif buttonmap) == FALSE) { ErrorF("unable to allocate Button class device\n"); return !Success; @@ -373,71 +334,48 @@ jstkDeviceControlProc(DeviceIntPtr pJstk, priv->axis[i].valuator = m++; } - if (InitValuatorClassDeviceStruct(pJstk, - m, -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 - axes_labels, -#endif -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 3 - xf86GetMotionEvents, -#endif - local->history_size, + if (InitValuatorClassDeviceStruct(pJstk, m, axes_labels, + GetMotionHistorySize(), Relative) == FALSE) { ErrorF("unable to allocate Valuator class device\n"); return !Success; } else { InitValuatorAxisStruct(pJstk, 0, /* valuator num */ -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 XIGetKnownProperty(AXIS_LABEL_PROP_REL_X), -#endif 0, /* min val */ screenInfo.screens[0]->width, /* max val */ 1, /* resolution */ 0, /* min_res */ - 1); /* max_res */ + 1, /* max_res */ + Absolute); InitValuatorAxisStruct(pJstk, 1, /* valuator num */ -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y), -#endif 0, /* min val */ screenInfo.screens[0]->height, /* max val */ 1, /* resolution */ 0, /* min_res */ - 1); /* max_res */ + 1, /* max_res */ + Absolute); for (i=0; i<MAXAXES; i++) if (priv->axis[i].valuator != -1) { InitValuatorAxisStruct(pJstk, priv->axis[i].valuator, -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 axes_labels[i], -#endif -32768, /* min val */ 32767, /* max val */ 1, /* resolution */ 0, /* min_res */ - 1); /* max_res */ + 1, /* max_res */ + Absolute); } /* allocate the motion history buffer if needed */ - xf86MotionHistoryAllocate(local); + xf86MotionHistoryAllocate(pInfo); } - - if (priv->keyboard_device != NULL) - { - DBG(2, ErrorF("Activating keyboard device\n")); - xf86ActivateDevice(priv->keyboard_device); - priv->keyboard_device->dev->inited = - (priv->keyboard_device->device_control(priv->keyboard_device->dev, DEVICE_INIT) == Success); - xf86EnableDevice(priv->keyboard_device->dev); - DBG(2, ErrorF("Keyboard device activated\n")); - } - -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3 jstkInitProperties(pJstk, priv); -#endif break; } @@ -448,8 +386,8 @@ jstkDeviceControlProc(DeviceIntPtr pJstk, if (jstkOpenDevice(priv, FALSE) != -1) { pJstk->public.on = TRUE; - local->fd = priv->fd; - AddEnabledDevice(local->fd); + pInfo->fd = priv->fd; + AddEnabledDevice(pInfo->fd); } else return !Success; break; @@ -471,9 +409,9 @@ jstkDeviceControlProc(DeviceIntPtr pJstk, TimerCancel(priv->axis[i].timer); } - if (local->fd >= 0) - RemoveEnabledDevice(local->fd); - local->fd = -1; + if (pInfo->fd >= 0) + RemoveEnabledDevice(pInfo->fd); + pInfo->fd = -1; if (priv->close_proc) priv->close_proc(priv); pJstk->public.on = FALSE; @@ -487,19 +425,6 @@ jstkDeviceControlProc(DeviceIntPtr pJstk, return Success; } - - - -_X_EXPORT InputDriverRec JSTK_KEYBOARD = { - 1, - "joystick_keyboard", - NULL, - jstkKeyboardPreInit, - jstkKeyboardUnInit, - NULL, - 0 -}; - /* *************************************************************************** * @@ -507,41 +432,41 @@ _X_EXPORT InputDriverRec JSTK_KEYBOARD = { * * Called when a device will be instantiated * + * This is a tad complicated. NewInputDeviceRequest(), which we use to + * hotplug a keyboard device,. enables the device, so we need to make sure + * that all options for the dependent device are set correctly. + * + * This means that we parse the keyboard-specific options into the + * keyboard device's PreInit, and re-use the keyboard's priv field. + * *************************************************************************** */ -static InputInfoPtr -jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags) +static int +jstkCorePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) { - LocalDevicePtr local = NULL; + InputInfoPtr keyboard_device; JoystickDevPtr priv = NULL; char *s; int i, j; - local = xf86AllocateInput(drv, 0); - if (!local) { - goto SetupProc_fail; - } + s = xf86CheckStrOption(pInfo->options, "_source", ""); + if (strcmp(s, "_driver/joystick") == 0) + return jstkKeyboardPreInit(drv, pInfo, flags); + + pInfo->device_control = jstkDeviceControlProc; + pInfo->read_input = jstkReadProc; + pInfo->control_proc = NULL; + pInfo->switch_mode = NULL; + pInfo->fd = -1; + pInfo->dev = NULL; + pInfo->type_name = XI_JOYSTICK; + + keyboard_device = jstkKeyboardHotplug(pInfo, flags); + if (!keyboard_device) + return BadAlloc; - local->private = (JoystickDevPtr)xalloc(sizeof(JoystickDevRec)); - priv = (JoystickDevPtr)local->private; - - local->name = dev->identifier; - local->flags = XI86_POINTER_CAPABLE; - local->flags |= XI86_SEND_DRAG_EVENTS; - local->device_control = jstkDeviceControlProc; - local->read_input = jstkReadProc; - local->close_proc = NULL; - local->control_proc = NULL; - local->switch_mode = NULL; - local->conversion_proc = jstkConvertProc; - local->fd = -1; - local->dev = NULL; - local->private = priv; - local->type_name = XI_JOYSTICK; - local->history_size = 0; - local->always_core_feedback = NULL; - local->conf_idev = dev; + pInfo->private = priv = keyboard_device->private; priv->fd = -1; priv->open_proc = NULL; @@ -554,9 +479,7 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags) priv->mouse_enabled = TRUE; priv->keys_enabled = TRUE; priv->amplify = 1.0f; - priv->keyboard_device = NULL; - priv->repeat_delay = 0; - priv->repeat_interval = 0; + priv->keyboard_device = keyboard_device; priv->num_axes = MAXAXES; priv->num_buttons = MAXBUTTONS; @@ -614,81 +537,39 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags) priv->axis[5].type = JSTK_TYPE_ACCELERATED; priv->axis[5].mapping = JSTK_MAPPING_Y; - xf86CollectInputOptions(local, NULL, NULL); - xf86OptionListReport(local->options); - /* Joystick device is mandatory */ - priv->device = xf86SetStrOption(dev->commonOptions, "Device", NULL); + priv->device = xf86SetStrOption(pInfo->options, "Device", NULL); if (!priv->device) - priv->device = xf86SetStrOption(dev->commonOptions, "Path", NULL); + priv->device = xf86SetStrOption(pInfo->options, "Path", NULL); if (!priv->device) { - xf86Msg (X_ERROR, "%s: No Device specified.\n", local->name); + xf86Msg (X_ERROR, "%s: No Device specified.\n", pInfo->name); goto SetupProc_fail; } - xf86ProcessCommonOptions(local, local->options); - #if DEBUG - debug_level = xf86SetIntOption(dev->commonOptions, "DebugLevel", 0); + debug_level = xf86SetIntOption(pInfo->options, "DebugLevel", 0); if (debug_level > 0) { xf86Msg(X_CONFIG, "%s: debug level set to %d\n", - local->name, debug_level); + pInfo->name, debug_level); } #else - if (xf86SetIntOption(dev->commonOptions, "DebugLevel", 0) != 0) { + if (xf86SetIntOption(pInfo->options, "DebugLevel", 0) != 0) { xf86Msg(X_WARNING, "%s: DebugLevel: Compiled without debugging support!\n", - local->name); + pInfo->name); } #endif - /* Parse option for autorepeat */ - if ((s = xf86SetStrOption(dev->commonOptions, "AutoRepeat", NULL))) { - int delay, rate; - if (sscanf(s, "%d %d", &delay, &rate) != 2) { - xf86Msg(X_ERROR, "%s: \"%s\" is not a valid AutoRepeat value", - local->name, s); - } else { - priv->repeat_delay = delay; - if (rate != 0) - priv->repeat_interval = 1000/rate; - else priv->repeat_interval = 0; - DBG(1, xf86Msg(X_CONFIG, "Autorepeat set to delay=%d, interval=%d\n", - priv->repeat_delay,priv->repeat_interval)); - } - xfree(s); - } - - priv->rmlvo.rules = xf86SetStrOption(dev->commonOptions, "xkb_rules", NULL); - if (!priv->rmlvo.rules) - priv->rmlvo.rules = xf86SetStrOption(dev->commonOptions, "XkbRules", "evdev"); - - priv->rmlvo.model = xf86SetStrOption(dev->commonOptions, "xkb_model", NULL); - if (!priv->rmlvo.model) - priv->rmlvo.model = xf86SetStrOption(dev->commonOptions, "XkbModel", "evdev"); - - priv->rmlvo.layout = xf86SetStrOption(dev->commonOptions, "xkb_layout", NULL); - if (!priv->rmlvo.layout) - priv->rmlvo.layout = xf86SetStrOption(dev->commonOptions, "XkbLayout", "us"); - - priv->rmlvo.variant = xf86SetStrOption(dev->commonOptions, "xkb_variant", NULL); - if (!priv->rmlvo.variant) - priv->rmlvo.variant = xf86SetStrOption(dev->commonOptions, "XkbVariant", ""); - - priv->rmlvo.options = xf86SetStrOption(dev->commonOptions, "xkb_options", NULL); - if (!priv->rmlvo.options) - priv->rmlvo.options = xf86SetStrOption(dev->commonOptions, "XkbOptions", ""); - - priv->mouse_enabled = xf86SetBoolOption(dev->commonOptions, "StartMouseEnabled", TRUE); - priv->keys_enabled = xf86SetBoolOption(dev->commonOptions, "StartKeysEnabled", TRUE); + priv->mouse_enabled = xf86SetBoolOption(pInfo->options, "StartMouseEnabled", TRUE); + priv->keys_enabled = xf86SetBoolOption(pInfo->options, "StartKeysEnabled", TRUE); /* Process button mapping options */ for (i=0; i<MAXBUTTONS; i++) { char p[64]; sprintf(p,"MapButton%d",i+1); - s = xf86SetStrOption(dev->commonOptions, p, NULL); + s = xf86SetStrOption(pInfo->options, p, NULL); if (s != NULL) { - jstkParseButtonOption(s, priv, i, local->name); + jstkParseButtonOption(s, priv, i, pInfo->name); } DBG(1, xf86Msg(X_CONFIG, "Button %d mapped to %d\n", i+1, priv->button[i].mapping)); @@ -698,9 +579,9 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags) for (i=0; i<MAXAXES; i++) { char p[64]; sprintf(p,"MapAxis%d",i+1); - s = xf86SetStrOption(dev->commonOptions, p, NULL); + s = xf86SetStrOption(pInfo->options, p, NULL); if (s != NULL) { - jstkParseAxisOption(s, priv, &priv->axis[i], local->name); + jstkParseAxisOption(s, priv, &priv->axis[i], pInfo->name); } DBG(1, xf86Msg(X_CONFIG, "Axis %d type is %d, mapped to %d, amplify=%.3f\n", i+1, @@ -709,23 +590,17 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags) priv->axis[i].amplify)); } - /* return the LocalDevice */ - local->flags |= XI86_CONFIGURED; - - priv->keyboard_device = jstkKeyboardPreInit(&JSTK_KEYBOARD, dev, flags); - if (priv->keyboard_device) { - priv->keyboard_device->private = priv; - } - - return (local); + return Success; SetupProc_fail: - if (priv) - xfree(priv); - if (local) - local->private = NULL; - return NULL; -/* return (local); */ /* Makes X segfault on error */ + if (priv) { + free(priv); + if (keyboard_device) + keyboard_device->private = NULL; + } + if (pInfo) + pInfo->private = NULL; + return BadValue; } @@ -736,26 +611,39 @@ SetupProc_fail: * jstkCoreUnInit -- * * Called when a device is unplugged and needs to be removed + * This is a bit tricky, because the keyboard device and the main device + * share the same private data, which must be freed only once, which is done + * by the main device. + * * *************************************************************************** */ static void jstkCoreUnInit(InputDriverPtr drv, - LocalDevicePtr local, + InputInfoPtr pInfo, int flags) { - JoystickDevPtr device = (JoystickDevPtr) local->private; - - if (device->keyboard_device != NULL) - { - xf86DisableDevice(device->keyboard_device->dev, TRUE); - device->keyboard_device = NULL; + if (pInfo->private) { + JoystickDevPtr priv = (JoystickDevPtr) pInfo->private; + if (priv->keyboard_device == pInfo) { + /* this is the keyboard device */ + /* Unlink from private data to notify that the + * keyboard device is no more, but don't free */ + priv->keyboard_device = NULL; + } else { + /* freeing main device + if keyboard still exists, notify keyboard device that it's + private data is gone */ + if (priv->keyboard_device) + priv->keyboard_device->private = NULL; + + free (priv); + } } - xfree (device); - local->private = NULL; - xf86DeleteInput(local, 0); + pInfo->private = NULL; + xf86DeleteInput(pInfo, 0); } @@ -767,11 +655,9 @@ _X_EXPORT InputDriverRec JOYSTICK = { NULL, jstkCorePreInit, jstkCoreUnInit, - NULL, - 0 + NULL }; - /* *************************************************************************** * @@ -789,7 +675,6 @@ jstkDriverPlug(pointer module, int *errmin) { xf86AddInputDriver(&JOYSTICK, module, 0); - xf86AddInputDriver(&JSTK_KEYBOARD, module, 0); return module; } diff --git a/driver/xf86-input-joystick/src/jstk.h b/driver/xf86-input-joystick/src/jstk.h index 78a1f83cf..ed5e4a7ba 100644 --- a/driver/xf86-input-joystick/src/jstk.h +++ b/driver/xf86-input-joystick/src/jstk.h @@ -55,17 +55,6 @@ #define XI_JOYSTICK "JOYSTICK" #endif -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5 -typedef struct { - char *rules; - char *model; - char *layout; - char *variant; - char *options; -} XkbRMLVOSet; -#endif - - typedef enum _JOYSTICKEVENT { EVENT_NONE=0, @@ -117,7 +106,7 @@ typedef struct _JoystickDevRec { jstkReadDataProc read_proc; /* Callback for reading data from the backend */ void *devicedata; /* Extra platform device dependend data */ char *device; /* Name of the device */ - LocalDevicePtr keyboard_device; /* Slave device for keyboard events */ + InputInfoPtr keyboard_device; /* Slave device for keyboard events */ OsTimerPtr timer; /* Timer for axis movement */ Bool timerrunning; diff --git a/driver/xf86-input-joystick/src/jstk_axis.c b/driver/xf86-input-joystick/src/jstk_axis.c index b31412270..95ebfe974 100644 --- a/driver/xf86-input-joystick/src/jstk_axis.c +++ b/driver/xf86-input-joystick/src/jstk_axis.c @@ -27,6 +27,7 @@ #include "config.h" #endif +#include <xorg-server.h> #include <xf86Xinput.h> #include <xf86_OSproc.h> #include <math.h> @@ -55,7 +56,8 @@ jstkAxisTimer(OsTimerPtr timer, { #define NEXTTIMER 15 DeviceIntPtr device = (DeviceIntPtr)arg; - JoystickDevPtr priv = (JoystickDevPtr)XI_PRIVATE(device); + InputInfoPtr pInfo = device->public.devicePrivate; + JoystickDevPtr priv = pInfo->private; int sigstate, i; int nexttimer; @@ -266,7 +268,7 @@ jstkAxisTimer(OsTimerPtr timer, *********************************************************************** */ void -jstkStartAxisTimer(LocalDevicePtr device, int number) +jstkStartAxisTimer(InputInfoPtr device, int number) { int pixel; JoystickDevPtr priv = device->private; @@ -298,7 +300,7 @@ jstkStartAxisTimer(LocalDevicePtr device, int number) */ void -jstkStartButtonAxisTimer(LocalDevicePtr device, int number) +jstkStartButtonAxisTimer(InputInfoPtr device, int number) { int pixel; JoystickDevPtr priv = device->private; @@ -338,7 +340,7 @@ jstkStartButtonAxisTimer(LocalDevicePtr device, int number) *********************************************************************** */ void -jstkHandleAbsoluteAxis(LocalDevicePtr device, int number) +jstkHandleAbsoluteAxis(InputInfoPtr device, int number) { JoystickDevPtr priv = device->private; int i,x,y; @@ -406,7 +408,8 @@ jstkPWMAxisTimer(OsTimerPtr timer, pointer arg) { DeviceIntPtr device = (DeviceIntPtr)arg; - JoystickDevPtr priv = (JoystickDevPtr)XI_PRIVATE(device); + InputInfoPtr pInfo = device->public.devicePrivate; + JoystickDevPtr priv = pInfo->private; int sigstate, i; int nexttimer; @@ -535,7 +538,7 @@ jstkPWMAxisTimer(OsTimerPtr timer, *********************************************************************** */ void -jstkHandlePWMAxis(LocalDevicePtr device, int number) +jstkHandlePWMAxis(InputInfoPtr device, int number) { JoystickDevPtr priv = device->private; if (priv->axis[number].timerrunning) return; diff --git a/driver/xf86-input-joystick/src/jstk_axis.h b/driver/xf86-input-joystick/src/jstk_axis.h index 028c65fc0..0d672dbcf 100644 --- a/driver/xf86-input-joystick/src/jstk_axis.h +++ b/driver/xf86-input-joystick/src/jstk_axis.h @@ -24,9 +24,9 @@ #ifndef _XF86JSTK_AXIS_H_INCLUDED_ #define _XF86JSTK_AXIS_H_INCLUDED_ -void jstkStartAxisTimer(LocalDevicePtr device, int number); -void jstkStartButtonAxisTimer(LocalDevicePtr device, int number); -void jstkHandleAbsoluteAxis(LocalDevicePtr device, int number); -void jstkHandlePWMAxis(LocalDevicePtr device, int number); +void jstkStartAxisTimer(InputInfoPtr device, int number); +void jstkStartButtonAxisTimer(InputInfoPtr device, int number); +void jstkHandleAbsoluteAxis(InputInfoPtr device, int number); +void jstkHandlePWMAxis(InputInfoPtr device, int number); #endif diff --git a/driver/xf86-input-joystick/src/jstk_key.c b/driver/xf86-input-joystick/src/jstk_key.c index fb1f52e4a..3c471ce97 100644 --- a/driver/xf86-input-joystick/src/jstk_key.c +++ b/driver/xf86-input-joystick/src/jstk_key.c @@ -28,6 +28,7 @@ #endif +#include <xorg-server.h> #include <xf86.h> #include <xf86Xinput.h> #include <X11/extensions/XKBsrv.h> @@ -38,9 +39,7 @@ #include "jstk.h" #include "jstk_key.h" -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 5 #include <xkbsrv.h> -#endif #define MIN_KEYCODE 8 #define GLYPHS_PER_KEY 2 @@ -51,280 +50,6 @@ #define KanaMask Mod4Mask #define ScrollLockMask Mod5Mask - - -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5 -static KeySym map[] = { - /* 0x00 */ NoSymbol, NoSymbol, - /* 0x01 */ XK_Escape, NoSymbol, - /* 0x02 */ XK_1, XK_exclam, - /* 0x03 */ XK_2, XK_at, - /* 0x04 */ XK_3, XK_numbersign, - /* 0x05 */ XK_4, XK_dollar, - /* 0x06 */ XK_5, XK_percent, - /* 0x07 */ XK_6, XK_asciicircum, - /* 0x08 */ XK_7, XK_ampersand, - /* 0x09 */ XK_8, XK_asterisk, - /* 0x0a */ XK_9, XK_parenleft, - /* 0x0b */ XK_0, XK_parenright, - /* 0x0c */ XK_minus, XK_underscore, - /* 0x0d */ XK_equal, XK_plus, - /* 0x0e */ XK_BackSpace, NoSymbol, - /* 0x0f */ XK_Tab, XK_ISO_Left_Tab, - /* 0x10 */ XK_Q, NoSymbol, - /* 0x11 */ XK_W, NoSymbol, - /* 0x12 */ XK_E, NoSymbol, - /* 0x13 */ XK_R, NoSymbol, - /* 0x14 */ XK_T, NoSymbol, - /* 0x15 */ XK_Y, NoSymbol, - /* 0x16 */ XK_U, NoSymbol, - /* 0x17 */ XK_I, NoSymbol, - /* 0x18 */ XK_O, NoSymbol, - /* 0x19 */ XK_P, NoSymbol, - /* 0x1a */ XK_bracketleft, XK_braceleft, - /* 0x1b */ XK_bracketright,XK_braceright, - /* 0x1c */ XK_Return, NoSymbol, - /* 0x1d */ XK_Control_L, NoSymbol, - /* 0x1e */ XK_A, NoSymbol, - /* 0x1f */ XK_S, NoSymbol, - /* 0x20 */ XK_D, NoSymbol, - /* 0x21 */ XK_F, NoSymbol, - /* 0x22 */ XK_G, NoSymbol, - /* 0x23 */ XK_H, NoSymbol, - /* 0x24 */ XK_J, NoSymbol, - /* 0x25 */ XK_K, NoSymbol, - /* 0x26 */ XK_L, NoSymbol, - /* 0x27 */ XK_semicolon, XK_colon, - /* 0x28 */ XK_quoteright, XK_quotedbl, - /* 0x29 */ XK_quoteleft, XK_asciitilde, - /* 0x2a */ XK_Shift_L, NoSymbol, - /* 0x2b */ XK_backslash, XK_bar, - /* 0x2c */ XK_Z, NoSymbol, - /* 0x2d */ XK_X, NoSymbol, - /* 0x2e */ XK_C, NoSymbol, - /* 0x2f */ XK_V, NoSymbol, - /* 0x30 */ XK_B, NoSymbol, - /* 0x31 */ XK_N, NoSymbol, - /* 0x32 */ XK_M, NoSymbol, - /* 0x33 */ XK_comma, XK_less, - /* 0x34 */ XK_period, XK_greater, - /* 0x35 */ XK_slash, XK_question, - /* 0x36 */ XK_Shift_R, NoSymbol, - /* 0x37 */ XK_KP_Multiply, NoSymbol, - /* 0x38 */ XK_Alt_L, XK_Meta_L, - /* 0x39 */ XK_space, NoSymbol, - /* 0x3a */ XK_Caps_Lock, NoSymbol, - /* 0x3b */ XK_F1, NoSymbol, - /* 0x3c */ XK_F2, NoSymbol, - /* 0x3d */ XK_F3, NoSymbol, - /* 0x3e */ XK_F4, NoSymbol, - /* 0x3f */ XK_F5, NoSymbol, - /* 0x40 */ XK_F6, NoSymbol, - /* 0x41 */ XK_F7, NoSymbol, - /* 0x42 */ XK_F8, NoSymbol, - /* 0x43 */ XK_F9, NoSymbol, - /* 0x44 */ XK_F10, NoSymbol, - /* 0x45 */ XK_Num_Lock, NoSymbol, - /* 0x46 */ XK_Scroll_Lock, NoSymbol, - /* These KP keys should have the KP_7 keysyms in the numlock - * modifer... ? */ - /* 0x47 */ XK_KP_Home, XK_KP_7, - /* 0x48 */ XK_KP_Up, XK_KP_8, - /* 0x49 */ XK_KP_Prior, XK_KP_9, - /* 0x4a */ XK_KP_Subtract, NoSymbol, - /* 0x4b */ XK_KP_Left, XK_KP_4, - /* 0x4c */ XK_KP_Begin, XK_KP_5, - /* 0x4d */ XK_KP_Right, XK_KP_6, - /* 0x4e */ XK_KP_Add, NoSymbol, - /* 0x4f */ XK_KP_End, XK_KP_1, - /* 0x50 */ XK_KP_Down, XK_KP_2, - /* 0x51 */ XK_KP_Next, XK_KP_3, - /* 0x52 */ XK_KP_Insert, XK_KP_0, - /* 0x53 */ XK_KP_Delete, XK_KP_Decimal, - /* 0x54 */ NoSymbol, NoSymbol, - /* 0x55 */ XK_F13, NoSymbol, - /* 0x56 */ XK_less, XK_greater, - /* 0x57 */ XK_F11, NoSymbol, - /* 0x58 */ XK_F12, NoSymbol, - /* 0x59 */ XK_F14, NoSymbol, - /* 0x5a */ XK_F15, NoSymbol, - /* 0x5b */ XK_F16, NoSymbol, - /* 0x5c */ XK_F17, NoSymbol, - /* 0x5d */ XK_F18, NoSymbol, - /* 0x5e */ XK_F19, NoSymbol, - /* 0x5f */ XK_F20, NoSymbol, - /* 0x60 */ XK_KP_Enter, NoSymbol, - /* 0x61 */ XK_Control_R, NoSymbol, - /* 0x62 */ XK_KP_Divide, NoSymbol, - /* 0x63 */ XK_Print, XK_Sys_Req, - /* 0x64 */ XK_Alt_R, XK_Meta_R, - /* 0x65 */ NoSymbol, NoSymbol, /* KEY_LINEFEED */ - /* 0x66 */ XK_Home, NoSymbol, - /* 0x67 */ XK_Up, NoSymbol, - /* 0x68 */ XK_Prior, NoSymbol, - /* 0x69 */ XK_Left, NoSymbol, - /* 0x6a */ XK_Right, NoSymbol, - /* 0x6b */ XK_End, NoSymbol, - /* 0x6c */ XK_Down, NoSymbol, - /* 0x6d */ XK_Next, NoSymbol, - /* 0x6e */ XK_Insert, NoSymbol, - /* 0x6f */ XK_Delete, NoSymbol, - /* 0x70 */ NoSymbol, NoSymbol, /* KEY_MACRO */ - /* 0x71 */ NoSymbol, NoSymbol, - /* 0x72 */ NoSymbol, NoSymbol, - /* 0x73 */ NoSymbol, NoSymbol, - /* 0x74 */ NoSymbol, NoSymbol, - /* 0x75 */ XK_KP_Equal, NoSymbol, - /* 0x76 */ NoSymbol, NoSymbol, - /* 0x77 */ NoSymbol, NoSymbol, - /* 0x78 */ XK_F21, NoSymbol, - /* 0x79 */ XK_F22, NoSymbol, - /* 0x7a */ XK_F23, NoSymbol, - /* 0x7b */ XK_F24, NoSymbol, - /* 0x7c */ XK_KP_Separator, NoSymbol, - /* 0x7d */ XK_Meta_L, NoSymbol, - /* 0x7e */ XK_Meta_R, NoSymbol, - /* 0x7f */ XK_Multi_key, NoSymbol, - /* 0x80 */ NoSymbol, NoSymbol, - /* 0x81 */ NoSymbol, NoSymbol, - /* 0x82 */ NoSymbol, NoSymbol, - /* 0x83 */ NoSymbol, NoSymbol, - /* 0x84 */ NoSymbol, NoSymbol, - /* 0x85 */ NoSymbol, NoSymbol, - /* 0x86 */ NoSymbol, NoSymbol, - /* 0x87 */ NoSymbol, NoSymbol, - /* 0x88 */ NoSymbol, NoSymbol, - /* 0x89 */ NoSymbol, NoSymbol, - /* 0x8a */ NoSymbol, NoSymbol, - /* 0x8b */ NoSymbol, NoSymbol, - /* 0x8c */ NoSymbol, NoSymbol, - /* 0x8d */ NoSymbol, NoSymbol, - /* 0x8e */ NoSymbol, NoSymbol, - /* 0x8f */ NoSymbol, NoSymbol, - /* 0x90 */ NoSymbol, NoSymbol, - /* 0x91 */ NoSymbol, NoSymbol, - /* 0x92 */ NoSymbol, NoSymbol, - /* 0x93 */ NoSymbol, NoSymbol, - /* 0x94 */ NoSymbol, NoSymbol, - /* 0x95 */ NoSymbol, NoSymbol, - /* 0x96 */ NoSymbol, NoSymbol, - /* 0x97 */ NoSymbol, NoSymbol, - /* 0x98 */ NoSymbol, NoSymbol, - /* 0x99 */ NoSymbol, NoSymbol, - /* 0x9a */ NoSymbol, NoSymbol, - /* 0x9b */ NoSymbol, NoSymbol, - /* 0x9c */ NoSymbol, NoSymbol, - /* 0x9d */ NoSymbol, NoSymbol, - /* 0x9e */ NoSymbol, NoSymbol, - /* 0x9f */ NoSymbol, NoSymbol, - /* 0xa0 */ NoSymbol, NoSymbol, - /* 0xa1 */ NoSymbol, NoSymbol, - /* 0xa2 */ NoSymbol, NoSymbol, - /* 0xa3 */ NoSymbol, NoSymbol, - /* 0xa4 */ NoSymbol, NoSymbol, - /* 0xa5 */ NoSymbol, NoSymbol, - /* 0xa6 */ NoSymbol, NoSymbol, - /* 0xa7 */ NoSymbol, NoSymbol, - /* 0xa8 */ NoSymbol, NoSymbol, - /* 0xa9 */ NoSymbol, NoSymbol, - /* 0xaa */ NoSymbol, NoSymbol, - /* 0xab */ NoSymbol, NoSymbol, - /* 0xac */ NoSymbol, NoSymbol, - /* 0xad */ NoSymbol, NoSymbol, - /* 0xae */ NoSymbol, NoSymbol, - /* 0xaf */ NoSymbol, NoSymbol, - /* 0xb0 */ NoSymbol, NoSymbol, - /* 0xb1 */ NoSymbol, NoSymbol, - /* 0xb2 */ NoSymbol, NoSymbol, - /* 0xb3 */ NoSymbol, NoSymbol, - /* 0xb4 */ NoSymbol, NoSymbol, - /* 0xb5 */ NoSymbol, NoSymbol, - /* 0xb6 */ NoSymbol, NoSymbol, - /* 0xb7 */ NoSymbol, NoSymbol, - /* 0xb8 */ NoSymbol, NoSymbol, - /* 0xb9 */ NoSymbol, NoSymbol, - /* 0xba */ NoSymbol, NoSymbol, - /* 0xbb */ NoSymbol, NoSymbol, - /* 0xbc */ NoSymbol, NoSymbol, - /* 0xbd */ NoSymbol, NoSymbol, - /* 0xbe */ NoSymbol, NoSymbol, - /* 0xbf */ NoSymbol, NoSymbol, - /* 0xc0 */ NoSymbol, NoSymbol, - /* 0xc1 */ NoSymbol, NoSymbol, - /* 0xc2 */ NoSymbol, NoSymbol, - /* 0xc3 */ NoSymbol, NoSymbol, - /* 0xc4 */ NoSymbol, NoSymbol, - /* 0xc5 */ NoSymbol, NoSymbol, - /* 0xc6 */ NoSymbol, NoSymbol, - /* 0xc7 */ NoSymbol, NoSymbol, - /* 0xc8 */ NoSymbol, NoSymbol, - /* 0xc9 */ NoSymbol, NoSymbol, - /* 0xca */ NoSymbol, NoSymbol, - /* 0xcb */ NoSymbol, NoSymbol, - /* 0xcc */ NoSymbol, NoSymbol, - /* 0xcd */ NoSymbol, NoSymbol, - /* 0xce */ NoSymbol, NoSymbol, - /* 0xcf */ NoSymbol, NoSymbol, - /* 0xd0 */ NoSymbol, NoSymbol, - /* 0xd1 */ NoSymbol, NoSymbol, - /* 0xd2 */ NoSymbol, NoSymbol, - /* 0xd3 */ NoSymbol, NoSymbol, - /* 0xd4 */ NoSymbol, NoSymbol, - /* 0xd5 */ NoSymbol, NoSymbol, - /* 0xd6 */ NoSymbol, NoSymbol, - /* 0xd7 */ NoSymbol, NoSymbol, - /* 0xd8 */ NoSymbol, NoSymbol, - /* 0xd9 */ NoSymbol, NoSymbol, - /* 0xda */ NoSymbol, NoSymbol, - /* 0xdb */ NoSymbol, NoSymbol, - /* 0xdc */ NoSymbol, NoSymbol, - /* 0xdd */ NoSymbol, NoSymbol, - /* 0xde */ NoSymbol, NoSymbol, - /* 0xdf */ NoSymbol, NoSymbol, - /* 0xe0 */ NoSymbol, NoSymbol, - /* 0xe1 */ NoSymbol, NoSymbol, - /* 0xe2 */ NoSymbol, NoSymbol, - /* 0xe3 */ NoSymbol, NoSymbol, - /* 0xe4 */ NoSymbol, NoSymbol, - /* 0xe5 */ NoSymbol, NoSymbol, - /* 0xe6 */ NoSymbol, NoSymbol, - /* 0xe7 */ NoSymbol, NoSymbol, - /* 0xe8 */ NoSymbol, NoSymbol, - /* 0xe9 */ NoSymbol, NoSymbol, - /* 0xea */ NoSymbol, NoSymbol, - /* 0xeb */ NoSymbol, NoSymbol, - /* 0xec */ NoSymbol, NoSymbol, - /* 0xed */ NoSymbol, NoSymbol, - /* 0xee */ NoSymbol, NoSymbol, - /* 0xef */ NoSymbol, NoSymbol, - /* 0xf0 */ NoSymbol, NoSymbol, - /* 0xf1 */ NoSymbol, NoSymbol, - /* 0xf2 */ NoSymbol, NoSymbol, - /* 0xf3 */ NoSymbol, NoSymbol, - /* 0xf4 */ NoSymbol, NoSymbol, - /* 0xf5 */ NoSymbol, NoSymbol, - /* 0xf6 */ NoSymbol, NoSymbol, - /* 0xf7 */ NoSymbol, NoSymbol, -}; - -static struct { KeySym keysym; CARD8 mask; } modifiers[] = { - { XK_Shift_L, ShiftMask }, - { XK_Shift_R, ShiftMask }, - { XK_Control_L, ControlMask }, - { XK_Control_R, ControlMask }, - { XK_Caps_Lock, LockMask }, - { XK_Alt_L, AltMask }, - { XK_Alt_R, AltMask }, - { XK_Meta_L, Mod4Mask }, - { XK_Meta_R, Mod4Mask }, - { XK_Num_Lock, NumLockMask }, - { XK_Scroll_Lock, ScrollLockMask }, - { XK_Mode_switch, AltLangMask } -}; -#endif - - - static void jstkKbdCtrl(DeviceIntPtr device, KeybdCtrl *ctrl) { @@ -346,46 +71,11 @@ jstkInitKeys(DeviceIntPtr pJstk, JoystickDevPtr priv) XkbSrvInfoPtr xkbi; XkbControlsPtr ctrls; -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 5 + if (!InitKeyboardDeviceStruct(pJstk, &priv->rmlvo, NULL, jstkKbdCtrl)) { - if (!InitKeyboardDeviceStruct(pJstk, &priv->rmlvo, NULL, jstkKbdCtrl)) - { - ErrorF("unable to init keyboard device\n"); - return !Success; - } - } -#else - KeySymsRec keySyms; - CARD8 modMap[MAP_LENGTH]; - KeySym sym; - int i, j; - XkbComponentNamesRec xkbnames; - - memset(modMap, 0, sizeof(modMap)); - memset(&xkbnames, 0, sizeof(xkbnames)); - - keySyms.map = map; - keySyms.mapWidth = GLYPHS_PER_KEY; - keySyms.minKeyCode = MIN_KEYCODE; - keySyms.maxKeyCode = MIN_KEYCODE + (sizeof(map) / sizeof(map[0])) / GLYPHS_PER_KEY - 1; - - for (i = 0; i < (sizeof(map) / sizeof(map[0])) / GLYPHS_PER_KEY; i++) { - sym = map[i * GLYPHS_PER_KEY]; - for (j = 0; j < sizeof(modifiers)/sizeof(modifiers[0]); j++) { - if (modifiers[j].keysym == sym) - modMap[i + MIN_KEYCODE] = modifiers[j].mask; - } - } - - ErrorF("%s, %s, %s, %s, %s\n", priv->rmlvo.rules, priv->rmlvo.model, priv->rmlvo.layout, priv->rmlvo.variant, priv->rmlvo.options); - XkbSetRulesDflts(priv->rmlvo.rules, priv->rmlvo.model, - priv->rmlvo.layout, priv->rmlvo.variant, - priv->rmlvo.options); - if (!XkbInitKeyboardDeviceStruct(pJstk, &xkbnames, - &keySyms, modMap, NULL, - jstkKbdCtrl)) + ErrorF("unable to init keyboard device\n"); return !Success; -#endif + } /* Set Autorepeat and Delay */ if ((priv->repeat_delay || priv->repeat_interval) && @@ -417,7 +107,7 @@ jstkInitKeys(DeviceIntPtr pJstk, JoystickDevPtr priv) *************************************************************************** */ void -jstkGenerateKeys(LocalDevicePtr device, KEYSCANCODES keys, char pressed) +jstkGenerateKeys(InputInfoPtr device, KEYSCANCODES keys, char pressed) { int i; unsigned int k; @@ -447,11 +137,12 @@ jstkGenerateKeys(LocalDevicePtr device, KEYSCANCODES keys, char pressed) * *************************************************************************** */ -static Bool +Bool jstkKeyboardDeviceControlProc(DeviceIntPtr dev, int what) { - JoystickDevPtr priv = (JoystickDevPtr)XI_PRIVATE(dev); + InputInfoPtr pInfo = dev->public.devicePrivate; + JoystickDevPtr priv = pInfo->private; if (!priv) { DBG(2, ErrorF("jstkKeyboardDeviceControlProc: priv == NULL\n")); return !Success; @@ -489,65 +180,116 @@ jstkKeyboardDeviceControlProc(DeviceIntPtr dev, * * jstkKeyboardPreInit -- * - * Called manually to create a keyboard device for the joystick + * See comment in jstkCorePreInit() for details. * *************************************************************************** */ + +int jstkKeyboardPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) +{ + JoystickDevPtr priv = NULL; + char *s; + + pInfo->private = priv = calloc(1, sizeof(JoystickDevRec)); + if (!priv) + return BadAlloc; + + pInfo->device_control = jstkKeyboardDeviceControlProc; + pInfo->read_input = NULL; + pInfo->control_proc = NULL; + pInfo->switch_mode = NULL; + pInfo->fd = -1; + pInfo->type_name = XI_JOYSTICK; + + /* parse keyboard-related options */ + priv->repeat_delay = 0; + priv->repeat_interval = 0; + + /* Parse option for autorepeat */ + if ((s = xf86SetStrOption(pInfo->options, "AutoRepeat", NULL))) { + int delay, rate; + if (sscanf(s, "%d %d", &delay, &rate) != 2) { + xf86Msg(X_ERROR, "%s: \"%s\" is not a valid AutoRepeat value", + pInfo->name, s); + } else { + priv->repeat_delay = delay; + if (rate != 0) + priv->repeat_interval = 1000/rate; + else priv->repeat_interval = 0; + DBG(1, xf86Msg(X_CONFIG, "Autorepeat set to delay=%d, interval=%d\n", + priv->repeat_delay,priv->repeat_interval)); + } + free(s); + } + + priv->rmlvo.rules = xf86SetStrOption(pInfo->options, "xkb_rules", NULL); + if (!priv->rmlvo.rules) + priv->rmlvo.rules = xf86SetStrOption(pInfo->options, "XkbRules", "evdev"); + + priv->rmlvo.model = xf86SetStrOption(pInfo->options, "xkb_model", NULL); + if (!priv->rmlvo.model) + priv->rmlvo.model = xf86SetStrOption(pInfo->options, "XkbModel", "evdev"); + + priv->rmlvo.layout = xf86SetStrOption(pInfo->options, "xkb_layout", NULL); + if (!priv->rmlvo.layout) + priv->rmlvo.layout = xf86SetStrOption(pInfo->options, "XkbLayout", "us"); + + priv->rmlvo.variant = xf86SetStrOption(pInfo->options, "xkb_variant", NULL); + if (!priv->rmlvo.variant) + priv->rmlvo.variant = xf86SetStrOption(pInfo->options, "XkbVariant", ""); + + priv->rmlvo.options = xf86SetStrOption(pInfo->options, "xkb_options", NULL); + if (!priv->rmlvo.options) + priv->rmlvo.options = xf86SetStrOption(pInfo->options, "XkbOptions", ""); + + return Success; +} + InputInfoPtr -jstkKeyboardPreInit(InputDriverPtr drv, IDevPtr _dev, int flags) +jstkKeyboardHotplug(InputInfoPtr pInfo, int flags) { - LocalDevicePtr local = NULL; - IDevPtr dev = NULL; + int rc; char name[512] = {0}; + InputAttributes *attrs = NULL; + InputOption *options; + InputOption *iopts = NULL, *tmp; + DeviceIntPtr dev; + + /* duplicate option list, append to name */ + options = xf86OptionListDuplicate(pInfo->options); + strcpy(name, pInfo->name); + strcat(name, " (keys)"); + options = xf86ReplaceStrOption(options, "Name", name); + options = xf86ReplaceStrOption(options, "_source", "_driver/joystick"); + + while(options) + { + tmp = calloc(1, sizeof(InputOption)); - local = xf86AllocateInput(drv, 0); - if (!local) { - goto SetupProc_fail; + tmp->key = xf86OptionName(options); + tmp->value = xf86OptionValue(options); + tmp->next = iopts; + iopts = tmp; + options = xf86NextOption(options); } - dev = xcalloc(sizeof(IDevRec), 1); - strcpy(name, _dev->identifier); - strcat(name, " (keys)"); - dev->identifier = xstrdup(name); - dev->driver = xstrdup(_dev->driver); - dev->commonOptions = (pointer)xf86optionListDup(_dev->commonOptions); - dev->extraOptions = (pointer)xf86optionListDup(_dev->extraOptions); - - local->name = dev->identifier; - local->flags = XI86_KEYBOARD_CAPABLE; - local->device_control = jstkKeyboardDeviceControlProc; - local->read_input = NULL; - local->close_proc = NULL; - local->control_proc = NULL; - local->switch_mode = NULL; - local->conversion_proc = NULL; - local->fd = -1; - local->dev = NULL; - local->private = NULL; - local->type_name = XI_JOYSTICK; - local->history_size = 0; - local->always_core_feedback = 0; - local->conf_idev = dev; - - xf86CollectInputOptions(local, NULL, NULL); - xf86OptionListReport(local->options); - xf86ProcessCommonOptions(local, local->options); - - - /* return the LocalDevice */ - local->flags |= XI86_CONFIGURED; - - return (local); - -SetupProc_fail: - if (local) - local->private = NULL; - if (dev) { - if (dev->identifier) xfree(dev->identifier); - if (dev->driver) xfree(dev->driver); - xfree(dev); + /* duplicate attribute list */ + attrs = DuplicateInputAttributes(pInfo->attrs); + + rc = NewInputDeviceRequest(iopts, attrs, &dev); + + while(iopts) + { + tmp = iopts->next; + free(iopts->key); + free(iopts->value); + free(iopts); + iopts = tmp; } - return NULL; + + FreeInputAttributes(attrs); + + return (rc == Success) ? dev->public.devicePrivate : NULL; } @@ -562,15 +304,15 @@ SetupProc_fail: */ void jstkKeyboardUnInit(InputDriverPtr drv, - LocalDevicePtr local, + InputInfoPtr pInfo, int flags) { - JoystickDevPtr device = (JoystickDevPtr) local->private; + JoystickDevPtr device = (JoystickDevPtr) pInfo->private; DBG(2, ErrorF("jstkKeyboardUnInit.\n")); device->keyboard_device = NULL; - local->private = NULL; + pInfo->private = NULL; - xf86DeleteInput(local, 0); + xf86DeleteInput(pInfo, 0); } diff --git a/driver/xf86-input-joystick/src/jstk_key.h b/driver/xf86-input-joystick/src/jstk_key.h index 1791c3518..fc0c7821a 100644 --- a/driver/xf86-input-joystick/src/jstk_key.h +++ b/driver/xf86-input-joystick/src/jstk_key.h @@ -25,9 +25,10 @@ #ifndef __JSTK_KEY_H_INCLUDED__ #define __JSTK_KEY_H_INCLUDED__ -void jstkGenerateKeys(LocalDevicePtr device, KEYSCANCODES keys, char pressed); - -InputInfoPtr jstkKeyboardPreInit(InputDriverPtr drv, IDevPtr dev, int flags); -void jstkKeyboardUnInit(InputDriverPtr drv, LocalDevicePtr local, int flags); +void jstkGenerateKeys(InputInfoPtr device, KEYSCANCODES keys, char pressed); +int jstkKeyboardPreInit(InputDriverPtr pInfo, InputInfoPtr dev, int flags); +void jstkKeyboardUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags); +Bool jstkKeyboardDeviceControlProc(DeviceIntPtr dev, int what); +InputInfoPtr jstkKeyboardHotplug(InputInfoPtr dev, int flags); #endif diff --git a/driver/xf86-input-joystick/src/jstk_options.c b/driver/xf86-input-joystick/src/jstk_options.c index 42293a7a1..65f25f804 100644 --- a/driver/xf86-input-joystick/src/jstk_options.c +++ b/driver/xf86-input-joystick/src/jstk_options.c @@ -26,6 +26,7 @@ #include "config.h" #endif +#include <xorg-server.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -154,7 +155,7 @@ jstkParseButtonOption(const char* org, xf86Msg(X_WARNING, "%s: error parsing button parameter.\n", name); } - xfree(param); + free(param); } @@ -292,5 +293,5 @@ jstkParseAxisOption(const char* org, }else xf86Msg(X_WARNING, "%s: error parsing deadzone.\n", name); } - xfree(param); + free(param); } diff --git a/driver/xf86-input-joystick/src/jstk_properties.c b/driver/xf86-input-joystick/src/jstk_properties.c index 1ceeb061b..413822d10 100644 --- a/driver/xf86-input-joystick/src/jstk_properties.c +++ b/driver/xf86-input-joystick/src/jstk_properties.c @@ -25,12 +25,9 @@ #include "config.h" #endif +#include <xorg-server.h> #include <xf86Module.h> -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3 - - - #include <misc.h> #include <xf86.h> #include <X11/Xatom.h> @@ -456,5 +453,3 @@ jstkInitProperties(DeviceIntPtr pJstk, JoystickDevPtr priv) return TRUE; } - -#endif |