Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Controller

This section covers all km commands that affect devices designated as Controllers, such as Xbox and Playstation controllers.

Axes

A controller has 6 axes. Sticks use the range -32768 to 32767, centered at 0, where positive is up or right, and negative is down or left. Triggers use the range 0 (released) to 65535 (fully pressed).

Axes
Axis NamesAxisRange
lxleft stick horizontal-32768 to 32767
lyleft stick vertical-32768 to 32767
rxright stick horizontal-32768 to 32767
ryright stick vertical-32768 to 32767
lt, l2left trigger0 to 65535
rt, r2right trigger0 to 65535

Buttons

A controller has up to 17 buttons. Each can be named by its Xbox or Playstation name (case-insensitive).

When reading every button at once, the buttons are combined into a single number, where each button is one bit. The Bit column shows each button’s bit, so a button is pressed if buttons & (1 << bit) is not 0.

Buttons
BitXbox NamesPlaystation NamesButton
0upupD-pad up
1rightrightD-pad right
2downdownD-pad down
3leftleftD-pad left
4ytriangletop face button
5bcircleright face button
6acrossbottom face button
7xsquareleft face button
8lsl3left stick press
9rsr3right stick press
10lbl1left bumper
11rbr1right bumper
12view, backcreateleft center button
13menu, startoptionsright center button
14sharetouchpadcenter button
15home, guidepshome button
16mutemute button

Triggers are axes rather than buttons (see Axes), due to being analog.

Note that share refers to the Xbox Share button (the center button). The Playstation 4’s Share button is the left center button, named create.