[Xcb] [PATCH proto 2/2 V2] xinput: rep QueryDeviceState struct InputState: full support

Ran Benita ran234 at gmail.com
Tue Oct 21 13:01:26 PDT 2014


On Fri, Aug 29, 2014 at 07:35:50PM +0200, Christian Linhart wrote:
> Full support for the QueryDeviceState reply.
> This has been done by changing the struct InputState
> with using switch-case and implicit-padding="false".
> 
> Also fixed the type of field valuators of struct ValuatorState
> from CARD32 to INT32.
> 
> V2: patch revised:
> * removed the implicit-padding="false" attribute, according
>   to the discussion in this thread.
> * give names to the cases, which generates more beautiful code.
> 
> spec:
> http://cgit.freedesktop.org/xorg/proto/inputproto/tree/specs/XIproto.txt?id=inputproto-2.3.1#n2082
> http://cgit.freedesktop.org/xorg/lib/libXi/tree/specs/encoding.xml?id=libXi-1.7.4#n1728
> ---
>  src/xinput.xml | 39 +++++++++++++++++++++++++++++----------
>  1 file changed, 29 insertions(+), 10 deletions(-)
> 
> diff --git a/src/xinput.xml b/src/xinput.xml
> index 95f0044..cf58a97 100644
> --- a/src/xinput.xml
> +++ b/src/xinput.xml
> @@ -858,30 +858,49 @@ <enum name="ValuatorStateModeMask">
>      </enum>
>  
>      <struct name="ValuatorState">
>          <field type="CARD8" name="class_id" enum="InputClass" />
>          <field type="CARD8" name="len" />
>          <field type="CARD8" name="num_valuators" />
>          <field type="CARD8" name="mode" mask="ValuatorStateModeMask" />
> -        <list type="CARD32" name="valuators">
> +        <list type="INT32" name="valuators">
>              <fieldref>num_valuators</fieldref>
>          </list>
>      </struct>

Remark/question for the archives: if I get it right, this struct, and
also KeyState and ButtonState, are not needed anymore, since they are
inlined into InputState, right? At least the test you posted for this
request looks like it doesn't use them.

So if they are really not needed, maybe you can add them to your
struct-removal TODO (if you haven't already).

Ran

>      <struct name="InputState">
>          <field type="CARD8" name="class_id" enum="InputClass" />
>          <field type="CARD8" name="len" />
> -        <field type="CARD8" name="num_items" />
> -        <pad bytes="1" />
> -        <list type="CARD8" name="uninterpreted_data">
> -            <op op="-">
> -                <fieldref>len</fieldref>
> -                <value>4</value>
> -            </op>
> -        </list>
> +        <switch name="data">
> +            <fieldref>class_id</fieldref>
> +            <case name="key">
> +                <enumref ref="InputClass">Key</enumref>
> +                <field type="CARD8" name="num_keys" />
> +                <pad bytes="1" />
> +                <list type="CARD8" name="keys">
> +                    <value>32</value>
> +                </list>
> +            </case>
> +            <case name="button">
> +                <enumref ref="InputClass">Button</enumref>
> +                <field type="CARD8" name="num_buttons" />
> +                <pad bytes="1" />
> +                <list type="CARD8" name="buttons">
> +                    <value>32</value>
> +                </list>
> +            </case>
> +            <case name="valuator">
> +                <enumref ref="InputClass">Valuator</enumref>
> +                <field type="CARD8" name="num_valuators" />
> +                <field type="CARD8" name="mode" mask="ValuatorStateModeMask" />
> +                <list type="INT32" name="valuators">
> +                    <fieldref>num_valuators</fieldref>
> +                </list>
> +            </case>
> +        </switch>
>      </struct>
>  
>      <request name="QueryDeviceState" opcode="30">
>          <field type="CARD8" name="device_id" />
>          <pad bytes="3" />
>          <reply>
>              <field type="CARD8" name="xi_reply_type" />
> -- 2.0.1


More information about the Xcb mailing list