@@ -320,7 +320,7 @@ static bool winraw_mouse_button_pressed(
320320 winraw_mouse_t * mouse ,
321321 unsigned port , unsigned key )
322322{
323- switch (key )
323+ switch (key )
324324 {
325325 case RETRO_DEVICE_ID_MOUSE_LEFT :
326326 return mouse -> btn_l ;
@@ -338,7 +338,7 @@ static bool winraw_mouse_button_pressed(
338338 return mouse -> whl_d ;
339339 }
340340
341- return false;
341+ return false;
342342}
343343
344344static void winraw_init_mouse_xy_mapping (winraw_input_t * wr )
@@ -368,6 +368,7 @@ static void winraw_update_mouse_state(winraw_input_t *wr,
368368 winraw_mouse_t * mouse , RAWMOUSE * state )
369369{
370370 POINT crs_pos ;
371+ bool swap_mouse_buttons = g_win32_flags & WIN32_CMN_FLAG_SWAP_MOUSE_BTNS ;
371372
372373 /* Used for fixing coordinates after switching resolutions */
373374 GetClientRect ((HWND )video_driver_window_get (), & wr -> prev_rect );
@@ -381,11 +382,11 @@ static void winraw_update_mouse_state(winraw_input_t *wr,
381382 }
382383 else
383384 {
384- int bottom = wr -> prev_rect .bottom ;
385- int right = wr -> prev_rect .right ;
386- wr -> active_rect = wr -> prev_rect ;
387- winraw_init_mouse_xy_mapping (wr );
388- wr -> rect_delay = 0 ;
385+ int bottom = wr -> prev_rect .bottom ;
386+ int right = wr -> prev_rect .right ;
387+ wr -> active_rect = wr -> prev_rect ;
388+ winraw_init_mouse_xy_mapping (wr );
389+ wr -> rect_delay = 0 ;
389390 }
390391 }
391392
@@ -465,20 +466,35 @@ static void winraw_update_mouse_state(winraw_input_t *wr,
465466 mouse -> y = crs_pos .y ;
466467 }
467468
468- if (state -> usButtonFlags & RI_MOUSE_LEFT_BUTTON_DOWN )
469- mouse -> btn_l = true;
470- else if (state -> usButtonFlags & RI_MOUSE_LEFT_BUTTON_UP )
471- mouse -> btn_l = false;
469+ if (swap_mouse_buttons )
470+ {
471+ if (state -> usButtonFlags & RI_MOUSE_LEFT_BUTTON_DOWN )
472+ mouse -> btn_r = true;
473+ else if (state -> usButtonFlags & RI_MOUSE_LEFT_BUTTON_UP )
474+ mouse -> btn_r = false;
475+
476+ if (state -> usButtonFlags & RI_MOUSE_RIGHT_BUTTON_DOWN )
477+ mouse -> btn_l = true;
478+ else if (state -> usButtonFlags & RI_MOUSE_RIGHT_BUTTON_UP )
479+ mouse -> btn_l = false;
480+ }
481+ else
482+ {
483+ if (state -> usButtonFlags & RI_MOUSE_LEFT_BUTTON_DOWN )
484+ mouse -> btn_l = true;
485+ else if (state -> usButtonFlags & RI_MOUSE_LEFT_BUTTON_UP )
486+ mouse -> btn_l = false;
487+
488+ if (state -> usButtonFlags & RI_MOUSE_RIGHT_BUTTON_DOWN )
489+ mouse -> btn_r = true;
490+ else if (state -> usButtonFlags & RI_MOUSE_RIGHT_BUTTON_UP )
491+ mouse -> btn_r = false;
492+ }
472493
473494 if (state -> usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_DOWN )
474- mouse -> btn_m = true;
495+ mouse -> btn_m = true;
475496 else if (state -> usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_UP )
476- mouse -> btn_m = false;
477-
478- if (state -> usButtonFlags & RI_MOUSE_RIGHT_BUTTON_DOWN )
479- mouse -> btn_r = true;
480- else if (state -> usButtonFlags & RI_MOUSE_RIGHT_BUTTON_UP )
481- mouse -> btn_r = false;
497+ mouse -> btn_m = false;
482498
483499 if (state -> usButtonFlags & RI_MOUSE_BUTTON_4_DOWN )
484500 mouse -> btn_b4 = true;
@@ -955,28 +971,26 @@ static int16_t winraw_input_state(
955971 }
956972 break ;
957973 case RETRO_DEVICE_LIGHTGUN :
958- switch (id )
959- {
960- /*aiming*/
961- case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X :
962- case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y :
963- case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN :
964- if (mouse )
965- return winraw_lightgun_aiming_state (wr , mouse , port , id );
966- break ;
967- /*buttons*/
968- case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER :
969- case RETRO_DEVICE_ID_LIGHTGUN_RELOAD :
970- case RETRO_DEVICE_ID_LIGHTGUN_AUX_A :
971- case RETRO_DEVICE_ID_LIGHTGUN_AUX_B :
972- case RETRO_DEVICE_ID_LIGHTGUN_AUX_C :
973- case RETRO_DEVICE_ID_LIGHTGUN_START :
974- case RETRO_DEVICE_ID_LIGHTGUN_SELECT :
975- case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP :
976- case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN :
977- case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT :
978- case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT :
979- case RETRO_DEVICE_ID_LIGHTGUN_PAUSE : /* deprecated */
974+ switch (id )
975+ {
976+ case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X :
977+ case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y :
978+ case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN :
979+ if (mouse )
980+ return winraw_lightgun_aiming_state (wr , mouse , port , id );
981+ break ;
982+ case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER :
983+ case RETRO_DEVICE_ID_LIGHTGUN_RELOAD :
984+ case RETRO_DEVICE_ID_LIGHTGUN_AUX_A :
985+ case RETRO_DEVICE_ID_LIGHTGUN_AUX_B :
986+ case RETRO_DEVICE_ID_LIGHTGUN_AUX_C :
987+ case RETRO_DEVICE_ID_LIGHTGUN_START :
988+ case RETRO_DEVICE_ID_LIGHTGUN_SELECT :
989+ case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP :
990+ case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN :
991+ case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT :
992+ case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT :
993+ case RETRO_DEVICE_ID_LIGHTGUN_PAUSE : /* deprecated */
980994 {
981995 unsigned new_id = winraw_retro_id_to_rarch (id );
982996 const uint64_t bind_joykey = input_config_binds [port ][new_id ].joykey ;
0 commit comments