[Xcb] [PATCH proto 5/8] xinput: ListInputDevices: full support

Christian Linhart chris at DemoRecorder.com
Sun Nov 2 04:47:38 PST 2014


* define struct InputInfo with switch-case
* define the lists "infos" and "names"
* the list "infos" requires a new xml-construct:
  <sumof> with a nested expression, to access fields
  of the list which is iterated by sumof.

spec:
http://cgit.freedesktop.org/xorg/proto/inputproto/tree/specs/XIproto.txt?id=inputproto-2.3.1#n305
http://cgit.freedesktop.org/xorg/lib/libXi/tree/specs/encoding.xml?id=libXi-1.7.4#n715

code:
http://cgit.freedesktop.org/xorg/lib/libXi/tree/src/XListDev.c?id=libXi-1.7.4

Both specs are misleading ( or buggy ) in the following aspect:

In both specs, struct Deviceinfo is defined to contain a list
of InputInfo and a list of STR.

But, by analyzing the code in libXi, it was clear that
* InputInfo is contained in an extra toplevel list
  in the reply ListInputDevices
* the strings ( struct xproto:STR ) are also contained in a toplevel list
  in the reply

Signed-off-by: Christian Linhart <chris at demorecorder.com>
Reviewed-by: Ran Benita <ran234 at gmail.com>
---
 src/xinput.xml | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/src/xinput.xml b/src/xinput.xml
index 7f7b0a6..b20a069 100644
--- a/src/xinput.xml
+++ b/src/xinput.xml
@@ -213,14 +213,37 @@ <struct name="ValuatorInfo">
             <fieldref>axes_len</fieldref>
         </list>
     </struct>
 
     <struct name="InputInfo">
         <field type="CARD8" name="class_id" enum="InputClass" />
         <field type="CARD8" name="len" />
+        <switch name="info">
+            <fieldref>class_id</fieldref>
+            <case name="key">
+                <enumref ref="InputClass">Key</enumref>
+                <field type="KeyCode" name="min_keycode" />
+                <field type="KeyCode" name="max_keycode" />
+                <field type="CARD16"  name="num_keys" />
+                <pad bytes="2" />
+            </case>
+            <case name="button">
+                <enumref ref="InputClass">Button</enumref>
+                <field type="CARD16"    name="num_buttons" />
+            </case>
+            <case name="valuator">
+                <enumref ref="InputClass">Valuator</enumref>
+                <field type="CARD8"   name="axes_len" />
+                <field type="CARD8"   name="mode" enum="ValuatorMode" />
+                <field type="CARD32"  name="motion_size" />
+                <list type="AxisInfo" name="axes">
+                    <fieldref>axes_len</fieldref>
+                </list>
+            </case>
+	</switch>
     </struct>
 
     <struct name="DeviceName">
         <field type="CARD8" name="len" />
         <list type="char"  name="string">
             <fieldref>len</fieldref>
         </list>
@@ -230,17 +253,23 @@ <request name="ListInputDevices" opcode="2">
         <reply>
             <field type="CARD8" name="xi_reply_type" />
             <field type="CARD8" name="devices_len" />
             <pad bytes="23" />
             <list type="DeviceInfo" name="devices">
                 <fieldref>devices_len</fieldref>
             </list>
-            <!-- Uninterpreted: list (infos) of InputInfo structures,
-                                length is <sumof> all devices.num_class_info -->
-            <!-- Uninterpreted: list (name) of DeviceName structures -->
+            <list type="InputInfo" name="infos">
+                <sumof ref="devices">
+			<fieldref>num_class_info</fieldref>
+		</sumof>
+            </list>
+            <list type="STR" name="names">
+                <fieldref>devices_len</fieldref>
+            </list>
+            <pad align="4" />
         </reply>
     </request>
 
     <!-- OpenDevice -->
 
     <struct name="InputClassInfo">
         <field type="CARD8" name="class_id" enum="InputClass" />
--
2.0.1




More information about the Xcb mailing list