99#include " DSAdvance.h"
1010
1111Gamepad CurGamepad;
12- InputOutState GamepadOutState;
12+ InputOutState GamepadOutState; unsigned LEDsTemp[ 3 ];
1313
1414void GamepadSetState (InputOutState OutState)
1515{
@@ -138,7 +138,7 @@ void GetBatteryInfo() {
138138 memset (buf, 0 , 64 );
139139 hid_read (CurGamepad.HidHandle , buf, 64 );
140140 CurGamepad.BatteryLevel = (buf[53 ] & 0x0f ) / 2 ; // ?
141- // CurGamepad.BatteryMode = buf[30]; //???
141+ // CurGamepad.BatteryMode = buf[30]; //??? in charge mode, need to show animation within a few seconds
142142 } else { // BT
143143 unsigned char buf[64 ];
144144 memset (buf, 0 , 64 );
@@ -156,12 +156,6 @@ void GetBatteryInfo() {
156156
157157static std::mutex m;
158158
159- struct EulerAngles {
160- double Yaw;
161- double Pitch;
162- double Roll;
163- };
164-
165159EulerAngles QuaternionToEulerAngle (double qW, double qX, double qY, double qZ) // https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles
166160{
167161 EulerAngles resAngles;
@@ -272,17 +266,25 @@ SHORT ToLeftStick(double Value, float WheelAngle)
272266 return LeftAxisX;
273267}
274268
275- void DefMainText (int TextMode) {
269+ void DefMainText (int TextMode, int EmuMode, int AimMode ) {
276270 system (" cls" );
277271 if (TextMode == 1 )
278272 printf (" \n Connect DualSense, DualShock 4, Pro controller or Joycons and reset." );
279- printf (" \n Press \" CTRL\" + \" R\" to reset.\n " );
273+ printf (" \n Press \" CTRL\" + \" R\" to reset." );
274+ if (EmuMode == 1 )
275+ printf (" \n Emulation: Xbox gamepad, press \" ALT\" + \" Q\" to turn off." );
276+ else
277+ printf (" \n Emulation: -, press \" ALT\" + \" Q\" to turn on." );
278+ if (AimMode == 1 )
279+ printf (" \n AIM mode = mouse\n " );
280+ else
281+ printf (" \n AIM mode = mouse-joystick\n " );
280282 printf (" Press \" ALT\" + \" Escape\" to exit.\n " );
281283}
282284
283285int main (int argc, char **argv)
284286{
285- SetConsoleTitle (" DSAdvance 0.4 " );
287+ SetConsoleTitle (" DSAdvance 0.5 " );
286288 // Config parameters
287289 CIniReader IniFile (" Config.ini" );
288290
@@ -302,9 +304,12 @@ int main(int argc, char **argv)
302304 float TouchRightStickX = IniFile.ReadFloat (" Gamepad" , " TouchRightStickSensX" , 4 );
303305 float TouchRightStickY = IniFile.ReadFloat (" Gamepad" , " TouchRightStickSensY" , 4 );
304306
307+ bool AimMode = IniFile.ReadBoolean (" Motion" , " AimMode" , false );
305308 float MotionWheelAngle = IniFile.ReadFloat (" Motion" , " WheelAngle" , 75 );
306- float MotionSensX = IniFile.ReadFloat (" Motion" , " SensX" , 3 );
307- float MotionSensY = IniFile.ReadFloat (" Motion" , " SensY" , 3 );
309+ float MotionSensX = IniFile.ReadFloat (" Motion" , " MouseSensX" , 3 );
310+ float MotionSensY = IniFile.ReadFloat (" Motion" , " MouseSensY" , 3 );
311+ float JoySensX = IniFile.ReadFloat (" Motion" , " JoySensX" , 3 );
312+ float JoySensY = IniFile.ReadFloat (" Motion" , " JoySensY" , 3 );
308313
309314 GamepadSearch ();
310315 GamepadOutState.PlayersCount = 0 ;
@@ -313,18 +318,19 @@ int main(int argc, char **argv)
313318 GamepadSetState (GamepadOutState);
314319
315320 int SkipPollCount = 0 ;
316- int BatteryShowCounter = 0 ;
321+ int BackOutStateCounter = 0 ;
317322 bool DeadZoneMode = false ;
318323 int GamepadMode = 0 ; int LastAIMProCtrlMode = 2 ;
319- EulerAngles AnglesOffset;
324+ EulerAngles MotionAngles, LastAngles, DeltaAngles, AnglesOffset;
325+ bool XboxGamepadEmulation = true ;
320326
321327 bool BTReset = true ; // Problems with BlueTooth, on first connection. Reconnecting fixes the problem.
322328 int controllersCount = JslConnectDevices ();
323329 int deviceID[4 ];
324330 JslGetConnectedDeviceHandles (deviceID, controllersCount);
325331
326- if (controllersCount == 0 ) DefMainText (1 ); else DefMainText (0 );
327-
332+ if (controllersCount == 0 ) DefMainText (1 , XboxGamepadEmulation, AimMode ); else DefMainText (0 , XboxGamepadEmulation, AimMode );
333+
328334 JOY_SHOCK_STATE InputState;
329335 MOTION_STATE MotionState;
330336 TOUCH_STATE TouchState;
@@ -338,17 +344,16 @@ int main(int argc, char **argv)
338344
339345 XUSB_REPORT report;
340346
341- bool FirstTouch, SecondTouch;
342- float InitFirstTouchAxisX, InitFirstTouchAxisY, FirstTouchAxisX, FirstTouchAxisY, InitSecondTouchAxisX, InitSecondTouchAxisY, SecondTouchAxisX, SecondTouchAxisY, TouchAxisLX, TouchAxisLY, TouchAxisRX, TouchAxisRY;
343-
347+ TouchpadTouch FirstTouch, SecondTouch;
348+
344349 while (! ( GetAsyncKeyState (VK_LMENU) & 0x8000 && GetAsyncKeyState (VK_ESCAPE) & 0x8000 ) )
345350 {
346351 // Dead zones
347352 if ((GetAsyncKeyState (VK_F9) & 0x8000 ) != 0 && ((GetAsyncKeyState (VK_MENU) & 0x8000 ) != 0 ) && SkipPollCount == 0 )
348353 {
349354 DeadZoneMode = !DeadZoneMode;
350- if (DeadZoneMode == false ) DefMainText (0 );
351- SkipPollCount = 15 ;
355+ if (DeadZoneMode == false ) DefMainText (0 , XboxGamepadEmulation, AimMode );
356+ SkipPollCount = SkipPollTimeOut ;
352357 }
353358
354359 if (DeadZoneMode) {
@@ -366,51 +371,81 @@ int main(int argc, char **argv)
366371 hid_close (CurGamepad.HidHandle );
367372 GamepadSearch ();
368373 GamepadSetState (GamepadOutState);
369- SkipPollCount = 15 ;
374+ SkipPollCount = SkipPollTimeOut ;
370375 BTReset = false ;
371- DefMainText (0 );
376+ DefMainText (0 , XboxGamepadEmulation, AimMode);
377+ }
378+
379+
380+ if ((GetAsyncKeyState (' Q' ) & 0x8000 ) != 0 && ((GetAsyncKeyState (VK_MENU) & 0x8000 ) != 0 ) && SkipPollCount == 0 ) // Disable Xbox controller emulation for games that support DualSense, DualShock, Nintendo controllers
381+ {
382+ XboxGamepadEmulation = !XboxGamepadEmulation;
383+ if (XboxGamepadEmulation == false ) {
384+ vigem_target_x360_unregister_notification (x360);
385+ vigem_target_remove (client, x360);
386+ // vigem_target_free(x360);
387+ } else {
388+ ret = vigem_target_add (client, x360);
389+ ret = vigem_target_x360_register_notification (client, x360, ¬ification, nullptr );
390+ }
391+ DefMainText (0 , XboxGamepadEmulation, AimMode);
392+ SkipPollCount = SkipPollTimeOut;
372393 }
373394
374- XUSB_REPORT_INIT (&report);
395+ if (XboxGamepadEmulation)
396+ XUSB_REPORT_INIT (&report);
375397
376398 InputState = JslGetSimpleState (deviceID[0 ]);
377399 MotionState = JslGetMotionState (deviceID[0 ]);
378-
379- EulerAngles MotionAngles;
380400 MotionAngles = QuaternionToEulerAngle (MotionState.quatW , MotionState.quatZ , MotionState.quatX , MotionState.quatY ); // ?? correct?
381401
382402 if (JslGetControllerType (deviceID[0 ]) == JS_TYPE_DS || JslGetControllerType (deviceID[0 ]) == JS_TYPE_DS4) {
383403
384404 TouchState = JslGetTouchState (deviceID[0 ]);
385405
386406 if (TouchState.t0Down && TouchState.t0Y <= 0.1 && TouchState.t0X >= 0.325 && TouchState.t0X <= 0.675 ) { // Brightness change
387- GamepadOutState.LEDBrightness = std::clamp ((int )((TouchState.t0X - 0.325 ) * 255 * 2.9 ), 0 , 255 );
388- // printf("%5.2f\n", (TouchState.t0X - 0.325 ) * 255 * 2.9 );
407+ GamepadOutState.LEDBrightness = 255 - std::clamp ((int )((TouchState.t0X - 0.335 ) * 255 * 3.2 ), 0 , 255 );
408+ // printf("%5.2f %d \n", (TouchState.t0X - 0.335 ) * 255 * 3.2, GamepadOutState.LEDBrightness );
389409 GamepadSetState (GamepadOutState);
390410 }
391411
392412 if (InputState.buttons & JSMASK_TOUCHPAD_CLICK) {
393413 if (TouchState.t0Y > 0.1 ) {
394- if (TouchState.t0X > 0 && TouchState.t0X <= 1 / 3.0 && GamepadMode != 4 ) { // [O--] - Driving mode
395- GamepadMode = 1 ;
396- AnglesOffset = MotionAngles;
397- GamepadOutState.LEDBlue = 0 ; GamepadOutState.LEDRed = 255 ; GamepadOutState.LEDGreen = 0 ;
414+ if (TouchState.t0X > 0 && TouchState.t0X <= 1 / 3.0 && GamepadMode != 4 ) { // [O--] - Driving mode & switching between joy aim and mouse aim
415+
416+ if (TouchState.t0Y > 0.1 && TouchState.t0Y < 0.7 ) {
417+ GamepadMode = 1 ;
418+ AnglesOffset = MotionAngles;
419+ GamepadOutState.LEDBlue = 0 ; GamepadOutState.LEDRed = 255 ; GamepadOutState.LEDGreen = 0 ;
420+ } else if (SkipPollCount == 0 ) { // Switch between mouse and mouse-joystick
421+ SkipPollCount = SkipPollTimeOut;
422+ AimMode = !AimMode;
423+ DefMainText (0 , XboxGamepadEmulation, AimMode);
424+ LEDsTemp[0 ] = GamepadOutState.LEDBlue ; LEDsTemp[1 ] = GamepadOutState.LEDRed ; LEDsTemp[2 ] = GamepadOutState.LEDGreen ;
425+ if (AimMode == 1 ) { // Mouse aim
426+ GamepadOutState.LEDBlue = 255 ; GamepadOutState.LEDRed = 255 ; GamepadOutState.LEDGreen = 255 ;
427+ } else { // Mouse-joystick aim
428+ GamepadOutState.LEDBlue = 0 ; GamepadOutState.LEDRed = 255 ; GamepadOutState.LEDGreen = 255 ;
429+ }
430+ BackOutStateCounter = 40 ;
431+ }
398432
399433 } else if (TouchState.t0X > 1 / 3.0 && TouchState.t0X <= 1 / 3.0 * 2.0 ) { // [-O-] // Default & touch sticks modes
400434
401435 if (TouchState.t0Y > 0.1 && TouchState.t0Y < 0.7 ) { // Default mode
402436 GamepadMode = 0 ;
403437 GamepadOutState.LEDBlue = 255 ; GamepadOutState.LEDRed = 0 ; GamepadOutState.LEDGreen = 0 ;
404438 // Show battery level
405- GetBatteryInfo (); BatteryShowCounter = 40 ; GamepadOutState.PlayersCount = CurGamepad.BatteryLevel ; GamepadSetState (GamepadOutState); // JslSetPlayerNumber(deviceID[0], 5);
439+ LEDsTemp[0 ] = GamepadOutState.LEDBlue ; LEDsTemp[1 ] = GamepadOutState.LEDRed ; LEDsTemp[2 ] = GamepadOutState.LEDGreen ;
440+ GetBatteryInfo (); BackOutStateCounter = 40 ; GamepadOutState.PlayersCount = CurGamepad.BatteryLevel ; GamepadSetState (GamepadOutState); // JslSetPlayerNumber(deviceID[0], 5);
406441 } else { // Touch sticks mode
407442 GamepadMode = 4 ;
408443 JslSetRumble (0 , 255 , 255 );
409444 GamepadOutState.LEDBlue = 255 ; GamepadOutState.LEDRed = 255 ; GamepadOutState.LEDGreen = 0 ;
410445 }
411446
412447 } else if (TouchState.t0X > (1 / 3.0 ) * 2.0 && TouchState.t0X <= 1 && GamepadMode != 4 ) { // [--O] Aiming mode
413-
448+ DeltaAngles = MotionAngles;
414449 if (TouchState.t0Y > 0.1 && TouchState.t0Y < 0.5 ) { // Motion AIM always
415450 GamepadMode = 3 ;
416451 GamepadOutState.LEDBlue = 255 ; GamepadOutState.LEDRed = 0 ; GamepadOutState.LEDGreen = 255 ;
@@ -457,16 +492,16 @@ int main(int argc, char **argv)
457492
458493 // Nintendo controllers + - change working mode
459494 if (JslGetControllerType (deviceID[0 ]) == JS_TYPE_PRO_CONTROLLER || JslGetControllerType (deviceID[0 ]) == JS_TYPE_JOYCON_LEFT || JslGetControllerType (deviceID[0 ]) == JS_TYPE_JOYCON_RIGHT) {
460- if (InputState.buttons & JSMASK_MINUS && SkipPollCount == 0 ) { if (GamepadMode == 1 ) GamepadMode = 0 ; else { GamepadMode = 1 ; AnglesOffset = MotionAngles; } SkipPollCount = 15 ; }
461- if (InputState.buttons & JSMASK_PLUS && SkipPollCount == 0 ) { if (GamepadMode == 0 || GamepadMode == 1 ) GamepadMode = LastAIMProCtrlMode; else if (GamepadMode == 2 ) { GamepadMode = 3 ; LastAIMProCtrlMode = 3 ; } else { GamepadMode = 2 ; LastAIMProCtrlMode = 2 ; } SkipPollCount = 15 ; }
495+ if (InputState.buttons & JSMASK_MINUS && SkipPollCount == 0 ) { if (GamepadMode == 1 ) GamepadMode = 0 ; else { GamepadMode = 1 ; AnglesOffset = MotionAngles; } SkipPollCount = SkipPollTimeOut ; }
496+ if (InputState.buttons & JSMASK_PLUS && SkipPollCount == 0 ) { if (GamepadMode == 0 || GamepadMode == 1 ) GamepadMode = LastAIMProCtrlMode; else if (GamepadMode == 2 ) { GamepadMode = 3 ; LastAIMProCtrlMode = 3 ; } else { GamepadMode = 2 ; LastAIMProCtrlMode = 2 ; } SkipPollCount = SkipPollTimeOut ; }
462497 }
463498
464499 if (InputState.buttons & JSMASK_PS && SkipPollCount == 0 ) {
465500 keybd_event (VK_LWIN, 0x45 , KEYEVENTF_EXTENDEDKEY | 0 , 0 );
466501 keybd_event (' G' , 0x45 , KEYEVENTF_EXTENDEDKEY | 0 , 0 );
467502 keybd_event (' G' , 0x45 , KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 );
468503 keybd_event (VK_LWIN, 0x45 , KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 );
469- SkipPollCount = 15 ;
504+ SkipPollCount = SkipPollTimeOut ;
470505 }
471506
472507 if (InputState.buttons & JSMASK_MIC && SkipPollCount == 0 ) {
@@ -476,72 +511,87 @@ int main(int argc, char **argv)
476511 keybd_event (VK_SNAPSHOT, 0x45 , KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 );
477512 keybd_event (VK_MENU, 0x45 , KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 );
478513 keybd_event (VK_LWIN, 0x45 , KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 );
479- SkipPollCount = 15 ;
514+ SkipPollCount = SkipPollTimeOut ;
480515 }
481516
482517 if (GamepadMode == 1 ) // Motion racing [O--]
483518 report.sThumbLX = ToLeftStick (OffsetYPR (RadToDeg (MotionAngles.Roll ), RadToDeg (AnglesOffset.Roll )) * -1 , MotionWheelAngle);
484519 else if (GamepadMode == 2 || GamepadMode == 3 ) { // Motion aiming [--õ]
485- float NewX = OffsetYPR (RadToDeg (MotionAngles.Yaw ), RadToDeg (AnglesOffset.Yaw )) * -1 ;
486- float NewY = OffsetYPR (RadToDeg (MotionAngles.Pitch ), RadToDeg (AnglesOffset.Pitch )) * -1 ;
487- if (GamepadMode == 3 || (GamepadMode == 2 && InputState.lTrigger > 0 ) )
488- MouseMove (NewX * MotionSensX, NewY * MotionSensY);
489- AnglesOffset = MotionAngles; // Not the best way but it works
490-
520+ DeltaAngles.Yaw = OffsetYPR (MotionAngles.Yaw , LastAngles.Yaw ) * -1 ;
521+ DeltaAngles.Pitch = OffsetYPR (MotionAngles.Pitch , LastAngles.Pitch ) * -1 ;
522+ if (GamepadMode == 3 || (GamepadMode == 2 && InputState.lTrigger > 0 ) )
523+ if (AimMode)
524+ MouseMove (RadToDeg (DeltaAngles.Yaw ) * MotionSensX, RadToDeg (DeltaAngles.Pitch ) * MotionSensY);
525+ else {
526+ report.sThumbRX = std::clamp ((int )(ClampFloat ((DeltaAngles.Yaw ) * JoySensX, -1 , 1 ) * 32767 + report.sThumbRX ), -32767 , 32767 );
527+ report.sThumbRY = std::clamp ((int )(ClampFloat (-(DeltaAngles.Pitch ) * JoySensY, -1 , 1 ) * 32767 + report.sThumbRY ), -32767 , 32767 );
528+ }
529+
530+ LastAngles = MotionAngles;
491531 } else if (GamepadMode == 4 ) { // [-_-] Touchpad sticks
492532
493533 if (TouchState.t0Down ) {
494- if (FirstTouch == false ) {
495- InitFirstTouchAxisX = TouchState.t0X ;
496- InitFirstTouchAxisY = TouchState.t0Y ;
497- FirstTouch = true ;
534+ if (FirstTouch. Touched == false ) {
535+ FirstTouch. InitAxisX = TouchState.t0X ;
536+ FirstTouch. InitAxisY = TouchState.t0Y ;
537+ FirstTouch. Touched = true ;
498538 }
499- FirstTouchAxisX = TouchState.t0X - InitFirstTouchAxisX ;
500- FirstTouchAxisY = TouchState.t0Y - InitFirstTouchAxisY ;
539+ FirstTouch. AxisX = TouchState.t0X - FirstTouch. InitAxisX ;
540+ FirstTouch. AxisY = TouchState.t0Y - FirstTouch. InitAxisY ;
501541
502- if (InitFirstTouchAxisX < 0.5 ) {
503- report.sThumbLX = ClampFloat (FirstTouchAxisX * TouchLeftStickX, -1 , 1 ) * 32767 ;
504- report.sThumbLY = ClampFloat (-FirstTouchAxisY * TouchLeftStickY, -1 , 1 ) * 32767 ;
542+ if (FirstTouch. InitAxisX < 0.5 ) {
543+ report.sThumbLX = ClampFloat (FirstTouch. AxisX * TouchLeftStickX, -1 , 1 ) * 32767 ;
544+ report.sThumbLY = ClampFloat (-FirstTouch. AxisY * TouchLeftStickY, -1 , 1 ) * 32767 ;
505545 if (InputState.buttons & JSMASK_TOUCHPAD_CLICK) report.wButtons |= XINPUT_GAMEPAD_LEFT_THUMB;
506546 } else {
507- report.sThumbRX = ClampFloat (FirstTouchAxisX * TouchRightStickX, -1 , 1 ) * 32767 ;
508- report.sThumbRY = ClampFloat (-FirstTouchAxisY * TouchRightStickY, -1 , 1 ) * 32767 ;
509- // MouseMove(FirstTouchAxisX * 0.25, FirstTouchAxisY * 0.25) ;
547+ report.sThumbRX = ClampFloat ((TouchState. t0X - FirstTouch. LastAxisX ) * TouchRightStickX * 200 , -1 , 1 ) * 32767 ;
548+ report.sThumbRY = ClampFloat (-(TouchState. t0Y - FirstTouch. LastAxisY ) * TouchRightStickY * 200 , -1 , 1 ) * 32767 ;
549+ FirstTouch. LastAxisX = TouchState. t0X ; FirstTouch. LastAxisY = TouchState. t0Y ;
510550 if (InputState.buttons & JSMASK_TOUCHPAD_CLICK) report.wButtons |= XINPUT_GAMEPAD_RIGHT_THUMB;
511551 }
512552 } else {
513- FirstTouchAxisX = 0 ;
514- FirstTouchAxisY = 0 ;
515- FirstTouch = false ;
553+ FirstTouch. AxisX = 0 ;
554+ FirstTouch. AxisY = 0 ;
555+ FirstTouch. Touched = false ;
516556 }
517557
518558 if (TouchState.t1Down ) {
519- if (SecondTouch == false ) {
520- InitSecondTouchAxisX = TouchState.t1X ;
521- InitSecondTouchAxisY = TouchState.t1Y ;
522- SecondTouch = true ;
559+ if (SecondTouch. Touched == false ) {
560+ SecondTouch. InitAxisX = TouchState.t1X ;
561+ SecondTouch. InitAxisY = TouchState.t1Y ;
562+ SecondTouch. Touched = true ;
523563 }
524- SecondTouchAxisX = TouchState.t1X - InitSecondTouchAxisX ;
525- SecondTouchAxisY = TouchState.t1Y - InitSecondTouchAxisY ;
564+ SecondTouch. AxisX = TouchState.t1X - SecondTouch. InitAxisX ;
565+ SecondTouch. AxisY = TouchState.t1Y - SecondTouch. InitAxisY ;
526566
527- if (InitSecondTouchAxisX < 0.5 ) {
528- report.sThumbLX = ClampFloat (SecondTouchAxisX * TouchLeftStickX, -1 , 1 ) * 32767 ;
529- report.sThumbLY = ClampFloat (-SecondTouchAxisY * TouchLeftStickY, -1 , 1 ) * 32767 ;
567+ if (SecondTouch. InitAxisX < 0.5 ) {
568+ report.sThumbLX = ClampFloat (SecondTouch. AxisX * TouchLeftStickX, -1 , 1 ) * 32767 ;
569+ report.sThumbLY = ClampFloat (-SecondTouch. AxisY * TouchLeftStickY, -1 , 1 ) * 32767 ;
530570 } else {
531- report.sThumbRX = ClampFloat (SecondTouchAxisX * TouchRightStickX, -1 , 1 ) * 32767 ;
532- report.sThumbRY = ClampFloat (-SecondTouchAxisY * TouchRightStickY, -1 , 1 ) * 32767 ;
571+ report.sThumbRX = ClampFloat ((TouchState.t1X - SecondTouch.LastAxisX ) * TouchRightStickX * 200 , -1 , 1 ) * 32767 ;
572+ report.sThumbRY = ClampFloat (-(TouchState.t1Y - SecondTouch.LastAxisY ) * TouchRightStickY * 200 , -1 , 1 ) * 32767 ;
573+ SecondTouch.LastAxisX = TouchState.t1X ; SecondTouch.LastAxisY = TouchState.t1Y ;
533574 }
534575 } else {
535- SecondTouchAxisX = 0 ;
536- SecondTouchAxisY = 0 ;
537- SecondTouch = false ;
576+ SecondTouch. AxisX = 0 ;
577+ SecondTouch. AxisY = 0 ;
578+ SecondTouch. Touched = false ;
538579 }
539580
540581 }
541582
542- ret = vigem_target_x360_update (client, x360, report);
583+ if (XboxGamepadEmulation)
584+ ret = vigem_target_x360_update (client, x360, report);
543585
544- if (BatteryShowCounter > 0 ) { if (BatteryShowCounter == 1 ) { GamepadOutState.PlayersCount = 0 ; GamepadSetState (GamepadOutState); } BatteryShowCounter--; }
586+ if (BackOutStateCounter > 0 ) { // Battery display, aiming mode display
587+ if (BackOutStateCounter == 1 ) {
588+ GamepadOutState.LEDBlue = LEDsTemp[0 ]; GamepadOutState.LEDRed = LEDsTemp[1 ]; GamepadOutState.LEDGreen = LEDsTemp[2 ];
589+ GamepadOutState.PlayersCount = 0 ;
590+ GamepadSetState (GamepadOutState);
591+ }
592+ BackOutStateCounter--;
593+ }
594+
545595 if (SkipPollCount > 0 ) SkipPollCount--;
546596 Sleep (SleepTimeOut);
547597 }
0 commit comments