@@ -602,6 +602,11 @@ namespace xinput
602602
603603 void handle_digital_buttons (const XINPUT_GAMEPAD & current, const XINPUT_GAMEPAD & previous, const DWORD time)
604604 {
605+ if (is_overlay_blocking_input () && !pad.menu_mode )
606+ {
607+ return ;
608+ }
609+
605610 for (const auto & mapping : digital_buttons)
606611 {
607612 const auto was_down = (previous.wButtons & mapping.xinput_mask ) != 0 ;
@@ -646,6 +651,11 @@ namespace xinput
646651
647652 void handle_trigger_button (const float current_value, const float previous_value, const int gameplay_key, const int menu_key, const DWORD time)
648653 {
654+ if (is_overlay_blocking_input () && !pad.menu_mode )
655+ {
656+ return ;
657+ }
658+
649659 const auto was_down = previous_value > 0 .0f ;
650660 const auto is_down = current_value > 0 .0f ;
651661 if (was_down == is_down)
@@ -799,71 +809,34 @@ namespace xinput
799809
800810 int msg_read_bit (game::msg_t * msg)
801811 {
802- auto * const fields = reinterpret_cast <std::uint32_t *>(msg);
803- const auto bit_index = fields[8 ] & 7u ;
804- if (!bit_index)
812+ int value = 0 ;
813+ __asm
805814 {
806- const auto byte_index = fields[7 ];
807- if (byte_index >= fields[5 ] + fields[6 ])
808- {
809- fields[0 ] = 1 ;
810- return -1 ;
811- }
812-
813- fields[8 ] = byte_index * 8u ;
814- fields[7 ] = byte_index + 1u ;
815+ mov edx, msg
816+ xor ecx, ecx
817+ mov eax, 0x103EEDE0
818+ call eax
819+ mov value, eax
815820 }
816-
817- const auto byte_index = fields[8 ] >> 3u ;
818- const auto * const src = byte_index < fields[5 ]
819- ? reinterpret_cast <const std::uint8_t *>(fields[2 ])
820- : reinterpret_cast <const std::uint8_t *>(fields[3 ] - fields[5 ]);
821- ++fields[8 ];
822- return (src[byte_index] >> bit_index) & 1 ;
821+ return value;
823822 }
824823
825824 int msg_read_bits (game::msg_t * msg, int bits)
826825 {
827- auto * const fields = reinterpret_cast <std::uint32_t *>(msg);
828826 int value = 0 ;
829- int out_bit = 0 ;
830-
831- if (bits <= 0 )
827+ __asm
832828 {
833- return 0 ;
829+ push esi
830+ mov esi, msg
831+ push bits
832+ mov eax, 0x103EEE50
833+ call eax
834+ add esp, 4
835+ mov value, eax
836+ pop esi
834837 }
835838
836- while (true )
837- {
838- auto bit_index = fields[8 ] & 7u ;
839- if (!bit_index)
840- {
841- const auto byte_index = fields[7 ];
842- if (byte_index >= fields[5 ] + fields[6 ])
843- {
844- fields[0 ] = 1 ;
845- return -1 ;
846- }
847-
848- fields[8 ] = byte_index * 8u ;
849- fields[7 ] = byte_index + 1u ;
850- bit_index = 0 ;
851- }
852-
853- const auto byte_index = fields[8 ] >> 3u ;
854- const auto * const src = byte_index < fields[5 ]
855- ? reinterpret_cast <const std::uint8_t *>(fields[2 ])
856- : reinterpret_cast <const std::uint8_t *>(fields[3 ] - fields[5 ]);
857- const auto bit = (src[byte_index] >> bit_index) & 1 ;
858- ++fields[8 ];
859- value |= bit << out_bit;
860- ++out_bit;
861-
862- if (out_bit >= bits)
863- {
864- return value;
865- }
866- }
839+ return value;
867840 }
868841
869842 void ApplyMovement (game::msg_t * msg, int key, game::usercmd_t * from, game::usercmd_t * to)
@@ -887,17 +860,17 @@ namespace xinput
887860 // Original QoS callsite passes:
888861 // eax = msg_t*
889862 // edi = to usercmd
890- // [esp + 4] = key
891- // [esp + 8] = from usercmd
863+ // [esp + 4] = from usercmd
864+ // [esp + 8] = key
892865 push ebx
893866 push esi
894867
895868 mov ebx, [esp + 0Ch]
896869 mov esi, [esp + 10h]
897870
898871 push edi
899- push esi
900872 push ebx
873+ push esi
901874 push eax
902875 call ApplyMovement
903876 add esp, 10h
@@ -1174,12 +1147,6 @@ namespace xinput
11741147 {
11751148 return ;
11761149 }
1177-
1178- original_write_move_bits_a = utils::hook::get<std::uint16_t >(game::game_offset (0x103EF9CE ));
1179- original_write_move_bits_b = utils::hook::get<std::uint16_t >(game::game_offset (0x103EFA44 ));
1180-
1181- utils::hook::set<std::uint16_t >(game::game_offset (0x103EF9CE ), 0x106A );
1182- utils::hook::set<std::uint16_t >(game::game_offset (0x103EFA44 ), 0x106A );
11831150 utils::hook::call (game::game_offset (0x102F0DBC ), MSG_ReadDeltaUsercmdKey_stub);
11841151
11851152 usercmd_movement_patched = true ;
@@ -1237,9 +1204,6 @@ namespace xinput
12371204 return ;
12381205 }
12391206
1240- utils::hook::set<std::uint16_t >(game::game_offset (0x103EF9CE ), original_write_move_bits_a);
1241- utils::hook::set<std::uint16_t >(game::game_offset (0x103EFA44 ), original_write_move_bits_b);
1242-
12431207 usercmd_movement_patched = false ;
12441208 }
12451209
0 commit comments