diff options
author | Sascha Hlusiak <saschahlusiak@arcor.de> | 2008-08-23 22:02:54 +0200 |
---|---|---|
committer | Sascha Hlusiak <saschahlusiak@arcor.de> | 2008-08-23 22:02:54 +0200 |
commit | e64b4ebcd121a9080d1da39e5037182df7edfdbb (patch) | |
tree | 9eb86b746887e8651db4bbe6b450da9f4c66ba8e | |
parent | 5e91f0bdd4fa529d1d5f0f8ffc87aaf9fbec2a88 (diff) |
Add support for device properties.
Only exported property for now is DebugLevel.
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/jstk.c | 7 | ||||
-rw-r--r-- | src/jstk.h | 2 | ||||
-rw-r--r-- | src/jstk_properties.c | 93 | ||||
-rw-r--r-- | src/jstk_properties.h | 31 |
5 files changed, 132 insertions, 2 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index cdb96b6..66b6471 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -32,6 +32,7 @@ jstk_axis.c jstk_axis.h \ jstk_key.c jstk_key.h \ jstk_options.c jstk_options.h \ + jstk_properties.c jstk_properties.h \ StrKeysym.c StrKeysym.h ks_tables.h BSD_SRCS = backend_bsd.c backend_bsd.h @@ -42,6 +42,7 @@ #include "jstk_axis.h" #include "jstk_key.h" #include "jstk_options.h" +#include "jstk_properties.h" #ifdef LINUX_BACKEND #include "backend_joystick.h" @@ -55,7 +56,7 @@ #if DEBUG - int debug_level = 0; + char debug_level = 0; #endif @@ -384,6 +385,10 @@ jstkDeviceControlProc(DeviceIntPtr pJstk, /* allocate the motion history buffer if needed */ xf86MotionHistoryAllocate(local); } +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3 + jstkInitProperties(pJstk, priv); +#endif + break; } @@ -39,7 +39,7 @@ #endif #if DEBUG - extern int debug_level; + extern char debug_level; #define DBG(lvl, f) {if ((lvl) <= debug_level) f;} #else #define DBG(lvl, f) diff --git a/src/jstk_properties.c b/src/jstk_properties.c new file mode 100644 index 0000000..5cc223b --- /dev/null +++ b/src/jstk_properties.c @@ -0,0 +1,93 @@ +/* + * Copyright 2007-2008 by Sascha Hlusiak. <saschahlusiak@freedesktop.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * 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 + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Sascha Hlusiak makes 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, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SASCHA HLUSIAK 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 + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <xf86Module.h> + +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3 + + +#include <misc.h> +#include <xf86.h> +#include <X11/Xatom.h> +#include <xf86Xinput.h> +#include <exevents.h> + +#include "jstk.h" +#include "jstk_properties.h" + + + +#define JSTK_PROP_DEBUGLEVEL "Debug Level" +static Atom prop_debuglevel = 0; + + + +static Bool +jstkSetProperty(DeviceIntPtr pJstk, Atom atom, XIPropertyValuePtr val) +{ + InputInfoPtr pInfo = pJstk->public.devicePrivate; + JoystickDevPtr priv = pInfo->private; + + if (atom == prop_debuglevel) + { + debug_level = *((INT8*)val->data); + + } + + + /* property not handled, report success */ + return TRUE; +} + +static Bool +jstkGetProperty(DeviceIntPtr pJstk, Atom property) +{ + return TRUE; +} + + +Bool +jstkInitProperties(DeviceIntPtr pJstk, JoystickDevPtr priv) +{ + int rc = TRUE; + + XIRegisterPropertyHandler(pJstk, jstkSetProperty, jstkGetProperty); + + /* Debug Level */ + prop_debuglevel = MakeAtom(JSTK_PROP_DEBUGLEVEL, strlen(JSTK_PROP_DEBUGLEVEL), TRUE); + rc = XIChangeDeviceProperty(pJstk, prop_debuglevel, XA_INTEGER, 8, + PropModeReplace, 1, + &debug_level, + FALSE, FALSE, FALSE); + if (rc != Success) + return; + + + return TRUE; +} + +#endif diff --git a/src/jstk_properties.h b/src/jstk_properties.h new file mode 100644 index 0000000..fe6290f --- /dev/null +++ b/src/jstk_properties.h @@ -0,0 +1,31 @@ +/* + * Copyright 2007-2008 by Sascha Hlusiak. <saschahlusiak@freedesktop.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * 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 + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Sascha Hlusiak makes 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, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL SASCHA HLUSIAK 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 + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifndef __JSTK_PROPERTIES_INCLUDED__ +#define __JSTK_PROPERTIES_INCLUDED__ + +#include "jstk.h" + +Bool jstkInitProperties(DeviceIntPtr pJstk, JoystickDevPtr priv); + +#endif |