-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathKey.cpp
648 lines (607 loc) · 20.6 KB
/
Key.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
#include "pch.h"
#include <windows.h>
#include "UI.h"
#include "Key.h"
#include <XInput.h>
#include "Address.h"
#include "Connection.h"
#include "Utils.h"
#include <unordered_map>
#include <format>
#include <random>
#include "States.h"
#include <dinput.h>
#undef max
#undef min
extern P2PConnection g_connection;
extern bool g_is_focus_ui;
extern int g_ui_frame;
extern LARGE_INTEGER g_cur_time;
std::unordered_map<int, KeyState> g_keystate_self;
std::unordered_map<int, KeyState> g_keystate_rcved;
extern bool g_is_loading;
bool IsOnWindow()
{
return Address<BYTE>(GetAddress(0x609178)).GetValue() && (!g_is_focus_ui);
}
DWORD GetKeyStateFull_original(DWORD keyStruct, __int16* keyMapStruct)
{
if (!IsOnWindow())
return 0;
GetKeyboardState((PBYTE)(keyStruct + 720));
DWORD v1 = keyStruct;
__int16* v4 = keyMapStruct;
int v5 = 2 // 755=end 733=enter 756=home 800=P 802=R
* (*(BYTE*)(v4[22] + v1 + 720) & 0x80 | (((*(BYTE*)(v1 + 756) | *(BYTE*)(v1 + 800)) & 0x80 | (2 * (*(BYTE*)(v1 + 733) & 0x80 | (4 * ((*(BYTE*)(v1 + 755) | *(BYTE*)(v1 + 802)) & 0x80))))) << 10));
int ks = (*(char*)(v1 + 823) >> 31) & 0x50 | (*(char*)(v1 + 817) >> 31) & 0x60 | ((unsigned __int8)(*(char*)(v1 + 819) >> 7) | (*(BYTE*)(v1 + 822) | *(BYTE*)(v4[26] + v1 + 720)) & 0xDF) & 0xA0 | ((unsigned __int8)(*(char*)(v1 + 825) >> 7) | ((*(unsigned __int8*)(v1 + 824) | (unsigned int)*(unsigned __int8*)(v4[23] + v1 + 720)) >> 3) & 0x10) & 0x90 | v5 | (((*(BYTE*)(v1 + 820) | *(BYTE*)(v4[25] + v1 + 720)) & 0x80 | (((*(BYTE*)(v1 + 818) | *(BYTE*)(v4[24] + v1 + 720)) & 0x80 | ((*(BYTE*)(v4[21] + v1 + 720) & 0x80 | ((*(BYTE*)(v4[20] + v1 + 720) & 0x80 | (((*(unsigned __int8*)(v4[18] + v1 + 720) >> 1) | *(BYTE*)(v4[19] + v1 + 720) & 0x80u) >> 1)) >> 1)) >> 2)) >> 1)) >> 1);
return ks;
}
DWORD GetKeyStateP1_original(DWORD keyStruct, __int16* keyMapStruct)
{
if (!IsOnWindow())
return 0;
return GetKeyStateFull_original(keyStruct, keyMapStruct);
GetKeyboardState((PBYTE)(keyStruct + 720));
DWORD v1 = keyStruct;
__int16* v4 = keyMapStruct;
int ks = *(BYTE*)(v4[35] + v1 + 720) & 0x80 | (2 * (*(BYTE*)(v4[31] + v1 + 720) & 0x80)) | ((*(BYTE*)(v4[34] + v1 + 720) & 0x80 | ((*(BYTE*)(v4[33] + v1 + 720) & 0x80 | ((*(BYTE*)(v4[32] + v1 + 720) & 0x80 | ((*(BYTE*)(v4[30] + v1 + 720) & 0x80 | ((*(BYTE*)(v4[29] + v1 + 720) & 0x80 | (((*(unsigned __int8*)(v4[27] + v1 + 720) >> 1) | *(BYTE*)(v4[28] + v1 + 720) & 0x80u) >> 1)) >> 1)) >> 1)) >> 1)) >> 1)) >> 1);
return ks;
}
DWORD GetKeyStateP2_original(DWORD keyStruct, __int16* keyMapStruct)
{
if (!IsOnWindow())
return 0;
return GetKeyStateFull_original(keyStruct, keyMapStruct);
GetKeyboardState((PBYTE)(keyStruct + 720));
DWORD v1 = keyStruct;
__int16* v4 = keyMapStruct;
int ks = *(BYTE*)(v4[44] + v1 + 720) & 0x80 | (2 * (*(BYTE*)(v4[40] + v1 + 720) & 0x80)) | ((*(BYTE*)(v4[43] + v1 + 720) & 0x80 | ((*(BYTE*)(v4[42] + v1 + 720) & 0x80 | ((*(BYTE*)(v4[41] + v1 + 720) & 0x80 | ((*(BYTE*)(v4[39] + v1 + 720) & 0x80 | ((*(BYTE*)(v4[38] + v1 + 720) & 0x80 | (((*(unsigned __int8*)(v4[36] + v1 + 720) >> 1) | *(BYTE*)(v4[37] + v1 + 720) & 0x80u) >> 1)) >> 1)) >> 1)) >> 1)) >> 1)) >> 1);
return ks;
}
DWORD GetKeyStateGamePad_xinput_original(DWORD keyStruct, __int16* keyMapStruct, XINPUT_STATE* ipState,bool* has_gp)
{
DWORD ks;
if (!IsOnWindow())
return 0;
DWORD v30 = *(DWORD*)(keyStruct + 12);
XINPUT_STATE& state=*ipState;
memset(&state, 0, sizeof(state));
if (XInputGetState(v30, &state))
{
*has_gp = false;
return 0;
}
*has_gp = true;
DWORD kst = state.Gamepad.wButtons;
if (state.Gamepad.bLeftTrigger >= 0x1Eu)
kst = state.Gamepad.wButtons | 0x10000;
if (state.Gamepad.bRightTrigger >= 0x1Eu)
kst |= 0x20000u;
if (state.Gamepad.sThumbLY >= 7849)
kst |= 1u;
if (state.Gamepad.sThumbLY <= -7849)
kst |= 2u;
if (state.Gamepad.sThumbLX >= 7849)
kst |= 8u;
if (state.Gamepad.sThumbLX <= -7849)
kst |= 4u;
DWORD v7 = (0x10 * (kst & 1)) | 0x20;
if ((kst & 2) == 0)
v7 = 0x10 * (kst & 1);
DWORD v8 = v7 | 0x40;
if ((kst & 4) == 0)
v8 = v7;
DWORD v9 = v8 | 0x80;
if ((kst & 8) == 0)
v9 = v8;
DWORD v10 = v9 | 1;
DWORD v11, v12, v13;
{
DWORD* dword_5743E8 = (DWORD*)(GetAddress(0x5743E8));
if ((kst & dword_5743E8[keyMapStruct[9]]) == 0)
v10 = v9;
v11 = v10 | 2;
if ((kst & dword_5743E8[keyMapStruct[10]]) == 0)
v11 = v10;
v12 = v11 | 4;
if ((kst & dword_5743E8[keyMapStruct[11]]) == 0)
v12 = v11;
v13 = v12 | 8;
if ((kst & dword_5743E8[keyMapStruct[12]]) == 0)
v13 = v12;
ks = v13 | 0x100;
if ((kst & dword_5743E8[keyMapStruct[13]]) == 0)
ks = v13;
}
return ks;
}
DWORD GetKeyStateGamePad_dinput_original(DWORD keyStruct, __int16* keyMapStruct, bool* has_gp)
{
*has_gp = true;
DWORD v1 = keyStruct;
__int16 *v4 = keyMapStruct;
if ((*(int(__stdcall**)(DWORD))(**(DWORD**)(v1 + 8) + 100))(*(DWORD*)(v1 + 8)) < 0) {
int v17 = 0;
if ((*(int(__stdcall**)(DWORD))(**(DWORD**)(v1 + 8) + 28))(*(DWORD*)(v1 + 8)) == -2147024866) {
while (1) {
DWORD v18 = (*(int(__stdcall**)(DWORD))(**(DWORD**)(v1 + 8) + 28))(*(DWORD*)(v1 + 8));
if (++v17 >= 400)
break;
if (v18 != -2147024866) {
void(__fastcall * sub_402310)(DWORD thiz, int a2);
sub_402310 = (decltype(sub_402310))(GetAddress(0x402310));
sub_402310(GetAddress(0x607728), 15);
return 0;
}
}
}
goto LABEL_70;
}
int v35[69];
memset(v35, 0, 0x110u);
if ((*(int(__stdcall**)(DWORD, int, int*))(**(DWORD**)(v1 + 8) + 36))(*(DWORD*)(v1 + 8), 272, v35) < 0)
{
LABEL_70:
*has_gp = false;
return 0;
}
int v2=0;
if (*v4 >= 0)
v2 = *((unsigned __int8*)&v35[12] + *v4) >> 7;
DWORD v20 = v4[1];
if (v20 >= 0)
v2 |= (*((unsigned __int8*)&v35[12] + v20) >> 6) & 2;
DWORD v21 = v4[2];
if (v21 >= 0)
v2 |= (*((unsigned __int8*)&v35[12] + v21) >> 5) & 4;
DWORD v22 = v4[4];
if (v22 >= 0)
v2 |= 2 * (*((BYTE*)&v35[12] + v22) & 0x80);
DWORD v23 = v4[3];
if (v23 >= 0)
v2 |= (*((unsigned __int8*)&v35[12] + v23) >> 4) & 8;
DWORD v24 = 0;
if (v35[0] < -Address<WORD>(GetAddress(0x608614)).GetValue())
v24 = 64;
DWORD v33 = v24;
DWORD v25 = 0;
if (v35[1] < -Address<WORD>(GetAddress(0x608616)).GetValue())
v25 = 16;
DWORD v26 = 0;
DWORD v34 = v25 | v33;
if (v35[0] > Address<WORD>(GetAddress(0x608614)).GetValue())
v26 = 128;
DWORD v27 = v26 | v34;
DWORD v28 = 0;
if (v35[1] > Address<WORD>(GetAddress(0x608616)).GetValue())
v28 = 32;
v2 |= v28 | v27;
return v2;
}
void RemoveKey()
{
auto p = [](std::pair<int, KeyState> i)->bool {
if (i.first != i.second.frame)
LogError(std::format("wrong frame from index, {}:{}",i.first,i.second.frame));
return i.first < (g_ui_frame - g_connection.delay_compensation*2 - 20) || (i.first > g_ui_frame + g_connection.delay_compensation*2 + 20);
};
auto m = [p](std::unordered_map<int, KeyState>& m)
{
for (auto i = m.begin(); i != m.end();){
if (p(*i)){
i=m.erase(i);
}else{
i++;
}
}
};
m(g_keystate_rcved);
m(g_keystate_self);
}
DWORD GetCurrentReceivedKey()
{
if(g_keystate_rcved.contains(g_ui_frame))
return g_keystate_rcved[g_ui_frame].state;
LogError(std::format("fail to get cur rcv key : {}",g_ui_frame));
Delay(2);
HandlePacks();
if (!g_keystate_rcved.contains(g_ui_frame)){
LogInfo("no cur key");
bool is_ahead = true;
for (int i = 0; i < g_connection.delay_compensation; i++) {
if (g_keystate_rcved.contains(g_ui_frame + 1)) {
is_ahead = false;
}
}
bool has_key = false;
for (int i = 0; i < g_connection.c_max_time_retry_timeout; i++)
{
g_connection.SendUDPPack(Data_NAK_KeyState(g_ui_frame));
LARGE_INTEGER time_begin;
GetTime(&time_begin);
while (true)
{
HandlePacks();
if (g_keystate_rcved.contains(g_ui_frame)) {
has_key = true;
break;
}
if (g_connection.connect_state == ConnectState::No_Connection)
return 0;
LARGE_INTEGER time_cur;
GetTime(&time_cur);
if (CalTimePeriod(time_begin, time_cur) > 16 * g_connection.delay_compensation)
break;
}
if (has_key)
break;
Delay(g_connection.delay_compensation * 16);
}
if (!has_key) {
LogError("fail to Connect");
g_connection.EndConnect();
return 0;
}
if (is_ahead) {
LogInfo(std::format("ahead delay {} ms", 8 * g_connection.delay_compensation));
Delay(8 * g_connection.delay_compensation);
}
}
return g_keystate_rcved[g_ui_frame].state;
}
DWORD GetCurrentSelfKey()
{
if (g_keystate_self.contains(g_ui_frame))
return g_keystate_self[g_ui_frame].state;
LogError(std::format("fail to get cur slf key : {}", g_ui_frame));
return 0;
}
DWORD GetKeyStateP1(DWORD keyStruct, __int16* keyMapStruct)
{
if (g_connection.connect_state==ConnectState::No_Connection){
return GetKeyStateP1_original(keyStruct,keyMapStruct);
}else if(g_connection.connect_state == ConnectState::Connected) {
if (g_connection.is_host){
return GetCurrentSelfKey();
}else{
return GetCurrentReceivedKey();
}
}
return 0;
}
DWORD GetKeyStateP2(DWORD keyStruct, __int16* keyMapStruct)
{
if (g_connection.connect_state == ConnectState::No_Connection)
{
return GetKeyStateP2_original(keyStruct, keyMapStruct);
}else if (g_connection.connect_state == ConnectState::Connected) {
if (g_connection.is_host){
return GetCurrentReceivedKey();
}else {
return GetCurrentSelfKey();
}
}
return 0;
}
DWORD GetKeyStateFull(DWORD keyStruct, __int16* keyMapStruct)
{
if (g_connection.connect_state == ConnectState::No_Connection){
return GetKeyStateFull_original(keyStruct, keyMapStruct);
}
if (g_connection.connect_state == ConnectState::Connected){
if (g_connection.is_host){
return GetCurrentSelfKey();
}else{
return GetCurrentReceivedKey();
}
}
return 0;
}
void RecordKey(DWORD keyStruct, __int16* keyMapStruct)
{
int real_cur_frame = g_ui_frame + g_connection.delay_compensation;
if (g_is_loading)
{
if (!g_keystate_self.contains(real_cur_frame)) {
KeyState state = { 0 };
state.state = 0;
state.frame = real_cur_frame;
CopyFromOriginalSeeds(state.seednum);
g_keystate_self[real_cur_frame] = state;
}
}
bool has_gp = false;
DWORD ks = 0;
switch (*(DWORD*)keyStruct)
{
case 0:
case 3:
case 4:
{
if (IsOnWindow()) {
GetKeyboardState((PBYTE)(keyStruct + 720));
ks = GetKeyStateFull_original(keyStruct, keyMapStruct);
}
}
break;
case 2://gamepad(xinput)
{
if (IsOnWindow()) {
XINPUT_STATE stt;
ks = GetKeyStateGamePad_xinput_original(keyStruct, keyMapStruct, &stt, &has_gp);
if (!has_gp)
return;
}
}break;
case 1:
{
if (IsOnWindow()) {
ks = GetKeyStateGamePad_dinput_original(keyStruct,keyMapStruct, &has_gp);
if (!has_gp)
return;
}
}break;
default:
break;
}
if (!g_keystate_self.contains(real_cur_frame)) {
KeyState state = { 0 };
state.state = ks;
state.frame = real_cur_frame;
CopyFromOriginalSeeds(state.seednum);
g_keystate_self[real_cur_frame] = state;
}else if(has_gp){
KeyState state = g_keystate_self[real_cur_frame];
state.state |= ks;
state.frame = real_cur_frame;
g_keystate_self[real_cur_frame] = state;
}
RemoveKey();
}
int __fastcall MyGetKeyState(DWORD thiz) {
GetTime(&g_cur_time);
DWORD control_option = VALUED(GetAddress(0x005AE3A0));
if (g_connection.connect_state==Connected && control_option){
*(DWORD*)(GetAddress(0x0060860C)) = 1;
*(DWORD*)(GetAddress(0x00608610)) = 2;
VALUED(control_option + 0x2E24) = 1;
VALUED(control_option + 0x2E28) = 2;//keyboard
}
int v1; // ebx
unsigned int v2; // esi
int v3; // ecx
__int16* v4; // edi
//int v5; // edx
int v6; // esi
int v7; // edx
int v8; // ecx
int v9; // edx
int v10; // ecx
int v11; // edx
int v12; // ecx
int v13; // edx
int v14; // eax
bool v15; // zf
WORD v16; // ax
int v17; // esi
int v18; // eax
__int16 v20; // ax
__int16 v21; // ax
__int16 v22; // ax
__int16 v23; // ax
int v24; // ecx
int v25; // ecx
int v26; // eax
int v27; // ecx
int v28; // eax
int i; // eax
DWORD v30; // [esp-8h] [ebp-148h]
int v31; // [esp+Ch] [ebp-134h]
int v33; // [esp+14h] [ebp-12Ch]
int v34; // [esp+14h] [ebp-12Ch]
int v35[69]; // [esp+18h] [ebp-128h] BYREF
XINPUT_STATE pState; // [esp+12Ch] [ebp-14h] BYREF
v1 = thiz;
v2 = 0;
v31 = thiz + 720;
memset((void*)(thiz + 720), 0, 0x100u);
v3 = 0;
if (*(DWORD*)(Address<DWORD>(GetAddress(0x5AE3A0)).GetValue() + 0x2E28) == *(DWORD*)(v1 + 4))
v3 = 90;
v4 = (__int16*)(v3 + Address<DWORD>(GetAddress(0x5AE3A0)).GetValue() + 0x2E38);
if (g_connection.connect_state == ConnectState::Connected){
RecordKey(v1, v4);
}
switch (*(DWORD*)v1)
{
case 0:
case 3:
case 4:
//if (IsOnWindow())//is on the window?
{
if (*(DWORD*)v1){
if (*(DWORD*)v1 == 3){
v2 = GetKeyStateP1(v1, v4);
} else if (*(DWORD*)v1 == 4) {
v2 = GetKeyStateP2(v1, v4);
}
}else{
v2 = GetKeyStateFull(v1, v4);
}
}
memset((void*)(thiz + 720), 0, 0x100u);
break;
case 1:
if (g_connection.connect_state == Connected) {
break;
}else if (g_connection.connect_state != No_Connection) {
break;
}
if (!IsOnWindow())
break;
if ((*(int(__stdcall**)(DWORD))(**(DWORD**)(v1 + 8) + 100))(*(DWORD*)(v1 + 8)) < 0){
v17 = 0;
if ((*(int(__stdcall**)(DWORD))(**(DWORD**)(v1 + 8) + 28))(*(DWORD*)(v1 + 8)) == -2147024866){
while (1){
v18 = (*(int(__stdcall**)(DWORD))(**(DWORD**)(v1 + 8) + 28))(*(DWORD*)(v1 + 8));
if (++v17 >= 400)
break;
if (v18 != -2147024866) {
void(__fastcall * sub_402310)(DWORD thiz, int a2);
sub_402310 = (decltype(sub_402310))(GetAddress(0x402310));
sub_402310(GetAddress(0x607728), 15);
return 0;
}
}
}
goto LABEL_70;
}
memset(v35, 0, 0x110u);
if ((*(int(__stdcall**)(DWORD, int, int*))(**(DWORD**)(v1 + 8) + 36))(*(DWORD*)(v1 + 8), 272, v35) < 0)
{
LABEL_70:
void(__fastcall * sub_402310)(DWORD thiz, int a2);
sub_402310 = (decltype(sub_402310))(GetAddress(0x402310));
sub_402310(GetAddress(0x607728), 15);
return 0;
}
if (*v4 >= 0)
v2 = *((unsigned __int8*)&v35[12] + *v4) >> 7;
v20 = v4[1];
if (v20 >= 0)
v2 |= (*((unsigned __int8*)&v35[12] + v20) >> 6) & 2;
v21 = v4[2];
if (v21 >= 0)
v2 |= (*((unsigned __int8*)&v35[12] + v21) >> 5) & 4;
v22 = v4[4];
if (v22 >= 0)
v2 |= 2 * (*((BYTE*)&v35[12] + v22) & 0x80);
v23 = v4[3];
if (v23 >= 0)
v2 |= (*((unsigned __int8*)&v35[12] + v23) >> 4) & 8;
v24 = 0;
if (v35[0] < -Address<WORD>(GetAddress(0x608614)).GetValue())
v24 = 64;
v33 = v24;
v25 = 0;
if (v35[1] < -Address<WORD>(GetAddress(0x608616)).GetValue())
v25 = 16;
v26 = 0;
v34 = v25 | v33;
if (v35[0] > Address<WORD>(GetAddress(0x608614)).GetValue())
v26 = 128;
v27 = v26 | v34;
v28 = 0;
if (v35[1] > Address<WORD>(GetAddress(0x608616)).GetValue())
v28 = 32;
v2 |= v28 | v27;
for (i = 0; i < 32; ++i)
{
if (*((BYTE*)&v35[12] + i))
*(BYTE*)(v31 + i) = 0x80;
}
v1 = thiz;
LABEL_94:
if (v2)
*(DWORD*)(Address<DWORD>(GetAddress(0x5AE3A0)).GetValue() + 24) = *(DWORD*)v1;
break;
case 2:
if (g_connection.connect_state == Connected) {
break;
}else if (g_connection.connect_state != No_Connection){
break;
}
v30 = *(DWORD*)(v1 + 12);
memset(&pState, 0, sizeof(pState));
if (XInputGetState(v30, &pState)!=0)
break;
if (!IsOnWindow())
break;
bool has_gp;
v2=GetKeyStateGamePad_xinput_original(v1, v4, &pState, &has_gp);
/*
v6 = pState.Gamepad.wButtons;
if (pState.Gamepad.bLeftTrigger >= 0x1Eu)
v6 = pState.Gamepad.wButtons | 0x10000;
if (pState.Gamepad.bRightTrigger >= 0x1Eu)
v6 |= 0x20000u;
if (pState.Gamepad.sThumbLY >= 7849)
v6 |= 1u;
if (pState.Gamepad.sThumbLY <= -7849)
v6 |= 2u;
if (pState.Gamepad.sThumbLX >= 7849)
v6 |= 8u;
if (pState.Gamepad.sThumbLX <= -7849)
v6 |= 4u;
v7 = (16 * (v6 & 1)) | 0x20;
if ((v6 & 2) == 0)
v7 = 16 * (v6 & 1);
v8 = v7 | 0x40;
if ((v6 & 4) == 0)
v8 = v7;
v9 = v8 | 0x80;
if ((v6 & 8) == 0)
v9 = v8;
v10 = v9 | 1;
{
DWORD* dword_5743E8 = (DWORD*)(GetAddress(0x5743E8));
if ((v6 & dword_5743E8[v4[9]]) == 0)
v10 = v9;
v11 = v10 | 2;
if ((v6 & dword_5743E8[v4[10]]) == 0)
v11 = v10;
v12 = v11 | 4;
if ((v6 & dword_5743E8[v4[11]]) == 0)
v12 = v11;
v13 = v12 | 8;
if ((v6 & dword_5743E8[v4[12]]) == 0)
v13 = v12;
v14 = v6 & dword_5743E8[v4[13]];
}
v2 = v13 | 0x100;
v15 = v14 == 0;
v16 = pState.Gamepad.wButtons;
if (v15)
v2 = v13;
*/
v16 = pState.Gamepad.wButtons;
if ((pState.Gamepad.wButtons & 0x1000) != 0)
*(BYTE*)(v1 + 720) = 0x80;
if ((v16 & 0x2000) != 0)
*(BYTE*)(v1 + 721) = 0x80;
if ((v16 & 0x4000) != 0)
*(BYTE*)(v1 + 722) = 0x80;
if ((v16 & 0x8000) != 0)
*(BYTE*)(v1 + 723) = 0x80;
if ((v16 & 0x40) != 0)
*(BYTE*)(v1 + 728) = 0x80;
if ((v16 & 0x80u) != 0)
*(BYTE*)(v1 + 729) = 0x80;
if ((v16 & 0x100) != 0)
*(BYTE*)(v1 + 724) = 0x80;
if ((v16 & 0x200) != 0)
*(BYTE*)(v1 + 725) = 0x80;
if ((v16 & 0x10) != 0)
*(BYTE*)(v1 + 730) = 0x80;
if ((v16 & 0x20) != 0)
*(BYTE*)(v1 + 731) = 0x80;
if (pState.Gamepad.bLeftTrigger >= 0x1Eu)
*(BYTE*)(v1 + 726) = 0x80;
if (pState.Gamepad.bRightTrigger >= 0x1Eu)
*(BYTE*)(v1 + 727) = 0x80;
goto LABEL_94;
default:
break;
}
*(DWORD*)(v1 + 20) = *(DWORD*)(v1 + 16);
*(DWORD*)(v1 + 16) = v2;
void(__fastcall* sub_402730)(unsigned int* thiz);
sub_402730 = (decltype(sub_402730))(GetAddress(0x402730));
sub_402730((unsigned int*)(v1 + 16));
if (Address<BYTE>(GetAddress(0x6078B8)).GetValue())
{
LeaveCriticalSection((LPCRITICAL_SECTION)GetAddress(0x607890));
Address<BYTE>(GetAddress(0x6078B7)).SetValue(Address<BYTE>(GetAddress(0x6078B7)).GetValue());
}
return v2;
}