@@ -688,7 +688,7 @@ bool input_driver_button_combo(
688688 return false;
689689}
690690
691- static int16_t input_state_wrap (
691+ static int32_t input_state_wrap (
692692 input_driver_t * current_input ,
693693 void * data ,
694694 const input_device_driver_t * joypad ,
@@ -701,7 +701,7 @@ static int16_t input_state_wrap(
701701 unsigned idx ,
702702 unsigned id )
703703{
704- int16_t ret = 0 ;
704+ int32_t ret = 0 ;
705705
706706 if (!binds )
707707 return 0 ;
@@ -780,18 +780,33 @@ static int16_t input_state_wrap(
780780 idx ,
781781 id );
782782
783- /* No binds, no input. This is for ignoring RETROK_UNKNOWN
784- * if the driver allows setting the key down somehow.
785- * Otherwise all hotkeys and inputs with null bind get triggered. */
786783 if (device == RETRO_DEVICE_JOYPAD )
787784 {
788- /* Drivers can also overflow when sending all keys at once,
789- * resulting in negative values which also need to be ignored.. */
790- if ( (id == RETRO_DEVICE_ID_JOYPAD_MASK && ret < 0 )
791- || ( binds [_port ][id ].key == RETROK_UNKNOWN
792- && binds [_port ][id ].mbutton == NO_BTN
793- && binds [_port ][id ].joykey == NO_BTN
794- && binds [_port ][id ].joyaxis == AXIS_NONE ))
785+ /* Drivers can overflow when sending too many keys at once.. */
786+ if (id == RETRO_DEVICE_ID_JOYPAD_MASK && ret )
787+ {
788+ /* Deal with menu toggle combo buttons that won't stay inside +32767. */
789+ if (ret == -0x8000 ) /* R3 */
790+ ret = 0x8000 ;
791+ else if (ret == -0x4000 ) /* LR+R3 */
792+ ret = 0x8000 + 0x4000 ;
793+ else if (ret < 0 )
794+ ret = 0 ;
795+ return ret ;
796+ }
797+
798+ /* No binds, no input. This is for ignoring RETROK_UNKNOWN
799+ * if the driver allows setting the key down somehow.
800+ * Otherwise all hotkeys and inputs with null bind get triggered. */
801+ if ( id != RETRO_DEVICE_ID_JOYPAD_MASK && ret
802+ && binds [_port ][id ].key == RETROK_UNKNOWN
803+ && binds [_port ][id ].mbutton == NO_BTN
804+ && ( ( binds [_port ][id ].joykey == NO_BTN
805+ && binds [_port ][id ].joyaxis == AXIS_NONE )
806+ || ( joypad_info -> auto_binds [id ].joykey == NO_BTN
807+ && joypad_info -> auto_binds [id ].joyaxis == AXIS_NONE )
808+ )
809+ )
795810 return 0 ;
796811 }
797812
@@ -1213,7 +1228,7 @@ static int16_t input_state_device(
12131228 settings_t * settings ,
12141229 input_mapper_t * handle ,
12151230 unsigned input_analog_dpad_mode ,
1216- int16_t ret ,
1231+ int32_t ret ,
12171232 unsigned port , unsigned device ,
12181233 unsigned idx , unsigned id ,
12191234 bool button_mask )
@@ -1594,8 +1609,8 @@ static int16_t input_state_internal(
15941609 * 'virtual' port index */
15951610 while ((mapped_port = * (input_remap_port_map ++ )) < MAX_USERS )
15961611 {
1597- int16_t ret = 0 ;
1598- int16_t port_result = 0 ;
1612+ int32_t ret = 0 ;
1613+ int32_t port_result = 0 ;
15991614 unsigned input_analog_dpad_mode = settings -> uints .input_analog_dpad_mode [mapped_port ];
16001615
16011616 joypad_info .joy_idx = settings -> uints .input_joypad_index [mapped_port ];
@@ -4833,7 +4848,7 @@ static void input_keys_pressed(
48334848 }
48344849
48354850 {
4836- int16_t ret = 0 ;
4851+ int32_t ret = 0 ;
48374852 bool libretro_input_pressed = false;
48384853
48394854 /* Check libretro input if emulated device type is active,
@@ -5588,7 +5603,7 @@ void input_driver_poll(void)
55885603 if (joypad )
55895604 {
55905605 unsigned k , j ;
5591- int16_t ret = input_state_wrap (
5606+ int32_t ret = input_state_wrap (
55925607 input_st -> current_driver ,
55935608 input_st -> current_data ,
55945609 input_st -> primary_joypad ,
0 commit comments