Skip to content

Commit f1bd5ce

Browse files
committed
Improvement: Reset gamepads and bluetooth
1 parent 646b7d4 commit f1bd5ce

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

README.RU.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
Для того, чтобы выйти из режима эмуляции стиков на тачпаде нужно переключиться на режим по умолчанию.
1616

1717

18-
Нажимая на профиль по умолчанию, на DualSense, белые светодиоды отображает текущий статус заряда аккумулятора (1 - 25%, 2 - 50%, 3 - 75%, 4 - 100%).
18+
Нажимая на профиль по умолчанию, на DualSense, белые светодиоды отображают текущий статус заряда аккумулятора (1 - 25%, 2 - 50%, 3 - 75%, 4 - 100%).
1919

2020

2121
Кнопка `PS` симулирует нажатие `Win+G`, а кнопка микрофона `Win+Alt+PrtScr`.
@@ -28,6 +28,12 @@
2828
5. При необходимости измените мёртвые зоны стиков или другие параметры, в конфигурационном файле `Config.ini`.
2929
6. При использовании со Steam играми, в настройках контроллера, отключите "персональные настройки Playstation".
3030

31+
32+
## Возможные проблемы
33+
Часть игр несовместимы с данным методом, поскольку не расчитаны на использование мыши и геймпада одновременно. У части игр могут постоянно изменяться значки кнопок (с клавиатура на геймпад и наоборот).
34+
35+
36+
3137
## Загрузка
3238
>Версия для Windows 10.
3339

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ The `PS` button simulates pressing `Win+G`, and the microphone button `Win+Alt+P
2929
5. If necessary, change the dead zones of the sticks or other parameters in the configuration file `Config.ini`.
3030
6. When used with Steam games, in the controller settings, disable "Playstation personal settings".
3131

32+
## Possible problems
33+
Some games are incompatible with this method, since they are not designed to use a mouse and a gamepad at the same time. Some games can constantly change button icons (from keyboard to gamepad and vice versa).
34+
3235
## Download
3336
>Version for Windows 10.
3437

Source/DSAdvance/DSAdvance.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void GamepadSearch() {
122122
// BT detection https://github.com/JibbSmart/JoyShockLibrary/blob/master/JoyShockLibrary/JoyShock.cpp
123123
unsigned char buf[64];
124124
memset(buf, 0, 64);
125-
hid_read_timeout(CurGamepad.HidHandle, buf, 64, 100);
125+
hid_read_timeout(CurGamepad.HidHandle, buf, 64, 100);
126126
if (buf[0] == 0x31)
127127
CurGamepad.USBConnection = false;
128128
}
@@ -281,9 +281,15 @@ SHORT ToLeftStick(double Value, float WheelAngle)
281281
return LeftAxisX;
282282
}
283283

284+
void DefMainText() {
285+
system("cls");
286+
printf("\n Press \"ALT\" + \"Escape\" or \"exit key\" to exit.\n");
287+
printf(" Press \"CTRL\" + \"R\" to reset.\n");
288+
}
289+
284290
int main(int argc, char **argv)
285291
{
286-
SetConsoleTitle("DSAdvance 0.3");
292+
SetConsoleTitle("DSAdvance 0.3.1");
287293
// Config parameters
288294
CIniReader IniFile("Config.ini");
289295
int KEY_ID_EXIT = IniFile.ReadInteger("Main", "ExitBtn", 192); // "~" by default for RU, US and not for UK
@@ -320,6 +326,7 @@ int main(int argc, char **argv)
320326
int GamepadMode = 0; int LastAIMProCtrlMode = 2;
321327
EulerAngles AnglesOffset;
322328

329+
int BTReset = 180;
323330
int controllersCount = JslConnectDevices();
324331
int deviceID[4];
325332
JslGetConnectedDeviceHandles(deviceID, controllersCount);
@@ -328,6 +335,7 @@ int main(int argc, char **argv)
328335
if (controllersCount == 0)
329336
printf("\n Connect DualSense, DualShock 4, Pro controller and restart the app.");
330337
printf("\n Press \"ALT\" + \"Escape\" or \"exit key\" to exit.\n");
338+
printf(" Press \"CTRL\" + \"R\" to reset.\n");
331339

332340
JOY_SHOCK_STATE InputState;
333341
MOTION_STATE MotionState;
@@ -351,10 +359,7 @@ int main(int argc, char **argv)
351359
if ((GetAsyncKeyState(VK_F9) & 0x8000) != 0 && ((GetAsyncKeyState(VK_MENU) & 0x8000) != 0) && SkipPollCount == 0)
352360
{
353361
DeadZoneMode = !DeadZoneMode;
354-
if (DeadZoneMode == false) {
355-
system("cls");
356-
printf("\n Press \"ALT\" + \"Escape\" or \"exit key\" to exit.\n");
357-
}
362+
if (DeadZoneMode == false) DefMainText();
358363
SkipPollCount = 15;
359364
}
360365

@@ -365,6 +370,17 @@ int main(int argc, char **argv)
365370
printf("Y=%6.2f\n", abs(InputState.stickRY));
366371
}
367372

373+
if ( ( (GetAsyncKeyState('R') & 0x8000) != 0 && ((GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0) && SkipPollCount == 0 ) || (BTReset == 1 && CurGamepad.USBConnection) )
374+
{
375+
controllersCount = JslConnectDevices();
376+
JslGetConnectedDeviceHandles(deviceID, controllersCount);
377+
if (CurGamepad.HidHandle != NULL)
378+
hid_close(CurGamepad.HidHandle);
379+
GamepadSearch();
380+
SkipPollCount = 15;
381+
DefMainText();
382+
}
383+
368384
XUSB_REPORT_INIT(&report);
369385

370386
InputState = JslGetSimpleState(deviceID[0]);
@@ -538,6 +554,7 @@ int main(int argc, char **argv)
538554

539555
if (BatteryShowCounter > 0) { if (BatteryShowCounter == 1) { GamepadOutState.PlayersCount = 0; GamepadSetState(GamepadOutState); } BatteryShowCounter--; }
540556
if (SkipPollCount > 0) SkipPollCount--;
557+
if (BTReset > 0) BTReset--;
541558
Sleep(SleepTimeOut);
542559
}
543560

0 commit comments

Comments
 (0)