summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDuncan McGreggor <duncan@canonical.com>2011-03-19 17:42:36 -0600
committerDuncan McGreggor <duncan@canonical.com>2011-03-19 17:42:36 -0600
commit61c282e8d3324ec37c7c090406e77b8c57681646 (patch)
tree736cc945e5a4394a10bb5bd6cdb6902d456c64c3 /python
parent2ba9ade983fe872e0cde09c38e7bc5ab117cc9fb (diff)
Start exploring a ctypes structure setup for the device structure.
Diffstat (limited to 'python')
-rw-r--r--python/evemu/data.py61
-rw-r--r--python/evemu/tests/test_data.py0
2 files changed, 61 insertions, 0 deletions
diff --git a/python/evemu/data.py b/python/evemu/data.py
new file mode 100644
index 0000000..3b79340
--- /dev/null
+++ b/python/evemu/data.py
@@ -0,0 +1,61 @@
+import ctypes
+
+from evemu import const
+
+
+ABS_CNT = const.ABS_MAX + 1
+
+
+class InputIdStruct(ctypes.Structure):
+ """
+ Data structure based on input_id in linux/uinput.h.
+ """
+ _fields_ = [
+ ("bustype", ctypes.c_uint),
+ ("vendor", ctypes.c_uint),
+ ("product", ctypes.c_uint),
+ ("version", ctypes.c_uint),
+ ]
+
+
+class InputAbsInfoStruct(ctypes.Structure):
+ """
+ Data structure based on input_absinfo in XXX.
+ """
+ _fields_ = [
+ ("value", ctypes.c_ulong),
+ ("minimum", ctypes.c_ulong),
+ ("maximum", ctypes.c_ulong),
+ ("fuzz", ctypes.c_ulong),
+ ("flat", ctypes.c_ulong),
+ ("resolution", ctypes.c_ulong),
+ ]
+
+
+class EvEmuDeviceStruct(ctypes.Structure):
+ """
+ Data structure based on evemu_device in evemu-impl.h.
+ """
+ _fields_ = [
+ ("version", ctypes.c_uint),
+ ("name", ctypes.c_byte * const.UINPUT_MAX_NAME_SIZE),
+ ("id", InputIdStruct),
+ ("prop", ctypes.c_ubyte * const.EVPLAY_NBYTES),
+ ("mask", ctypes.c_ubyte),
+ ("pbytes", ctypes.c_int),
+ ("mbytes", ctypes.c_int * const.EV_CNT),
+ ("abs", InputAbsInfoStruct * ABS_CONT),
+ ]
+"""
+struct evemu_device {
+ unsigned int version; //
+ char name[UINPUT_MAX_NAME_SIZE]; // string, max size
+ struct input_id id; // struct input_id from linux/uinput.h
+ unsigned char prop[EVPLAY_NBYTES]; //
+ unsigned char mask[EV_CNT][EVPLAY_NBYTES]; // doubly indexed array...
+ first index is what type, second field is a bitmask (
+ int pbytes //
+ int mbytes[EV_CNT]; // array of integers
+ struct input_absinfo abs[ABS_CNT]; // array structures
+};
+"""
diff --git a/python/evemu/tests/test_data.py b/python/evemu/tests/test_data.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/python/evemu/tests/test_data.py