When GAMEPAD_SUPPORT
is enabled, Sommelier will create a gaming seat to listen for gamepads being attached and their associated events.
Once a gamepad is added, we use evdev
and uinput
to emulate an Xbox One S gamepad in the VM. We subsequently forward gamepad events from the host through that emulated gamepad. Because not every gamepad lines up precisely with an Xbox gamepad, we sometimes have to remap input events so that they make sense.
This guide assumes you have access to a Chromebook in Developer Mode.
evtest
and select your deviceDeviceID
struct with the details of your gamepadDeviceID
/mapping pair to kDeviceMappings
To figure out what the mapping should be, you can follow the reference table below which demonstrates which event codes are mapped to which buttons on an Xbox gamepad (which we emulate) - we suggest making the mappings locality focused, rather than glyph-focused (i.e bottom face button should map to the Xbox “A”).
Xbox One S gamepad button-event code mapping:
Button/axes | Input code |
---|---|
left joystick | ABS_X, ABX_Y |
right joystick. | ABS_RX, ABS_RY |
directional pad | ABS_HAT0X, ABS_HAT0Y |
left bumper | BTN_TL |
left trigger | ABS_Z |
right bumper | BTN_TR |
right trigger | ABS_RZ |
Y | BTN_Y |
B | BTN_B |
A | BTN_A |
X | BTN_X |
select button | BTN_SELECT |
Xbox button | BTN_MODE |
start button | BTN_START |
Notes: