Input Data
Moonlight will send all user inputs via the control stream.
INPUT_DATA
messageThe first 4 bytes (big endian) following the header of a packet of type
INPUT_DATA
indicate the size of the message, which varies depending on the input type.
The next 4 bytes (little endian) specify the input type, which can be any of the values in the following table.
Input type name | Value |
---|---|
MOUSE_MOVE_REL |
|
MOUSE_MOVE_ABS |
|
MOUSE_BUTTON_DOWN |
|
MOUSE_BUTTON_UP |
|
KEY_DOWN |
|
KEY_UP |
|
MOUSE_SCROLL |
|
MOUSE_HSCROLL |
|
TOUCH |
|
PEN |
|
CONTROLLER_MULTI |
|
CONTROLLER_ARRIVAL |
|
CONTROLLER_TOUCH |
|
CONTROLLER_MOTION |
|
CONTROLLER_BATTERY |
|
HAPTICS |
|
UTF8_TEXT |
|
Mouse: relative move
Moonlight will send mouse relative coordinates when the option "Optimize mouse for remote desktop instead of games" is turned OFF
.
MOUSE_MOVE_REL
packetDelta X
and Delta Y
defines the relative movement that the mouse must perform.
Delta X and Delta Y are encoded as big endian.
|
Mouse: absolute move
Moonlight will send mouse absolute coordinates when the option "Optimize mouse for remote desktop instead of games" is turned ON
.
MOUSE_MOVE_ABS
packetIn order to define an absolute position Moonlight will send both:
-
width
,height
which represent the size of the viewport on the client side -
X
,Y
are the absolute coordinates of the mouse on the client side
X , Y , width and height are encoded as big endian.
|
Mouse: button
MOUSE_BUTTON_DOWN
or MOUSE_BUTTON_UP
packetAction
can have the following values:
Action data | Meaning |
---|---|
|
Button released |
|
Button pressed |
Button
can have the following values:
Button data | Meaning |
---|---|
1 |
Button left |
2 |
Button middle |
3 |
Button right |
4 |
Button side |
5 |
Button extra |
Keyboard
KEY_DOWN
or KEY_UP
packetAction
can have the following values:
Action data | Meaning |
---|---|
|
Button released |
|
Button pressed |
What’s |
Key code
represent the corresponding keyboard code of the pressed input, see the following table:
Moonlight code | Keyboard button |
---|---|
0x08 |
BACKSPACE |
0x09 |
TAB |
0x0C |
CLEAR |
0x0D |
ENTER |
0x10 |
LEFTSHIFT |
0x11 |
LEFTCTRL |
0x12 |
LEFTALT |
0x13 |
PAUSE |
0x14 |
CAPSLOCK |
0x15 |
KATAKANAHIRAGANA |
0x16 |
HANGEUL |
0x17 |
HANJA |
0x19 |
KATAKANA |
0x1B |
ESC |
0x20 |
SPACE |
0x21 |
PAGEUP |
0x22 |
PAGEDOWN |
0x23 |
END |
0x24 |
HOME |
0x25 |
LEFT |
0x26 |
UP |
0x27 |
RIGHT |
0x28 |
DOWN |
0x29 |
SELECT |
0x2A |
|
0x2C |
SYSRQ |
0x2D |
INSERT |
0x2E |
DELETE |
0x2F |
HELP |
0x30 |
0 |
0x31 |
1 |
0x32 |
2 |
0x33 |
3 |
0x34 |
4 |
0x35 |
5 |
0x36 |
6 |
0x37 |
7 |
0x38 |
8 |
0x39 |
9 |
0x41 |
A |
0x42 |
B |
0x43 |
C |
0x44 |
D |
0x45 |
E |
0x46 |
F |
0x47 |
G |
0x48 |
H |
0x49 |
I |
0x4A |
J |
0x4B |
K |
0x4C |
L |
0x4D |
M |
0x4E |
N |
0x4F |
O |
0x50 |
P |
0x51 |
Q |
0x52 |
R |
0x53 |
S |
0x54 |
T |
0x55 |
U |
0x56 |
V |
0x57 |
W |
0x58 |
X |
0x59 |
Y |
0x5A |
Z |
0x5B |
LEFTMETA |
0x5C |
RIGHTMETA |
0x5F |
SLEEP |
0x60 |
NUMPAD 0 |
0x61 |
NUMPAD 1 |
0x62 |
NUMPAD 2 |
0x63 |
NUMPAD 3 |
0x64 |
NUMPAD 4 |
0x65 |
NUMPAD 5 |
0x66 |
NUMPAD 6 |
0x67 |
NUMPAD 7 |
0x68 |
NUMPAD 8 |
0x69 |
NUMPAD 9 |
0x6A |
NUMPAD ASTERISK |
x6B |
NUMPAD PLUS |
0x6C |
NUMPAD COMMA |
0x6D |
NUMPAD MINUS |
0x6E |
NUMPAD DOT |
0x6F |
NUMPAD SLASH |
0x70 |
F1 |
0x71 |
F2 |
0x72 |
F3 |
0x73 |
F4 |
0x74 |
F5 |
0x75 |
F6 |
0x76 |
F7 |
0x77 |
F8 |
0x78 |
F9 |
0x79 |
F10 |
0x7A |
F11 |
0x7B |
F12 |
0x90 |
NUMLOCK |
0x91 |
SCROLLLOCK |
0xA0 |
LEFTSHIFT |
0xA1 |
RIGHTSHIFT |
0xA2 |
LEFTCTRL |
0xA3 |
RIGHTCTRL |
0xA4 |
LEFTALT |
0xA5 |
RIGHTALT |
0xBA |
SEMICOLON |
0xBB |
EQUAL |
0xBC |
COMMA |
0xBD |
MINUS |
0xBE |
DOT |
0xBF |
SLASH |
0xC0 |
GRAVE |
0xDB |
LEFTBRACE |
0xDC |
BACKSLASH |
0xDD |
RIGHTBRACE |
0xDE |
APOSTROPHE |
0xE2 |
102ND |
Mouse scroll
MOUSE_SCROLL
packetWe only use amount 1
to determine the amount of scroll to be applied.
What’s |
Controller
Controller arrival
new in Moonlight 5.0.0
Sent when a new connector has been plugged, it’ll specify the supported capabilities and the specific type of controller to be emulated.
CONTROLLER_ARRIVAL
packetWhere controller type can be:
Moonlight code | Description |
---|---|
Unknown |
0x00 |
XBOX |
0x01 |
PS |
0x02 |
Nintendo |
0x03 |
And the capabilities is a bitfield with the followings options:
Moonlight code | Description |
---|---|
Analog triggers |
0x01 |
Rumble |
0x02 |
Trigger Rumble |
0x04 |
Touchpad |
0x08 |
Accelerometer |
0x10 |
Gyro |
0x20 |
Battery |
0x40 |
RGB LED |
0x80 |
Controller multi
Since Moonlight 5.0.0 the format has been slightly changed (without breaking the legacy format) |
CONTROLLER_MULTI
packetLegacy format
CONTROLLER_MULTI
packetLT
and RT
refer to the left and right triggers, respectively. Left X
and the following fields refer to the values of the left and right sticks.
Active mask
The active mask represent a bitfield with bits set for each controller present.
If you combine this with the ctrl #
(controller number) you can detect when a controller has been unplugged.
An active mask of |
Button flags
The buttons
element encodes the currently pressed buttons in the joypad.
In order to get the new added buttons you have to combine btn flags
and btn flags 2
so that
(button_flags | (button_flags2 << 16))
Button type | Flag (HEX) |
---|---|
DPAD_UP |
0x0001 |
DPAD_DOWN |
0x0002 |
DPAD_LEFT |
0x0004 |
DPAD_RIGHT |
0x0008 |
START |
0x0010 |
BACK |
0x0020 |
HOME |
0x0400 |
LEFT_STICK |
0x0040 |
RIGHT_STICK |
0x0080 |
LEFT_BUTTON |
0x0100 |
RIGHT_BUTTON |
0x0200 |
A |
0x1000 |
B |
0x2000 |
X |
0x4000 |
Y |
0x8000 |
SPECIAL_FLAG |
0x0400 |
PADDLE 1 |
0x010000 |
PADDLE 2 |
0x020000 |
PADDLE 3 |
0x040000 |
PADDLE 4 |
0x080000 |
Touchpad |
0x100000 |
MISC |
0x200000 |
If more than one button is being pressed at the same time button_flag
will contain the sum of both values.
button_flag
contains 0x0050
that 5
decodes as follows:button_flag
binary encoding