@@ -432,8 +432,7 @@ static bool dinput_mouse_button_pressed(
432
432
static int16_t dinput_lightgun_aiming_state (
433
433
struct dinput_input * di , unsigned idx , unsigned id )
434
434
{
435
- struct video_viewport vp ;
436
- const int edge_detect = 32700 ;
435
+ struct video_viewport vp = {0 };
437
436
int16_t res_x = 0 ;
438
437
int16_t res_y = 0 ;
439
438
int16_t res_screen_x = 0 ;
@@ -446,13 +445,6 @@ static int16_t dinput_lightgun_aiming_state(
446
445
struct dinput_pointer_status
447
446
* check_pos = di -> pointer_head .next ;
448
447
449
- vp .x = 0 ;
450
- vp .y = 0 ;
451
- vp .width = 0 ;
452
- vp .height = 0 ;
453
- vp .full_width = 0 ;
454
- vp .full_height = 0 ;
455
-
456
448
while (check_pos && num < idx )
457
449
{
458
450
num ++ ;
@@ -475,24 +467,14 @@ static int16_t dinput_lightgun_aiming_state(
475
467
& vp , x , y ,
476
468
& res_x , & res_y , & res_screen_x , & res_screen_y ))
477
469
{
478
- bool inside =
479
- (res_x >= - edge_detect )
480
- && (res_y >= - edge_detect )
481
- && (res_x <= edge_detect )
482
- && (res_y <= edge_detect );
483
-
484
470
switch (id )
485
471
{
486
472
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X :
487
- if (inside )
488
- return res_x ;
489
- break ;
473
+ return res_x ;
490
474
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y :
491
- if (inside )
492
- return res_y ;
493
- break ;
475
+ return res_y ;
494
476
case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN :
495
- return ! inside ;
477
+ return input_driver_pointer_is_offscreen ( res_x , res_y ) ;
496
478
default :
497
479
break ;
498
480
}
@@ -501,41 +483,6 @@ static int16_t dinput_lightgun_aiming_state(
501
483
return 0 ;
502
484
}
503
485
504
- static unsigned dinput_retro_id_to_rarch (unsigned id )
505
- {
506
- switch (id )
507
- {
508
- case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT :
509
- return RARCH_LIGHTGUN_DPAD_RIGHT ;
510
- case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT :
511
- return RARCH_LIGHTGUN_DPAD_LEFT ;
512
- case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP :
513
- return RARCH_LIGHTGUN_DPAD_UP ;
514
- case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN :
515
- return RARCH_LIGHTGUN_DPAD_DOWN ;
516
- case RETRO_DEVICE_ID_LIGHTGUN_SELECT :
517
- return RARCH_LIGHTGUN_SELECT ;
518
- case RETRO_DEVICE_ID_LIGHTGUN_PAUSE :
519
- return RARCH_LIGHTGUN_START ;
520
- case RETRO_DEVICE_ID_LIGHTGUN_RELOAD :
521
- return RARCH_LIGHTGUN_RELOAD ;
522
- case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER :
523
- return RARCH_LIGHTGUN_TRIGGER ;
524
- case RETRO_DEVICE_ID_LIGHTGUN_AUX_A :
525
- return RARCH_LIGHTGUN_AUX_A ;
526
- case RETRO_DEVICE_ID_LIGHTGUN_AUX_B :
527
- return RARCH_LIGHTGUN_AUX_B ;
528
- case RETRO_DEVICE_ID_LIGHTGUN_AUX_C :
529
- return RARCH_LIGHTGUN_AUX_C ;
530
- case RETRO_DEVICE_ID_LIGHTGUN_START :
531
- return RARCH_LIGHTGUN_START ;
532
- default :
533
- break ;
534
- }
535
-
536
- return 0 ;
537
- }
538
-
539
486
static int16_t dinput_input_state (
540
487
void * data ,
541
488
const input_device_driver_t * joypad ,
@@ -717,8 +664,7 @@ static int16_t dinput_input_state(
717
664
case RETRO_DEVICE_POINTER :
718
665
case RARCH_DEVICE_POINTER_SCREEN :
719
666
{
720
- struct video_viewport vp ;
721
- bool inside = false;
667
+ struct video_viewport vp = {0 };
722
668
int x = 0 ;
723
669
int y = 0 ;
724
670
int16_t res_x = 0 ;
@@ -729,13 +675,6 @@ static int16_t dinput_input_state(
729
675
struct dinput_pointer_status *
730
676
check_pos = di -> pointer_head .next ;
731
677
732
- vp .x = 0 ;
733
- vp .y = 0 ;
734
- vp .width = 0 ;
735
- vp .height = 0 ;
736
- vp .full_width = 0 ;
737
- vp .full_height = 0 ;
738
-
739
678
while (check_pos && num < idx )
740
679
{
741
680
num ++ ;
@@ -753,7 +692,7 @@ static int16_t dinput_input_state(
753
692
y = check_pos -> pointer_y ;
754
693
}
755
694
756
- if (video_driver_translate_coord_viewport_wrap (& vp , x , y ,
695
+ if (video_driver_translate_coord_viewport_confined_wrap (& vp , x , y ,
757
696
& res_x , & res_y , & res_screen_x , & res_screen_y ))
758
697
{
759
698
if (device == RARCH_DEVICE_POINTER_SCREEN )
@@ -762,19 +701,18 @@ static int16_t dinput_input_state(
762
701
res_y = res_screen_y ;
763
702
}
764
703
765
- if (( inside = ( res_x >= -0x7fff ) && ( res_y >= -0x7fff )) )
704
+ switch ( id )
766
705
{
767
- switch (id )
768
- {
769
- case RETRO_DEVICE_ID_POINTER_X :
770
- return res_x ;
771
- case RETRO_DEVICE_ID_POINTER_Y :
772
- return res_y ;
773
- case RETRO_DEVICE_ID_POINTER_PRESSED :
774
- return check_pos ? 1 : (di -> flags & DINP_FLAG_MOUSE_L_BTN ) > 0 ;
775
- default :
776
- break ;
777
- }
706
+ case RETRO_DEVICE_ID_POINTER_X :
707
+ return res_x ;
708
+ case RETRO_DEVICE_ID_POINTER_Y :
709
+ return res_y ;
710
+ case RETRO_DEVICE_ID_POINTER_PRESSED :
711
+ return check_pos ? 1 : (di -> flags & DINP_FLAG_MOUSE_L_BTN ) > 0 ;
712
+ case RETRO_DEVICE_ID_POINTER_IS_OFFSCREEN :
713
+ return input_driver_pointer_is_offscreen (res_x , res_y );
714
+ default :
715
+ break ;
778
716
}
779
717
}
780
718
}
@@ -802,7 +740,7 @@ static int16_t dinput_input_state(
802
740
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT :
803
741
case RETRO_DEVICE_ID_LIGHTGUN_PAUSE :
804
742
{
805
- unsigned new_id = dinput_retro_id_to_rarch (id );
743
+ unsigned new_id = input_driver_lightgun_id_convert (id );
806
744
const uint64_t bind_joykey = input_config_binds [port ][new_id ].joykey ;
807
745
const uint64_t bind_joyaxis = input_config_binds [port ][new_id ].joyaxis ;
808
746
const uint64_t autobind_joykey = input_autoconf_binds [port ][new_id ].joykey ;
0 commit comments