Add Sunshine protocol extension to support non-normalized key codes

This commit is contained in:
Cameron Gutman
2023-01-16 21:05:11 -06:00
parent 22adeb3902
commit c9a5cea93e
3 changed files with 15 additions and 3 deletions

View File

@@ -17,7 +17,7 @@ typedef struct _NV_HAPTICS_PACKET {
#define KEY_UP_EVENT_MAGIC 0x00000004
typedef struct _NV_KEYBOARD_PACKET {
NV_INPUT_HEADER header;
char zero1;
char flags; // Sunshine extension (always 0 for GFE)
short keyCode;
char modifiers;
short zero2;

View File

@@ -675,7 +675,7 @@ int LiSendMouseButtonEvent(char action, int button) {
}
// Send a key press event to the streaming machine
int LiSendKeyboardEvent(short keyCode, char keyAction, char modifiers) {
int LiSendKeyboardEvent2(short keyCode, char keyAction, char modifiers, char flags) {
PPACKET_HOLDER holder;
int err;
@@ -732,7 +732,7 @@ int LiSendKeyboardEvent(short keyCode, char keyAction, char modifiers) {
holder->packet.keyboard.header.size = BE32(sizeof(NV_KEYBOARD_PACKET) - sizeof(uint32_t));
holder->packet.keyboard.header.magic = LE32((uint32_t)keyAction);
holder->packet.keyboard.zero1 = 0;
holder->packet.keyboard.flags = IS_SUNSHINE() ? flags : 0;
holder->packet.keyboard.keyCode = LE16(keyCode);
holder->packet.keyboard.modifiers = modifiers;
holder->packet.keyboard.zero2 = 0;
@@ -747,6 +747,10 @@ int LiSendKeyboardEvent(short keyCode, char keyAction, char modifiers) {
return err;
}
int LiSendKeyboardEvent(short keyCode, char keyAction, char modifiers) {
return LiSendKeyboardEvent2(keyCode, keyAction, modifiers, 0);
}
int LiSendUtf8TextEvent(const char *text, unsigned int length) {
PPACKET_HOLDER holder;
int err;

View File

@@ -546,6 +546,8 @@ int LiSendMouseMoveAsMousePositionEvent(short deltaX, short deltaY, short refere
int LiSendMouseButtonEvent(char action, int button);
// This function queues a keyboard event to be sent to the remote server.
// Key codes are Win32 Virtual Key (VK) codes and interpreted as keys on
// a US English layout.
#define KEY_ACTION_DOWN 0x03
#define KEY_ACTION_UP 0x04
#define MODIFIER_SHIFT 0x01
@@ -554,6 +556,12 @@ int LiSendMouseButtonEvent(char action, int button);
#define MODIFIER_META 0x08
int LiSendKeyboardEvent(short keyCode, char keyAction, char modifiers);
// Similar to LiSendKeyboardEvent() but allows the client to inform the host that
// the keycode was not mapped to a standard US English scancode and should be
// interpreted as-is. This is a Sunshine protocol extension.
#define SS_KBE_FLAG_NON_NORMALIZED 0x01
int LiSendKeyboardEvent2(short keyCode, char keyAction, char modifiers, char flags);
// This function queues an UTF-8 encoded text to be sent to the remote server.
int LiSendUtf8TextEvent(const char *text, unsigned int length);