Skip to content

Commit 4a3b671

Browse files
committed
Improvements: Battery status display via keyboard, support for PS4 dongle, and initial support for DualSense EDGE
1 parent 75a59b2 commit 4a3b671

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

Source/DSAdvance/DSAdvance.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// DSAdvance by r57zone
2+
// Advanced Xbox controller emulation for DualSense, DualShock 4, Pro Controller, Joy-Cons
23
// https://github.com/r57zone/DSAdvance
34

45
#include <windows.h>
@@ -11,7 +12,7 @@
1112
#include "hidapi.h"
1213
#include "DSAdvance.h"
1314
#include <thread>
14-
#include <atlstr.h>
15+
#include <atlstr.h>
1516

1617
#pragma comment(lib, "winmm.lib")
1718

@@ -152,12 +153,17 @@ void GamepadSearch() {
152153
// Sony controllers
153154
cur_dev = hid_enumerate(SONY_VENDOR, 0x0);
154155
while (cur_dev) {
155-
if (cur_dev->product_id == SONY_DS5 || cur_dev->product_id == SONY_DS4_USB || cur_dev->product_id == SONY_DS4_V2_USB || cur_dev->product_id == SONY_DS4_BT)
156+
if (cur_dev->product_id == SONY_DS5 ||
157+
cur_dev->product_id == SONY_DS5_EDGE ||
158+
cur_dev->product_id == SONY_DS4_USB ||
159+
cur_dev->product_id == SONY_DS4_V2_USB ||
160+
cur_dev->product_id == SONY_DS4_BT ||
161+
cur_dev->product_id == SONY_DS4_DONGLE)
156162
{
157163
CurGamepad.HidHandle = hid_open(cur_dev->vendor_id, cur_dev->product_id, cur_dev->serial_number);
158164
hid_set_nonblocking(CurGamepad.HidHandle, 1);
159165

160-
if (cur_dev->product_id == SONY_DS5) {
166+
if (cur_dev->product_id == SONY_DS5 || cur_dev->product_id == SONY_DS5_EDGE) {
161167
CurGamepad.ControllerType = SONY_DUALSENSE;
162168
CurGamepad.USBConnection = true;
163169

@@ -168,7 +174,7 @@ void GamepadSearch() {
168174
if (buf[0] == 0x31)
169175
CurGamepad.USBConnection = false;
170176

171-
} else if (cur_dev->product_id == SONY_DS4_USB || cur_dev->product_id == SONY_DS4_V2_USB) {
177+
} else if (cur_dev->product_id == SONY_DS4_USB || cur_dev->product_id == SONY_DS4_V2_USB || cur_dev->product_id == SONY_DS4_DONGLE) {
172178
CurGamepad.ControllerType = SONY_DUALSHOCK4;
173179
CurGamepad.USBConnection = true;
174180

@@ -456,12 +462,13 @@ void MainTextUpdate() {
456462
printf(", press \"ALT + X\" to switch.\n");
457463

458464
printf(" Press \"ALT + F9\" to get the sticks dead zones.\n");
465+
printf(" Press \"ALT + I\" to get the battery status.\n");
459466
printf(" Press \"ALT + Escape\" to exit.\n");
460467
}
461468

462469
int main(int argc, char **argv)
463470
{
464-
SetConsoleTitle("DSAdvance 0.8.6");
471+
SetConsoleTitle("DSAdvance 0.8.7");
465472
// Config parameters
466473
CIniReader IniFile("Config.ini");
467474

@@ -802,6 +809,14 @@ int main(int argc, char **argv)
802809

803810
}
804811

812+
if ((GetAsyncKeyState(VK_MENU) & 0x8000) != 0 && ((GetAsyncKeyState('I') & 0x8000) != 0) && SkipPollCount == 0 && GetConsoleWindow() == GetForegroundWindow())
813+
{
814+
SkipPollCount = SkipPollTimeOut;
815+
GetBatteryInfo(); if (BackOutStateCounter == 0) BackOutStateCounter = 40; //
816+
AppStatus.ShowBatteryStatus = true;
817+
MainTextUpdate();
818+
}
819+
805820
//printf("%5.2f\t%5.2f\r\n", InputState.stickLX, DeadZoneAxis(InputState.stickLX, DeadZoneLeftStickX));
806821
report.sThumbLX = InvertLeftStickX == false ? DeadZoneAxis(InputState.stickLX, DeadZoneLeftStickX) * 32767 : DeadZoneAxis(-InputState.stickLX, DeadZoneLeftStickX) * 32767;
807822
report.sThumbLY = InvertLeftStickX == false ? DeadZoneAxis(InputState.stickLY, DeadZoneLeftStickY) * 32767 : DeadZoneAxis(-InputState.stickLY, DeadZoneLeftStickY) * 32767;

Source/DSAdvance/DSAdvance.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
#define SONY_VENDOR 0x054C
77
#define SONY_DS4_USB 0x05C4
88
#define SONY_DS4_V2_USB 0x09CC
9+
#define SONY_DS4_DONGLE 0x0BA0
910
#define SONY_DS4_BT 0x081F
1011
#define SONY_DS5 0x0CE6
12+
#define SONY_DS5_EDGE 0x0DF2
1113

1214
// DS4 compatible controllers
1315
#define BROOK_DS4_VENDOR 0x0C12
@@ -67,7 +69,7 @@
6769
#define ScreenShotMaxModes 3
6870

6971
#define SkipPollTimeOut 15
70-
#define ResetControllersTimeOut 2000 // JoyShockLibrary bug with increase in CPU usage when the controller is turned off & auto connection gamepad
72+
#define ResetControllersTimeOut 2000 // JoyShockLibrary 2.2.0 bug with increase in CPU usage when the controller is turned off & auto connection gamepad
7173
#define PSReleasedTimeOut 30
7274

7375
#define WASDStickMode 0

0 commit comments

Comments
 (0)