[Xcb] [PATCH proto 5/5] xinput: Implement nearly everything from XI 1.4
Daniel Martin
consume.noise at gmail.com
Thu Jan 3 06:02:40 PST 2013
With this commit and the latetly introduced sizeof element we're able to
implement nearly every missing list from XI 1.4.
Still incomplete are the requests ListInputDevices and
GetDeviceMotionEvents.
For every previously unimplemented list there's a union now. In
combination with the sizeof handling in unions it allows us to use an
iterator on lists of such unions. To make it work, a union generally is
realized like this:
<struct name="Foo">
<field type="CARD8" name="id" enum="FooBarEnum" />
<field type="CARD8" name="len" />
<!-- Foo specific fields ... -->
</struct>
<struct name="Bar">
<field type="CARD8" name="id" enum="FooBarEnum" />
<field type="CARD8" name="len" />
<!-- Bar specific fields ... -->
</struct>
<struct name="AnyFooBar">
<field type="CARD8" name="id" enum="FooBarEnum" />
<field type="CARD8" name="len" />
<sizeof>
<fieldref>len</fieldref>
</sizeof>
</struct>
<union name="FooBar">
<field type="AnyFooBar" name="any" />
<field type="Foo" name="foo" />
<field type="Bar" name="bar" />
<field type="CARD8" name="id" enum="FooBarEnum" />
</union>
Signed-off-by: Daniel Martin <consume.noise at gmail.com>
---
src/xinput.xml | 192 +++++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 140 insertions(+), 52 deletions(-)
diff --git a/src/xinput.xml b/src/xinput.xml
index d8bba3a..08f90b3 100644
--- a/src/xinput.xml
+++ b/src/xinput.xml
@@ -95,8 +95,14 @@ authorization from the authors.
<list type="DeviceInfo" name="devices">
<fieldref>devices_len</fieldref>
</list>
- <!-- Uninterpreted: list of InputInfo structures, length is sum of all devices.num_class_info -->
- <!-- Uninterpreted: list of CountedString structures, length is devices_len -->
+ <list type="InputInfo" name="fixme_classes">
+ <!-- FIXME: length is sum of all devices.num_class_info -->
+ <fieldref>devices_len</fieldref>
+ </list>
+ <list type="CountedString" name="fixme_names">
+ <!-- FIXME: starts after fixme_classes -->
+ <fieldref>devices_len</fieldref>
+ </list>
</reply>
</request>
@@ -110,11 +116,6 @@ authorization from the authors.
<item name="Other"> <value>6</value> </item>
</enum>
- <struct name="InputInfo">
- <field type="CARD8" name="class_id" enum="InputClass" />
- <field type="CARD8" name="len" />
- </struct>
-
<struct name="KeyInfo">
<field type="CARD8" name="class_id" enum="InputClass" />
<field type="CARD8" name="len" />
@@ -147,6 +148,23 @@ authorization from the authors.
</list>
</struct>
+ <struct name="AnyInputInfo">
+ <field type="CARD8" name="class_id" enum="InputClass" />
+ <field type="CARD8" name="len" />
+ <sizeof>
+ <fieldref>len</fieldref>
+ </sizeof>
+ </struct>
+
+ <union name="InputInfo">
+ <field type="AnyInputInfo" name="any" />
+ <field type="KeyInfo" name="key" />
+ <field type="ButtonInfo" name="button" />
+ <field type="AxisInfo" name="axis" />
+ <field type="ValuatorInfo" name="valuator" />
+ <field type="CARD8" name="class_id" enum="InputClass" />
+ </union>
+
<!-- OpenDevice -->
<struct name="InputClassInfo">
@@ -254,16 +272,22 @@ authorization from the authors.
<field type="CARD8" name="num_axes" />
<field type="CARD8" name="device_mode" enum="ValuatorMode" />
<pad bytes="18" />
- <!-- Uninterpreted: list of DeviceTimeCoord structures -->
+ <list type="DeviceTimeCoord" name="fixme_coords">
+ <fieldref>num_coords</fieldref>
+ </list>
</reply>
</request>
<struct name="DeviceTimeCoord">
<field type="TIMESTAMP" name="time" />
- <!-- Uninterpreted: list of CARD16, length is num_axes from GetDeviceMotionEvents -->
+ <list type="CARD16" name="fixme_data">
+ <!-- FIXME: length is num_axes from GetDeviceMotionEvents -->
+ <value>0</value>
+ </list>
</struct>
<!-- ChangeKeyboardDevice -->
+
<request name="ChangeKeyboardDevice" opcode="11">
<field type="CARD8" name="device_id" />
<pad bytes="3" />
@@ -421,7 +445,9 @@ authorization from the authors.
<pad bytes="1" />
<field type="CARD16" name="num_feedback" />
<pad bytes="22" />
- <!-- Uninterpreted: list of FeedbackState structures -->
+ <list type="FeedbackState" name="feedbacks">
+ <fieldref>num_feedback</fieldref>
+ </list>
</reply>
</request>
@@ -434,12 +460,6 @@ authorization from the authors.
<item name="Bell" />
</enum>
- <struct name="FeedbackState">
- <field type="CARD8" name="class_id" enum="FeedbackClass" />
- <field type="CARD8" name="id" />
- <field type="CARD16" name="len" />
- </struct>
-
<struct name="KbdFeedbackState">
<field type="CARD8" name="class_id" enum="FeedbackClass" />
<field type="CARD8" name="id" />
@@ -505,22 +525,34 @@ authorization from the authors.
<field type="CARD32" name="led_values" />
</struct>
- <!-- ChangeFeedbackControl
+ <struct name="AnyFeedbackState">
+ <field type="CARD8" name="class_id" enum="FeedbackClass" />
+ <field type="CARD8" name="id" />
+ <field type="CARD16" name="len" />
+ <sizeof>
+ <fieldref>len</fieldref>
+ </sizeof>
+ </struct>
- <request name="ChangeFeedbackControl" opcode="23">
- <field type="CARD32" name="mask" />
- <field type="CARD8" name="device_id" />
- <field type="CARD8" name="feedback_id" />
- Uninterpreted: field of FeedbackCtl structure
- </request>
+ <union name="FeedbackState">
+ <field type="AnyFeedbackState" name="any" />
+ <field type="KbdFeedbackState" name="keyboard" />
+ <field type="PtrFeedbackState" name="pointer" />
+ <field type="IntegerFeedbackState" name="integer" />
+ <field type="StringFeedbackState" name="string" />
+ <field type="BellFeedbackState" name="bell" />
+ <field type="LedFeedbackState" name="led" />
+ <field type="CARD8" name="class_id" enum="FeedbackClass" />
+ </union>
- -->
+ <!-- ChangeFeedbackControl -->
- <struct name="FeedbackCtl">
- <field type="CARD8" name="class_id" enum="FeedbackClass" />
- <field type="CARD8" name="id" />
- <field type="CARD16" name="len" />
- </struct>
+ <request name="ChangeFeedbackControl" opcode="23">
+ <field type="CARD32" name="mask" />
+ <field type="CARD8" name="device_id" />
+ <field type="CARD8" name="feedback_id" />
+ <field type="FeedbackCtl" name="feedback" />
+ </request>
<struct name="KbdFeedbackCtl">
<field type="CARD8" name="class_id" enum="FeedbackClass" />
@@ -582,6 +614,26 @@ authorization from the authors.
<field type="CARD32" name="led_values" />
</struct>
+ <struct name="AnyFeedbackCtl">
+ <field type="CARD8" name="class_id" enum="FeedbackClass" />
+ <field type="CARD8" name="id" />
+ <field type="CARD16" name="len" />
+ <sizeof>
+ <fieldref>len</fieldref>
+ </sizeof>
+ </struct>
+
+ <union name="FeedbackCtl">
+ <field type="AnyFeedbackCtl" name="any" />
+ <field type="KbdFeedbackCtl" name="keyboard" />
+ <field type="PtrFeedbackCtl" name="pointer" />
+ <field type="IntegerFeedbackCtl" name="integer" />
+ <field type="StringFeedbackCtl" name="string" />
+ <field type="BellFeedbackCtl" name="bell" />
+ <field type="LedFeedbackCtl" name="led" />
+ <field type="CARD8" name="class_id" enum="FeedbackClass" />
+ </union>
+
<!-- GetDeviceKeyMapping -->
<request name="GetDeviceKeyMapping" opcode="24">
@@ -690,16 +742,12 @@ authorization from the authors.
<pad bytes="1" />
<field type="CARD8" name="num_classes" />
<pad bytes="23" />
- <!-- Uninterpreted: list of InputState structures -->
+ <list type="InputState" name="classes">
+ <fieldref>num_classes</fieldref>
+ </list>
</reply>
</request>
- <struct name="InputState">
- <field type="CARD8" name="class_id" enum="InputClass" />
- <field type="CARD8" name="len" />
- <field type="CARD8" name="num_items" />
- </struct>
-
<struct name="KeyState">
<field type="CARD8" name="class_id" enum="InputClass" />
<field type="CARD8" name="len" />
@@ -730,6 +778,22 @@ authorization from the authors.
</list>
</struct>
+ <struct name="AnyInputState">
+ <field type="CARD8" name="class_id" enum="InputClass" />
+ <field type="CARD8" name="len" />
+ <sizeof>
+ <fieldref>len</fieldref>
+ </sizeof>
+ </struct>
+
+ <union name="InputState">
+ <field type="AnyInputState" name="any" />
+ <field type="KeyState" name="key" />
+ <field type="ButtonState" name="button" />
+ <field type="ValuatorState" name="valuator" />
+ <field type="CARD8" name="class_id" enum="InputClass" />
+ </union>
+
<!-- SendExtensionEvent -->
<request name="SendExtensionEvent" opcode="31">
@@ -794,15 +858,10 @@ authorization from the authors.
<pad bytes="1" />
<field type="CARD8" name="status" altenum="GrabStatus" />
<pad bytes="23" />
- <!-- Uninterpreted: field of DeviceState structure -->
+ <field type="DeviceState" name="state" />
</reply>
</request>
- <struct name="DeviceState">
- <field type="CARD16" name="control_id" enum="DeviceControl" />
- <field type="CARD16" name="len" />
- </struct>
-
<struct name="DeviceResolutionState">
<field type="CARD16" name="control_id" enum="DeviceControl" />
<field type="CARD16" name="len" />
@@ -857,27 +916,38 @@ authorization from the authors.
<pad bytes="3" />
</struct>
- <!-- ChangeDeviceControl
+ <struct name="AnyDeviceState">
+ <field type="CARD16" name="control_id" enum="DeviceControl" />
+ <field type="CARD16" name="len" />
+ <sizeof>
+ <fieldref>len</fieldref>
+ </sizeof>
+ </struct>
+
+ <union name="DeviceState">
+ <field type="AnyDeviceState" name="any" />
+ <field type="DeviceResolutionState" name="resolution" />
+ <field type="DeviceAbsCalibState" name="abs_calib" />
+ <field type="DeviceAbsAreaState" name="abs_area" />
+ <field type="DeviceCoreState" name="core" />
+ <field type="DeviceEnableState" name="enable" />
+ <field type="CARD16" name="control_id" enum="DeviceControl" />
+ </union>
+
+ <!-- ChangeDeviceControl -->
<request name="ChangeDeviceControl" opcode="35">
<field type="CARD16" name="control_id" enum="DeviceControl" />
<field type="CARD8" name="device_id" />
<pad bytes="1" />
- Uninterpreted: field of DeviceCtl structure
+ <field type="DeviceCtl" name="control" />
<reply>
- <pad byte="1" />
+ <pad bytes="1" />
<field type="CARD8" name="status" altenum="GrabStatus" />
<pad bytes="23" />
</reply>
</request>
- -->
-
- <struct name="DeviceCtl">
- <field type="CARD16" name="control_id" enum="DeviceControl" />
- <field type="CARD16" name="len" />
- </struct>
-
<struct name="DeviceResolutionCtl">
<field type="CARD16" name="control_id" enum="DeviceControl" />
<field type="CARD16" name="len" />
@@ -926,6 +996,24 @@ authorization from the authors.
<pad bytes="3" />
</struct>
+ <struct name="AnyDeviceCtl">
+ <field type="CARD16" name="control_id" enum="DeviceControl" />
+ <field type="CARD16" name="len" />
+ <sizeof>
+ <fieldref>len</fieldref>
+ </sizeof>
+ </struct>
+
+ <union name="DeviceCtl">
+ <field type="AnyDeviceCtl" name="any" />
+ <field type="DeviceResolutionCtl" name="resolution" />
+ <field type="DeviceAbsCalibCtl" name="abs_calib" />
+ <field type="DeviceAbsAreaCtrl" name="abs_area" />
+ <field type="DeviceCoreCtrl" name="core" />
+ <field type="DeviceEnableCtrl" name="enable" />
+ <field type="CARD16" name="control_id" enum="DeviceControl" />
+ </union>
+
<!-- EVENTS -->
<event name="DeviceValuator" number="0">
--
1.8.0.3
More information about the Xcb
mailing list