@@ -209,6 +209,7 @@ static inline logitech_g27_sdl_mapping get_runtime_mapping()
209209 convert_mapping (cfg.shifter_5 , mapping.shifter_5 );
210210 convert_mapping (cfg.shifter_6 , mapping.shifter_6 );
211211 convert_mapping (cfg.shifter_r , mapping.shifter_r );
212+ convert_mapping (cfg.shifter_press , mapping.shifter_press );
212213
213214 return mapping;
214215}
@@ -711,6 +712,7 @@ void usb_device_logitech_g27::interrupt_transfer(u32 buf_size, u8* buf, u32 endp
711712 const bool shifter_5 = sdl_to_logitech_g27_button (m_joysticks, m_mapping.shifter_5 );
712713 const bool shifter_6 = sdl_to_logitech_g27_button (m_joysticks, m_mapping.shifter_6 );
713714 const bool shifter_r = sdl_to_logitech_g27_button (m_joysticks, m_mapping.shifter_r );
715+ const bool shifter_press = sdl_to_logitech_g27_button (m_joysticks, m_mapping.shifter_press );
714716 m_sdl_handles_mutex.unlock ();
715717
716718 // populate buffer
@@ -750,16 +752,64 @@ void usb_device_logitech_g27::interrupt_transfer(u32 buf_size, u8* buf, u32 endp
750752 // shifter connected
751753 set_bit (buf, 83 , true );
752754 // shifter stick down
753- set_bit (buf, 86 , shifter_1 || shifter_2 || shifter_3 || shifter_4 || shifter_5 || shifter_6 || shifter_r );
755+ set_bit (buf, 86 , shifter_press );
754756
755757 buf[3 ] = (steering << 2 ) | buf[3 ];
756758 buf[4 ] = steering >> 6 ;
757759 buf[5 ] = throttle;
758760 buf[6 ] = brake;
759761 buf[7 ] = clutch;
760762
761- buf[8 ] = 0x80 ; // shifter x, don't own one to test gear/coord mapping
762- buf[9 ] = 0x80 ; // shifter y
763+ // rough analog values recorded in https://github.com/RPCS3/rpcs3/pull/17199#issuecomment-2883934412
764+ // buf[8] shifter x
765+ // buf[9] shifter y
766+ constexpr u8 shifter_coord_center = 0x80 ;
767+ constexpr u8 shifter_coord_top = 0xb7 ;
768+ constexpr u8 shifter_coord_bottom = 0x32 ;
769+ constexpr u8 shifter_coord_left = 0x30 ;
770+ constexpr u8 shifter_coord_right = 0xb3 ;
771+ constexpr u8 shifter_coord_right_reverse = 0xaa ;
772+ if (shifter_1)
773+ {
774+ buf[8 ] = shifter_coord_left;
775+ buf[9 ] = shifter_coord_top;
776+ }
777+ else if (shifter_2)
778+ {
779+ buf[8 ] = shifter_coord_left;
780+ buf[9 ] = shifter_coord_bottom;
781+ }
782+ else if (shifter_3)
783+ {
784+ buf[8 ] = shifter_coord_center;
785+ buf[9 ] = shifter_coord_top;
786+ }
787+ else if (shifter_4)
788+ {
789+ buf[8 ] = shifter_coord_center;
790+ buf[9 ] = shifter_coord_bottom;
791+ }
792+ else if (shifter_5)
793+ {
794+ buf[8 ] = shifter_coord_right;
795+ buf[9 ] = shifter_coord_top;
796+ }
797+ else if (shifter_6)
798+ {
799+ buf[8 ] = shifter_coord_right;
800+ buf[9 ] = shifter_coord_bottom;
801+ }
802+ else if (shifter_r)
803+ {
804+ buf[8 ] = shifter_coord_right_reverse;
805+ buf[9 ] = shifter_coord_bottom;
806+ }
807+ else
808+ {
809+ buf[8 ] = shifter_coord_center;
810+ buf[9 ] = shifter_coord_center;
811+ }
812+
763813 buf[10 ] = buf[10 ] | (m_wheel_range > 360 ? 0x90 : 0x10 );
764814
765815 // logitech_g27_log.error("%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[10]);
0 commit comments