[Q] How to map gamepad/joystick axes to control the UI?

g-e-c-o

New member
Aug 20, 2013
1
0
0
I have a joystick with 6 axes an 2 buttons. If I connect that joystick to my device (nexus 7) through an otg cable it gets recognized as HID device.
The two buttons are both mapped by android to ENTER and the X + Y axes to direction keys.
So it is already possible to control some UI sections (ie app icon selection on launcher).

I added a key layout map in "/system/usr/keylayout/Vendor_046d_Product_c626.kl" to customize the two buttons.
I was also able to remap and invert all 6 axes.

Code:
# left / right
axis 0x00 RX

# forth / back
axis 0x01 RY

# up / down
axis 0x02 RZ

# roll forth / back
axis 0x03 Y

# roll left / right
axis 0x04 X

# turn left / right
axis 0x05 Z

# left button
key 256   VOLUME_DOWN

# right button
key 257   VOLUME_UP
As you can see I mapped the two buttons to the volume controls, which works fine.
Unfortunately I'm not able to figure out how to map axes to keystrokes.
As the X + Y axes are mapped to direction keys, there must be a setting somewhere for this.
I would like to use all 6 axes and map them to simple keystrokes.

Can sombody help?
 

-16-

Senior Member
Nov 16, 2008
80
12
28
Hello g-e-c-o.

I know this thread is a lil bit older but I'm getting faced with the same problem soon. Did you find any solution for mapping the axes?