summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2010-10-19 13:37:46 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2010-10-22 11:02:48 +1000
commit675f4a8525d29ebad783351e17be785b2f32b2e8 (patch)
tree4a1aba9abeb869d0eedb1bbaf01f14c59bf778a0 /include
parentfc48a8f9f5f66e591b3e39211d44ce68267303f8 (diff)
Abstract valuator masks through a set of APIs.
This commit introduces an abstraction API for handling masked valuators. The intent is that drivers just allocate a mask, set the data and pass the mask to the server. The actual storage type of the mask is hidden from the drivers. The new calls for drivers are: valuator_mask_new() /* to allocate a valuator mask */ valuator_mask_zero() /* to reset a mask to zero */ valuator_mask_set() /* to set a valuator value */ The new interface to the server is xf86PostMotionEventM() xf86PostButtonEventM() xf86PostKeyboardEventM() xf86PostProximityEventM() all taking a mask instead of the valuator array. The ValuatorMask is currently defined for MAX_VALUATORS fixed size due to memory allocation restrictions in SIGIO handlers. For easier review, a lot of the code still uses separate valuator arrays. This will be fixed in a later patch. This patch was initially written by Chase Douglas. Signed-off-by: Chase Douglas <chase.douglas@canonical.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.am2
-rw-r--r--include/input.h24
-rw-r--r--include/inpututils.h49
3 files changed, 65 insertions, 10 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index e76de05c3..eb0e3a7c1 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -67,6 +67,6 @@ AM_CFLAGS = $(DIX_CFLAGS)
EXTRA_DIST = \
dix-config-apple-verbatim.h \
- eventconvert.h eventstr.h \
+ eventconvert.h eventstr.h inpututils.h \
protocol-versions.h \
xsha1.h
diff --git a/include/input.h b/include/input.h
index 36ce4c901..76df4ff79 100644
--- a/include/input.h
+++ b/include/input.h
@@ -157,6 +157,8 @@ typedef struct _DeviceRec {
Bool on; /* used by DDX to keep state */
} DeviceRec, *DevicePtr;
+typedef struct _ValuatorMask ValuatorMask;
+
typedef struct {
int click, bell, bell_pitch, bell_duration;
Bool autoRepeat;
@@ -445,9 +447,7 @@ extern _X_EXPORT int GetPointerEvents(
int type,
int buttons,
int flags,
- int first_valuator,
- int num_valuators,
- const int *valuators);
+ const ValuatorMask *mask);
extern _X_EXPORT int GetKeyboardEvents(
EventListPtr events,
@@ -460,17 +460,13 @@ extern int GetKeyboardValuatorEvents(
DeviceIntPtr pDev,
int type,
int key_code,
- int first_valuator,
- int num_valuator,
- const int *valuators);
+ const ValuatorMask *mask);
extern int GetProximityEvents(
EventListPtr events,
DeviceIntPtr pDev,
int type,
- int first_valuator,
- int num_valuators,
- const int *valuators);
+ const ValuatorMask *mask);
extern void PostSyntheticMotion(
DeviceIntPtr pDev,
@@ -554,4 +550,14 @@ extern _X_EXPORT void DDXRingBell(
xfixes/cursor.c uses it to determine if the cursor is enabled */
extern Bool EnableCursor;
+/* For server-internal functions, see inpututil.h */
+extern _X_EXPORT ValuatorMask *valuator_mask_new(int num_valuators);
+extern _X_EXPORT void valuator_mask_set_range(ValuatorMask *mask,
+ int first_valuator, int num_valuators,
+ const int* valuators);
+extern _X_EXPORT void valuator_mask_set(ValuatorMask *mask,
+ int valuator,
+ int data);
+extern _X_EXPORT void valuator_mask_zero(ValuatorMask *mask);
+
#endif /* INPUT_H */
diff --git a/include/inpututils.h b/include/inpututils.h
new file mode 100644
index 000000000..56bb75d07
--- /dev/null
+++ b/include/inpututils.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright © 2010 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER 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.
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include "dix-config.h"
+#endif
+
+#ifndef INPUTUTILS_H
+#define INPUTUTILS_H
+
+#include "input.h"
+
+struct _ValuatorMask {
+ int8_t last_bit; /* highest bit set in mask */
+ uint8_t mask[(MAX_VALUATORS + 7)/8];
+ int valuators[MAX_VALUATORS]; /* valuator data */
+};
+
+/* server-internal */
+extern _X_HIDDEN int valuator_mask_size(const ValuatorMask *mask);
+extern _X_HIDDEN int valuator_mask_isset(const ValuatorMask *mask, int bit);
+extern _X_HIDDEN void valuator_mask_unset(ValuatorMask *mask, int bit);
+extern _X_HIDDEN int* valuator_mask_copy_valuators(const ValuatorMask *mask, int *valuators_in);
+extern _X_HIDDEN int valuator_mask_num_valuators(const ValuatorMask *mask);
+extern _X_HIDDEN void valuator_mask_copy(ValuatorMask *dest, const ValuatorMask *src);
+extern _X_HIDDEN int valuator_mask_get(const ValuatorMask *mask, int valnum);
+
+#endif