1616#define QUIT_BUTTONS (PLAY_FLAG | BACK_FLAG | LB_FLAG | RB_FLAG)
1717/** Hold Select (Back) this long to toggle pinned performance stats (Artemis-style). */
1818#define GAMEPAD_HOLD_STATS_MS 4000
19- /** Hold Start (Play) this long to toggle virtual mouse (Artemis-style). */
20- #define GAMEPAD_HOLD_VMOUSE_MS 4000
2119
2220static bool quit_combo_pressed = false;
2321
24- /** Hold timers only detect shortcuts ; Select/Start are always forwarded to the host. */
22+ /** Hold timer only detects Select→stats shortcut ; Select is still forwarded to the host. */
2523static SDL_TimerID stats_hold_timer = 0 ;
26- static SDL_TimerID vmouse_hold_timer = 0 ;
2724
2825static void release_buttons (stream_input_t * input , app_gamepad_state_t * gamepad );
2926
@@ -42,14 +39,10 @@ static void stream_input_send_buttons(stream_input_t *input, app_gamepad_state_t
4239
4340static void cancel_stats_hold (void );
4441
45- static void cancel_vmouse_hold (void );
46-
4742static void cancel_all_holds (void );
4843
4944static Uint32 stats_hold_timer_cb (Uint32 interval , void * param );
5045
51- static Uint32 vmouse_hold_timer_cb (Uint32 interval , void * param );
52-
5346static bool stream_input_gamepad_sends_moonlight (const stream_input_t * input ,
5447 const app_gamepad_state_t * gamepad ) {
5548 (void ) input ;
@@ -66,6 +59,15 @@ void stream_input_handle_cbutton(stream_input_t *input, const SDL_ControllerButt
6659 if (gamepad == NULL ) {
6760 return ;
6861 }
62+
63+ /* Physical Y/Triangle opens the soft keyboard only while virtual mouse is active. */
64+ if (event -> type == SDL_CONTROLLERBUTTONDOWN && event -> button == SDL_CONTROLLER_BUTTON_Y
65+ && session_input_is_vmouse_active (& input -> vmouse )) {
66+ cancel_all_holds ();
67+ bus_pushevent (USER_OPEN_SOFT_KEYBOARD , NULL , NULL );
68+ return ;
69+ }
70+
6971 int button = 0 ;
7072 switch (event -> button ) {
7173 case SDL_CONTROLLER_BUTTON_A :
@@ -154,27 +156,15 @@ void stream_input_handle_cbutton(stream_input_t *input, const SDL_ControllerButt
154156 return ;
155157 }
156158
157- /* Select/Start always go to the host. Hold timers only arm client shortcuts . */
159+ /* Select always goes to the host. Hold timer only arms the stats shortcut . */
158160 if (event -> type == SDL_CONTROLLERBUTTONDOWN && button == BACK_FLAG ) {
159- cancel_vmouse_hold ();
160161 cancel_stats_hold ();
161162 stats_hold_timer = SDL_AddTimer (GAMEPAD_HOLD_STATS_MS , stats_hold_timer_cb , NULL );
162163 } else if (event -> type == SDL_CONTROLLERBUTTONUP && button == BACK_FLAG ) {
163164 cancel_stats_hold ();
164- } else if (event -> type == SDL_CONTROLLERBUTTONDOWN && button == PLAY_FLAG ) {
165- cancel_stats_hold ();
166- cancel_vmouse_hold ();
167- vmouse_hold_timer = SDL_AddTimer (GAMEPAD_HOLD_VMOUSE_MS , vmouse_hold_timer_cb , NULL );
168- } else if (event -> type == SDL_CONTROLLERBUTTONUP && button == PLAY_FLAG ) {
169- cancel_vmouse_hold ();
170- } else {
165+ } else if (button != BACK_FLAG ) {
171166 /* Mixing other buttons with a pending hold cancels the shortcut. */
172- if (button != BACK_FLAG ) {
173- cancel_stats_hold ();
174- }
175- if (button != PLAY_FLAG ) {
176- cancel_vmouse_hold ();
177- }
167+ cancel_stats_hold ();
178168 }
179169
180170 stream_input_send_buttons (input , gamepad );
@@ -467,16 +457,8 @@ static void cancel_stats_hold(void) {
467457 }
468458}
469459
470- static void cancel_vmouse_hold (void ) {
471- if (vmouse_hold_timer ) {
472- SDL_RemoveTimer (vmouse_hold_timer );
473- vmouse_hold_timer = 0 ;
474- }
475- }
476-
477460static void cancel_all_holds (void ) {
478461 cancel_stats_hold ();
479- cancel_vmouse_hold ();
480462}
481463
482464static Uint32 stats_hold_timer_cb (Uint32 interval , void * param ) {
@@ -488,15 +470,6 @@ static Uint32 stats_hold_timer_cb(Uint32 interval, void *param) {
488470 return 0 ;
489471}
490472
491- static Uint32 vmouse_hold_timer_cb (Uint32 interval , void * param ) {
492- (void ) interval ;
493- (void ) param ;
494- vmouse_hold_timer = 0 ;
495- bus_pushevent (USER_TOGGLE_VMOUSE , NULL , NULL );
496- commons_log_info ("Input" , "Start held %dms — toggle virtual mouse" , GAMEPAD_HOLD_VMOUSE_MS );
497- return 0 ;
498- }
499-
500473static void release_buttons (stream_input_t * input , app_gamepad_state_t * gamepad ) {
501474 gamepad -> buttons = 0 ;
502475 gamepad -> leftTrigger = 0 ;
0 commit comments