[ground_segment] add joystick hat to input2ivy

You can use the Hat<Position>(<hat_name>) function to trigger events,
where <Position> is one of
Centered/Up/Right/Down/Left/RightUp/RightDown/LeftUp/LeftDown

Only one hat can be used, but the interface will allow multiple ones in
the future.

closes #460
This commit is contained in:
Felix Ruess
2013-06-10 15:36:21 +02:00
parent ca67df9576
commit 6d2e303633
6 changed files with 166 additions and 56 deletions
+14 -8
View File
@@ -4,8 +4,6 @@
axis 1: pitch
axis 2: yaw
axis 3: throttle (reversed)
axis 4: hat switch left/right (right is positive)
axis 5: hat switch up/down (down is positive)
It has 9 buttons.
b0 - fire
@@ -18,6 +16,11 @@ It has 9 buttons.
b7 - button D
b8 - shift button
and a POV hat.
You can use the Hat<Position>(<hat_name>) function to trigger events,
where <Position> is one of
Centered/Up/Right/Down/Left/RightUp/RightDown/LeftUp/LeftDown
so e.g. HatDown(myhat)
-->
<joystick>
@@ -26,8 +29,6 @@ It has 9 buttons.
<axis index="1" name="pitch" limit="1.00" exponent="0.7" trim="0"/>
<axis index="2" name="yaw" limit="1.00" exponent="0.7" trim="0"/>
<axis index="3" name="throttle"/>
<axis index="4" name="hat_lr"/>
<axis index="5" name="hat_ud"/>
<button index="0" name="fire"/>
<button index="1" name="fire2"/>
<button index="2" name="up"/>
@@ -37,23 +38,28 @@ It has 9 buttons.
<button index="6" name="C"/>
<button index="7" name="D"/>
<button index="8" name="shift"/>
<hat index="0" name="hat"/>
</input>
<messages period="0.1">
<!--message class="datalink" name="RC_4CH" send_always="true">
<message class="datalink" name="RC_4CH" send_always="true">
<field name="mode" value="1-fire+A"/>
<field name="throttle" value="Fit(-throttle,-127,127,0,127)"/>
<field name="roll" value="roll"/>
<field name="pitch" value="pitch"/>
<field name="yaw" value="yaw"/>
</message-->
</message>
<message class="datalink" name="RC_3CH" send_always="true">
<message class="ground" name="JUMP_TO_BLOCK" on_event="HatDown(hat)">
<field name="block_id" value="IndexOfBlock('land')"/>
</message>
<!--message class="datalink" name="RC_3CH" send_always="true">
<field name="throttle_mode" value="0"/>
<field name="roll" value="roll"/>
<field name="pitch" value="pitch"/>
</message>
</message-->
</messages>
</joystick>
+67
View File
@@ -0,0 +1,67 @@
<!-- Generic X-Box gamepad, e.g. Logitech wireless gamepad F710
Has six axes:
axis 0: LTS_H (left thumb stick horizontal) (or DPad horizontal in alternate mode)
axis 1: LTS_V (left thumb stick vertical) (or DPad vertical in alternate mode)
axis 2: LT (left trigger)
axis 3: RTS_H (right thumb stick horizontal)
axis 4: RTS_V (right thumb stick vertical)
axis 5: RT (right trigger)
It has 11 buttons.
b0 - A
b1 - B
b2 - X
b3 - Y
b4 - LB (left button)
b5 - RB (right button)
b6 - back
b7 - start
b8 - ?
b9 - LSB (left stick button)
b10 - RSB (right stick button)
and the DPad as a hat (in normal mode)
You can use the Hat<Position>(<hat_name>) function to trigger events,
where <Position> is one of
Centered/Up/Right/Down/Left/RightUp/RightDown/LeftUp/LeftDown
so e.g. HatDown(dpad)
-->
<joystick>
<input>
<axis index="0" name="yaw" limit="1.00" exponent="0.7" trim="0"/>
<axis index="1" name="throttle"/>
<axis index="2" name="LT" limit="1.00" trim="127"/>
<axis index="3" name="roll" limit="1.00" exponent="0.7" trim="0"/>
<axis index="4" name="pitch" limit="1.00" exponent="0.7" trim="0"/>
<axis index="5" name="RT" limit="1.00" trim="127"/>
<button index="0" name="A"/>
<button index="1" name="B"/>
<button index="2" name="X"/>
<button index="3" name="Y"/>
<button index="4" name="LB"/>
<button index="5" name="RB"/>
<button index="6" name="back"/>
<button index="7" name="start"/>
<button index="9" name="LSB"/>
<button index="10" name="RSB"/>
<hat index="0" name="dpad"/>
</input>
<messages period="0.1">
<message class="datalink" name="RC_4CH" send_always="true">
<!-- manual if you press both left and right shoulder buttons, only one: auto1, none: auto 2 -->
<field name="mode" value="2 - LB - RB"/>
<field name="throttle" value="Fit(-throttle,-127,127,0,127)"/>
<field name="roll" value="roll"/>
<field name="pitch" value="pitch"/>
<field name="yaw" value="yaw"/>
</message>
<message class="ground" name="JUMP_TO_BLOCK" on_event="HatDown(dpad)">
<field name="block_id" value="IndexOfBlock('land')"/>
</message>
</messages>
</joystick>