From e42de9d155e2fe44793d3b4550ffe5d42ea6f9f1 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 18 Jun 2023 14:32:18 -0500 Subject: [PATCH] Add extended button support with Sunshine --- app/streaming/input/gamepad.cpp | 12 +++++++++++- app/streaming/input/input.h | 2 +- moonlight-common-c/moonlight-common-c | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/streaming/input/gamepad.cpp b/app/streaming/input/gamepad.cpp index 526e12dd..728d0f0e 100644 --- a/app/streaming/input/gamepad.cpp +++ b/app/streaming/input/gamepad.cpp @@ -27,7 +27,10 @@ const int SdlInputHandler::k_ButtonMap[] = { BACK_FLAG, SPECIAL_FLAG, PLAY_FLAG, LS_CLK_FLAG, RS_CLK_FLAG, LB_FLAG, RB_FLAG, - UP_FLAG, DOWN_FLAG, LEFT_FLAG, RIGHT_FLAG + UP_FLAG, DOWN_FLAG, LEFT_FLAG, RIGHT_FLAG, + MISC_FLAG, + PADDLE1_FLAG, PADDLE2_FLAG, PADDLE3_FLAG, PADDLE4_FLAG, + TOUCHPAD_FLAG, }; GamepadState* @@ -162,6 +165,13 @@ void SdlInputHandler::handleControllerAxisEvent(SDL_ControllerAxisEvent* event) void SdlInputHandler::handleControllerButtonEvent(SDL_ControllerButtonEvent* event) { + if (event->button >= SDL_arraysize(k_ButtonMap)) { + SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, + "No mapping for gamepad button: %u", + event->button); + return; + } + GamepadState* state = findStateForGamepad(event->which); if (state == NULL) { return; diff --git a/app/streaming/input/input.h b/app/streaming/input/input.h index 41aa3f77..e9e519f0 100644 --- a/app/streaming/input/input.h +++ b/app/streaming/input/input.h @@ -19,7 +19,7 @@ struct GamepadState { SDL_TimerID mouseEmulationTimer; uint32_t lastStartDownTime; - short buttons; + int buttons; short lsX, lsY; short rsX, rsY; unsigned char lt, rt; diff --git a/moonlight-common-c/moonlight-common-c b/moonlight-common-c/moonlight-common-c index c9426a6a..9bf09d68 160000 --- a/moonlight-common-c/moonlight-common-c +++ b/moonlight-common-c/moonlight-common-c @@ -1 +1 @@ -Subproject commit c9426a6a71c4162e65dde8c0c71a25f1dbca46ba +Subproject commit 9bf09d681ef21e5a1284b50a850fe4e5df3afbe3