@@ -3199,7 +3199,7 @@ void input_overlay_auto_rotate_(
31993199
32003200/**
32013201 * input_overlay_poll_lightgun
3202- * @settings: pointer to settings
3202+ * @settings : pointer to settings
32033203 * @ol : overlay handle
32043204 * @old_ptr_count : previous poll's non-hitbox pointer count
32053205 *
@@ -3319,8 +3319,10 @@ static void input_overlay_get_mouse_scale(settings_t *settings,
33193319
33203320/**
33213321 * input_overlay_poll_mouse
3322- * @settings: pointer to settings
3322+ * @settings : pointer to settings
3323+ * @mouse_st : pointer to overlay mouse state
33233324 * @ol : overlay handle
3325+ * @ptr_count : this poll's non-hitbox pointer count
33243326 * @old_ptr_count : previous poll's non-hitbox pointer count
33253327 *
33263328 * Updates button state of the overlay mouse.
@@ -3331,15 +3333,16 @@ static void input_overlay_poll_mouse(settings_t *settings,
33313333 const int ptr_count ,
33323334 const int old_ptr_count )
33333335{
3334- input_overlay_pointer_state_t * ptr_st = & ol -> pointer_state ;
3335- const retro_time_t now_usec = cpu_features_get_time_usec ();
3336- const retro_time_t hold_usec = settings -> uints .input_overlay_mouse_hold_msec * 1000 ;
3337- const retro_time_t dtap_usec = settings -> uints .input_overlay_mouse_dtap_msec * 1000 ;
3338- int swipe_thres_x = 0 ;
3339- int swipe_thres_y = 0 ;
3340- const bool hold_to_drag = settings -> bools .input_overlay_mouse_hold_to_drag ;
3341- const bool dtap_to_drag = settings -> bools .input_overlay_mouse_dtap_to_drag ;
3342- bool want_feedback = false;
3336+ input_overlay_pointer_state_t * ptr_st = & ol -> pointer_state ;
3337+ const retro_time_t now_usec = cpu_features_get_time_usec ();
3338+ const retro_time_t hold_usec = settings -> uints .input_overlay_mouse_hold_msec * 1000 ;
3339+ const retro_time_t dtap_usec = settings -> uints .input_overlay_mouse_dtap_msec * 1000 ;
3340+ const uint8_t alt_2touch = settings -> uints .input_overlay_mouse_alt_two_touch_input ;
3341+ int swipe_thres_x = 0 ;
3342+ int swipe_thres_y = 0 ;
3343+ const bool hold_to_drag = settings -> bools .input_overlay_mouse_hold_to_drag ;
3344+ const bool dtap_to_drag = settings -> bools .input_overlay_mouse_dtap_to_drag ;
3345+ bool want_feedback = false;
33433346 bool is_swipe , is_brief , is_long ;
33443347
33453348 static retro_time_t start_usec ;
@@ -3352,8 +3355,10 @@ static void input_overlay_poll_mouse(settings_t *settings,
33523355 static int y_start ;
33533356 static int peak_ptr_count ;
33543357 static int old_peak_ptr_count ;
3355- static bool skip_buttons ;
3358+ static bool check_gestures ;
33563359 static bool pending_click ;
3360+ static const uint8_t btns [OVERLAY_MAX_TOUCH + 1 ] =
3361+ {0x0 , 0x1 , 0x2 , 0x4 }; /* none, lmb, rmb, mmb */
33573362
33583363 input_overlay_get_mouse_scale (settings ,
33593364 (float * )& mouse_st -> scale_x , & mouse_st -> scale_y ,
@@ -3374,6 +3379,11 @@ static void input_overlay_poll_mouse(settings_t *settings,
33743379 /* Pointer added */
33753380 peak_ptr_count = ptr_count ;
33763381 start_usec = now_usec ;
3382+
3383+ /* Alt 2-touch input. After gesture checks,
3384+ * use 2nd touch as a button */
3385+ if (!check_gestures && ptr_count == 2 )
3386+ mouse_st -> hold = btns [alt_2touch ];
33773387 }
33783388 else
33793389 {
@@ -3391,15 +3401,15 @@ static void input_overlay_poll_mouse(settings_t *settings,
33913401 is_long = (now_usec - start_usec ) > (hold_to_drag ? hold_usec : 250000 );
33923402
33933403 /* Check if new button input should be created */
3394- if (! skip_buttons )
3404+ if (check_gestures )
33953405 {
33963406 if (!is_swipe )
33973407 {
33983408 if ( hold_to_drag
33993409 && is_long && ptr_count && !mouse_st -> hold )
34003410 {
34013411 /* Long press */
3402- mouse_st -> hold = ( 1 << ( ptr_count - 1 )) ;
3412+ mouse_st -> hold = btns [ ptr_count ] ;
34033413 want_feedback = true;
34043414 }
34053415 else if (is_brief )
@@ -3409,7 +3419,7 @@ static void input_overlay_poll_mouse(settings_t *settings,
34093419 /* New input. Check for double tap */
34103420 if ( dtap_to_drag
34113421 && now_usec - last_up_usec < dtap_usec )
3412- mouse_st -> hold = ( 1 << ( old_peak_ptr_count - 1 )) ;
3422+ mouse_st -> hold = btns [ old_peak_ptr_count ] ;
34133423
34143424 last_down_usec = now_usec ;
34153425 }
@@ -3425,7 +3435,7 @@ static void input_overlay_poll_mouse(settings_t *settings,
34253435 }
34263436 else
34273437 {
3428- mouse_st -> click = ( 1 << ( peak_ptr_count - 1 )) ;
3438+ mouse_st -> click = btns [ peak_ptr_count ] ;
34293439 click_end_usec = now_usec + click_dur_usec ;
34303440 }
34313441
@@ -3435,14 +3445,19 @@ static void input_overlay_poll_mouse(settings_t *settings,
34353445 }
34363446 else
34373447 {
3438- /* If dragging 2+ fingers, hold RMB or MMB */
3448+ /* Swiping. Stop gesture checks and possibly hold a button */
34393449 if (ptr_count > 1 )
34403450 {
3441- mouse_st -> hold = (1 << (ptr_count - 1 ));
3442- if (hold_to_drag )
3451+ if (hold_to_drag && !alt_2touch )
3452+ {
3453+ mouse_st -> hold = btns [ptr_count ];
34433454 want_feedback = true;
3455+ }
3456+ else if (alt_2touch && !hold_to_drag
3457+ && ptr_count == 2 )
3458+ mouse_st -> hold = btns [alt_2touch ];
34443459 }
3445- skip_buttons = true ;
3460+ check_gestures = false ;
34463461 }
34473462 }
34483463
@@ -3455,9 +3470,9 @@ static void input_overlay_poll_mouse(settings_t *settings,
34553470 }
34563471
34573472 if (!ptr_count )
3458- skip_buttons = false; /* Reset button checks */
3473+ check_gestures = true;
34593474 else if (is_long )
3460- skip_buttons = true; /* End of button checks */
3475+ check_gestures = false;
34613476
34623477 /* Remove stale clicks */
34633478 if (mouse_st -> click && now_usec > click_end_usec )
0 commit comments