@@ -379,10 +379,10 @@ void LoadKMProfile(std::string ProfileFile) {
379379 ButtonsStates.Back .KeyCode = KeyNameToKeyCode (IniFile.ReadString (" GAMEPAD" , " BACK" , " ESCAPE" ));
380380 ButtonsStates.Start .KeyCode = KeyNameToKeyCode (IniFile.ReadString (" GAMEPAD" , " START" , " ENTER" ));
381381
382- ButtonsStates.DPADUp .KeyCode = KeyNameToKeyCode (IniFile.ReadString (" GAMEPAD" , " DPAD-UP" , " 1" ));
383- ButtonsStates.DPADDown .KeyCode = KeyNameToKeyCode (IniFile.ReadString (" GAMEPAD" , " DPAD-DOWN" , " 4" ));
384- ButtonsStates.DPADLeft .KeyCode = KeyNameToKeyCode (IniFile.ReadString (" GAMEPAD" , " DPAD-LEFT" , " 2" ));
382+ ButtonsStates.DPADUp .KeyCode = KeyNameToKeyCode (IniFile.ReadString (" GAMEPAD" , " DPAD-UP" , " 2" ));
383+ ButtonsStates.DPADLeft .KeyCode = KeyNameToKeyCode (IniFile.ReadString (" GAMEPAD" , " DPAD-LEFT" , " 1" ));
385384 ButtonsStates.DPADRight .KeyCode = KeyNameToKeyCode (IniFile.ReadString (" GAMEPAD" , " DPAD-RIGHT" , " 3" ));
385+ ButtonsStates.DPADDown .KeyCode = KeyNameToKeyCode (IniFile.ReadString (" GAMEPAD" , " DPAD-DOWN" , " 4" ));
386386
387387 ButtonsStates.Y .KeyCode = KeyNameToKeyCode (IniFile.ReadString (" GAMEPAD" , " TRIANGLE-Y" , " E" ));
388388 ButtonsStates.X .KeyCode = KeyNameToKeyCode (IniFile.ReadString (" GAMEPAD" , " SQUARE-X" , " R" ));
@@ -422,7 +422,7 @@ void MainTextUpdate() {
422422 else if (AppStatus.GamepadEmulationMode == EmuGamepadDisabled)
423423 printf (" Emulation: Only mouse (for mouse aiming).\n " );
424424 else if (AppStatus.GamepadEmulationMode == EmuKeyboardAndMouse)
425- printf_s (" Emulation: Keyboard and mouse - %s .\n Change profiles with \" ALT + Up | Down\" or \" PS + DPAD Up | Down\" .\n " , KMProfiles[ProfileIndex].c_str ());
425+ printf_s (" Emulation: Keyboard and mouse (%s) .\n Change profiles with \" ALT + Up | Down\" or \" PS + DPAD Up | Down\" .\n " , KMProfiles[ProfileIndex].c_str ());
426426 printf (" Press \" ALT + Q\" or \" PS + DPAD Left | Right\" to switch emulation.\n " );
427427
428428 if (AppStatus.ExternalPedalsConnected )
@@ -431,17 +431,37 @@ void MainTextUpdate() {
431431 if (AppStatus.AimMode == AimMouseMode) printf (" AIM mode = mouse" ); else printf (" AIM mode = mouse-joystick" );
432432 printf (" , press \" ALT + A\" or \" PS + R1\" to switch.\n " );
433433
434+ if (AppStatus.GamepadEmulationMode == EmuGamepadEnabled) {
435+ if (AppStatus.LeftStickMode == LeftStickDefaultMode)
436+ printf (" Left stick mode: Default" );
437+ else if (AppStatus.LeftStickMode == LeftStickAutoPressMode)
438+ printf (" Left stick mode: Auto pressing by value" );
439+ else if (AppStatus.LeftStickMode == LeftStickInvertPressMode)
440+ printf (" Left stick mode: Invert pressed" );
441+ printf (" , press \" ALT + S\" or \" PS + LS\" to switch.\n " );
442+ }
443+
434444 if (AppStatus.ChangeModesWithoutPress ) printf (" Change modes without pressing the touchpad" ); else printf (" Change modes by pressing the touchpad" );
435445 printf (" , press \" ALT + W\" or \" PS + Share\" to switch.\n " );
436446 printf (" Press \" ALT + B\" or \" PS + L1\" to turn the backlight on or off.\n " );
437447
448+ if (AppStatus.ScreenshotMode == ScreenShotCustomKeyMode)
449+ printf (" Screenshot mode: Custom key" );
450+ else if (AppStatus.ScreenshotMode == ScreenShotXboxGameBarMode)
451+ printf (" Screenshot mode: Xbox Game Bar" );
452+ else if (AppStatus.ScreenshotMode == ScreenShotSteamMode)
453+ printf (" Screenshot mode: Steam (F12)" );
454+ else if (AppStatus.ScreenshotMode == ScreenShotMultiMode)
455+ printf (" Screenshot mode: Xbox Game Bar & Steam (F12)" );
456+ printf (" , press \" ALT + X\" to switch.\n " );
457+
438458 printf (" Press \" ALT + F9\" to get the sticks dead zones.\n " );
439459 printf (" Press \" ALT + Escape\" to exit.\n " );
440460}
441461
442462int main (int argc, char **argv)
443463{
444- SetConsoleTitle (" DSAdvance 0.8.5 " );
464+ SetConsoleTitle (" DSAdvance 0.8.6 " );
445465 // Config parameters
446466 CIniReader IniFile (" Config.ini" );
447467
@@ -465,6 +485,8 @@ int main(int argc, char **argv)
465485 float TouchRightStickX = IniFile.ReadFloat (" Gamepad" , " TouchRightStickSensX" , 4 );
466486 float TouchRightStickY = IniFile.ReadFloat (" Gamepad" , " TouchRightStickSensY" , 4 );
467487
488+ float AutoPressModeValue = IniFile.ReadFloat (" Gamepad" , " AutoPressModeStick" , 99 ) * 0 .01f ;
489+
468490 unsigned char DefaultLEDBrightness = std::clamp ((int )(255 - IniFile.ReadInteger (" Gamepad" , " DefaultBrightness" , 100 ) * 2.55 ), 0 , 255 );
469491 bool LockedChangeBrightness = IniFile.ReadBoolean (" Gamepad" , " LockChangeBrightness" , false );
470492 bool LockChangeBrightness = true ;
@@ -482,7 +504,11 @@ int main(int argc, char **argv)
482504 float JoySensY = IniFile.ReadFloat (" Motion" , " JoySensY" , 3 );
483505 float CustomMulSens = 1 ;
484506
507+ int ScreenShotKey = VK_GAMEBAR_SCREENSHOT;
485508 int MicCustomKey = KeyNameToKeyCode (IniFile.ReadString (" Gamepad" , " MicCustomKey" , " NONE" ));
509+ if (MicCustomKey == 0 ) AppStatus.ScreenshotMode = ScreenShotXboxGameBarMode; // If not set, then hide this mode
510+ else ScreenShotKey = MicCustomKey;
511+
486512
487513 int ExternalPedalsCOMPort = IniFile.ReadInteger (" ExternalPedals" , " COMPort" , 0 );
488514 if (ExternalPedalsCOMPort != 0 ) {
@@ -630,7 +656,7 @@ int main(int argc, char **argv)
630656 }
631657 }
632658
633- SkipPollCount = 35 ; // 15 is seems not enough to enable or disable Xbox virtual gamepad
659+ SkipPollCount = 30 ; // 15 is seems not enough to enable or disable Xbox virtual gamepad
634660
635661 if (AppStatus.GamepadEmulationMode == EmuKeyboardAndMouse)
636662 LoadKMProfile (KMProfiles[ProfileIndex]);
@@ -658,6 +684,26 @@ int main(int argc, char **argv)
658684 SkipPollCount = SkipPollTimeOut;
659685 }
660686
687+ // Switch left stick mode
688+ if ((((GetAsyncKeyState (VK_MENU) & 0x8000 ) != 0 && (GetAsyncKeyState (' S' ) & 0x8000 ) != 0 ) || (InputState.buttons & JSMASK_PS && InputState.buttons & JSMASK_LCLICK)) && SkipPollCount == 0 )
689+ {
690+ AppStatus.LeftStickMode ++; if (AppStatus.LeftStickMode > LeftStickMaxModes) AppStatus.LeftStickMode = LeftStickDefaultMode;
691+ MainTextUpdate ();
692+ SkipPollCount = SkipPollTimeOut;
693+ }
694+
695+ // Switch screenshot mode
696+ if ((GetAsyncKeyState (VK_MENU) & 0x8000 ) != 0 && (GetAsyncKeyState (' X' ) & 0x8000 ) != 0 && SkipPollCount == 0 )
697+ {
698+ AppStatus.ScreenshotMode ++; if (AppStatus.ScreenshotMode > ScreenShotMaxModes) AppStatus.ScreenshotMode = MicCustomKey == 0 ? ScreenShotXboxGameBarMode : ScreenShotCustomKeyMode;
699+ if (AppStatus.ScreenshotMode == ScreenShotCustomKeyMode) ScreenShotKey = MicCustomKey;
700+ else if (AppStatus.ScreenshotMode == ScreenShotXboxGameBarMode) ScreenShotKey = VK_GAMEBAR_SCREENSHOT;
701+ else if (AppStatus.ScreenshotMode == ScreenShotSteamMode) ScreenShotKey = VK_STEAM_SCREENSHOT;
702+ else if (AppStatus.ScreenshotMode == ScreenShotMultiMode) ScreenShotKey = VK_MULTI_SCREENSHOT;
703+ MainTextUpdate ();
704+ SkipPollCount = SkipPollTimeOut;
705+ }
706+
661707 // Enable or disable lightbar
662708 if ((((GetAsyncKeyState (VK_MENU) & 0x8000 ) != 0 && (GetAsyncKeyState (' B' ) & 0x8000 ) != 0 ) || (InputState.buttons & JSMASK_PS && InputState.buttons & JSMASK_L)) && SkipPollCount == 0 )
663709 {
@@ -762,6 +808,10 @@ int main(int argc, char **argv)
762808 report.sThumbRX = InvertRightStickX == false ? DeadZoneAxis (InputState.stickRX , DeadZoneRightStickX) * 32767 : DeadZoneAxis (-InputState.stickRX , DeadZoneRightStickX) * 32767 ;
763809 report.sThumbRY = InvertRightStickY == false ? DeadZoneAxis (InputState.stickRY , DeadZoneRightStickY) * 32767 : DeadZoneAxis (-InputState.stickRY , DeadZoneRightStickY) * 32767 ;
764810
811+ // Auto stick pressing when value is exceeded
812+ if (AppStatus.LeftStickMode == LeftStickAutoPressMode && (abs (InputState.stickLX ) > AutoPressModeValue || abs (InputState.stickLY ) > AutoPressModeValue))
813+ report.wButtons |= JSMASK_LCLICK;
814+
765815 report.bLeftTrigger = InputState.lTrigger * 255 ;
766816 report.bRightTrigger = InputState.rTrigger * 255 ;
767817
@@ -784,8 +834,11 @@ int main(int argc, char **argv)
784834
785835 if (!(InputState.buttons & JSMASK_PS)) { // During special functions, nothing is pressed in the game
786836 report.wButtons |= InputState.buttons & JSMASK_L ? XINPUT_GAMEPAD_LEFT_SHOULDER : 0 ;
787- report.wButtons |= InputState.buttons & JSMASK_R ? XINPUT_GAMEPAD_RIGHT_SHOULDER : 0 ;
788- report.wButtons |= InputState.buttons & JSMASK_LCLICK ? XINPUT_GAMEPAD_LEFT_THUMB : 0 ;
837+ report.wButtons |= InputState.buttons & JSMASK_R ? XINPUT_GAMEPAD_RIGHT_SHOULDER : 0 ;
838+ if (AppStatus.LeftStickMode != LeftStickInvertPressMode) // Invert stick mode
839+ report.wButtons |= InputState.buttons & JSMASK_LCLICK ? XINPUT_GAMEPAD_LEFT_THUMB : 0 ;
840+ else
841+ report.wButtons |= InputState.buttons & JSMASK_LCLICK ? 0 : XINPUT_GAMEPAD_LEFT_THUMB;
789842 report.wButtons |= InputState.buttons & JSMASK_RCLICK ? XINPUT_GAMEPAD_RIGHT_THUMB : 0 ;
790843 report.wButtons |= InputState.buttons & JSMASK_UP ? XINPUT_GAMEPAD_DPAD_UP : 0 ;
791844 report.wButtons |= InputState.buttons & JSMASK_DOWN ? XINPUT_GAMEPAD_DPAD_DOWN : 0 ;
@@ -818,7 +871,7 @@ int main(int argc, char **argv)
818871 KeyPress (VK_GAMEBAR, PSOnlyCheckCount == 1 && PSOnlyPressed, &ButtonsStates.PS );
819872 KeyPress (VK_VOLUME_DOWN, InputState.buttons & JSMASK_PS && InputState.buttons & JSMASK_W, &ButtonsStates.VolumeDown );
820873 KeyPress (VK_VOLUME_UP, InputState.buttons & JSMASK_PS && InputState.buttons & JSMASK_E, &ButtonsStates.VolumeUP );
821- KeyPress (MicCustomKey == 0 ? VK_GAMEBAR_SCREENSHOT : MicCustomKey , InputState.buttons & JSMASK_MIC || (InputState.buttons & JSMASK_PS && InputState.buttons & JSMASK_S), &ButtonsStates.Mic ); // + DualShock 4
874+ KeyPress (ScreenShotKey , InputState.buttons & JSMASK_MIC || (InputState.buttons & JSMASK_PS && InputState.buttons & JSMASK_S), &ButtonsStates.Mic ); // + DualShock 4
822875
823876 // Custom sens
824877 if (InputState.buttons & JSMASK_PS && InputState.buttons & JSMASK_N && SkipPollCount == 0 ) {
0 commit comments