Skip to content

Commit

Permalink
Fixed rumble, battery and backlight for DualShock 4, added emulation …
Browse files Browse the repository at this point in the history
…of new buttons and commands
  • Loading branch information
r57zone committed Nov 23, 2024
1 parent addf10c commit 62b7a6c
Show file tree
Hide file tree
Showing 4 changed files with 272 additions and 191 deletions.
44 changes: 32 additions & 12 deletions BINDINGS.RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ F12 | `F12`
TAB | `TAB`
CAPS-LOCK | `CAPS-LOCK`
SHIFT | `SHIFT`
ЛЕВЫЙ SHIFT | `LSHIFT`
ПРАВЫЙ SHIFT | `RSHIFT`
CTRL | `CTRL`
ЛЕВЫЙ CTRL | `LCTRL`
ПРАВЫЙ CTRL | `RCTRL`
WIN | `WIN`
ALT | `ALT`
ЛЕВЫЙ ALT | `LALT`
ПРАВЫЙ ALT | `RALT`
ПРОБЕЛ | `SPACE`
ENTER | `ENTER`
BACKSPACE | `BACKSPACE`
Expand Down Expand Up @@ -119,16 +125,30 @@ NUMPAD + | `NUMPAD-PLUS`
NUMPAD DEL | `NUMPAD-DEL`

## Дополнительные кнопки
Описание | Значение
Значение | Описание
------------ | -------------
`VOLUME-UP` | Увеличить громкость
`VOLUME-DOWN` | Уменьшить громкость
`VOLUME-MUTE` | Включить / выключить звук
`HIDE-APPS` | Свернуть все приложения
`SWITCH-APP` | Показать все окна
`DISPLAY-KEYBOARD` | Вывести / спрятать экранную клавиатуру
`GAMEBAR` | Игровая панель
`GAMEBAR-SCREENSHOT` | Скриншот игровой панели
`FULLSCREEN` | Переключиться в полноэкранный режим `ALT + ENTER`
`FULLSCREEN-PLUS` | Переключиться в полноэкранный режим `ALT + ENTER` + `F` для сервисов YouTube и Twitch
`CHANGE-LANGUAGE` | Переключиться на другой язык
`VOLUME-UP` | Увеличить громкость.
`VOLUME-DOWN` | Уменьшить громкость.
`VOLUME-MUTE` | Включить / выключить звук.
`HIDE-APPS` | Свернуть все приложения.
`SWITCH-APP` | Показать все окна.
`DISPLAY-KEYBOARD` | Вывести / спрятать экранную клавиатуру.
`GAMEBAR` | Игровая панель.
`GAMEBAR-SCREENSHOT` | Скриншот игровой панели.
`FULLSCREEN` | Переключиться в полноэкранный режим `ALT + ENTER`.
`FULLSCREEN-PLUS` | Переключиться в полноэкранный режим `ALT + ENTER` + `F` для сервисов YouTube и Twitch.
`CHANGE-LANGUAGE` | Переключиться на другой язык.
`CUT` | Вырезать.
`COPY` | Копировать.
`PASTE` | Вставить.
`MEDIA-NEXT-TRACK` | Воспроизведение следующего трека.
`MEDIA-PREV-TRACK` | Воспроизведение предыдущего трека.
`MEDIA-STOP` | Остановка воспроизведения медиа.
`MEDIA-PLAY-PAUSE` | Воспроизведение или пауза медиа.
`BROWSER-BACK` | Переход назад в браузере.
`BROWSER-FORWARD` | Переход вперед в браузере.
`BROWSER-REFRESH` | Обновление текущей страницы.
`BROWSER-STOP` | Остановка загрузки страницы.
`BROWSER-SEARCH` | Открытие поиска в браузере.
`BROWSER-FAVORITES` | Открытие списка избранного.
`BROWSER-HOME` | Переход на главную страницу.
42 changes: 31 additions & 11 deletions BINDINGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ F12 | `F12`
TAB | `TAB`
CAPS-LOCK | `CAPS-LOCK`
SHIFT | `SHIFT`
LEFT SHIFT | `LSHIFT`
RIGHT SHIFT | `RSHIFT`
CTRL | `CTRL`
LEFT CTRL | `LCTRL`
RIGHT CTRL | `RCTRL`
WIN | `WIN`
ALT | `ALT`
LEFT ALT | `LALT`
RIGHT ALT | `RALT`
SPACE | `SPACE`
ENTER | `ENTER`
BACKSPACE | `BACKSPACE`
Expand Down Expand Up @@ -120,14 +126,28 @@ NUMPAD DEL | `NUMPAD-DEL`
## Additional action buttons
Value | Description
------------ | -------------
`VOLUME-UP` | Volume up
`VOLUME-DOWN` | Volume down
`VOLUME-MUTE` | Enable / disable sound
`HIDE-APPS` | Minimize all applications
`SWITCH-APP` | Show all windows
`DISPLAY-KEYBOARD` | Show / hide the on-screen keyboard
`GAMEBAR` | Show / hide the Game Bar
`GAMEBAR-SCREENSHOT` | Game bar screenshot
`FULLSCREEN` | Switch to full screen mode `ALT + ENTER`
`FULLSCREEN-PLUS` | Switch to full screen mode `ALT + ENTER` + `F` for YouTube and Twitch services
`CHANGE-LANGUAGE` | Switch to another language
`VOLUME-UP` | Volume up.
`VOLUME-DOWN` | Volume down.
`VOLUME-MUTE` | Enable / disable sound.
`HIDE-APPS` | Minimize all applications.
`SWITCH-APP` | Show all windows.
`DISPLAY-KEYBOARD` | Show / hide the on-screen keyboard.
`GAMEBAR` | Show / hide the Game Bar.
`GAMEBAR-SCREENSHOT` | Game bar screenshot.
`FULLSCREEN` | Switch to full screen mode `ALT + ENTER`.
`FULLSCREEN-PLUS` | Switch to full screen mode `ALT + ENTER` + `F` for YouTube and Twitch services.
`CHANGE-LANGUAGE` | Switch to another language.
`CUT` | Cut.
`COPY` | Copy.
`PASTE` | Paste.
`MEDIA-NEXT-TRACK` | Play the next track.
`MEDIA-PREV-TRACK` | Play the previous track.
`MEDIA-STOP` | Stop media playback.
`MEDIA-PLAY-PAUSE` | Play or pause media.
`BROWSER-BACK` | Go back in the browser.
`BROWSER-FORWARD` | Go forward in the browser.
`BROWSER-REFRESH` | Refresh the current page.
`BROWSER-STOP` | Stop loading the page.
`BROWSER-SEARCH` | Open search in the browser.
`BROWSER-FAVORITES` | Open the favorites list.
`BROWSER-HOME` | Go to the home page.
35 changes: 20 additions & 15 deletions Source/DSAdvance/DSAdvance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,15 @@ void GamepadSearch() {
} else if (cur_dev->product_id == SONY_DS4_USB || cur_dev->product_id == SONY_DS4_V2_USB || cur_dev->product_id == SONY_DS4_DONGLE) {
CurGamepad.ControllerType = SONY_DUALSHOCK4;
CurGamepad.USBConnection = true;

// BT detection
unsigned char buf[64];
memset(buf, 0, sizeof(buf));
int bytesRead = hid_read_timeout(CurGamepad.HidHandle, buf, sizeof(buf), 100);
if (bytesRead > 0 && buf[0] == 0x11)
CurGamepad.USBConnection = false;

} else if (cur_dev->product_id == SONY_DS4_BT) {
} else if (cur_dev->product_id == SONY_DS4_BT) { // ?
CurGamepad.ControllerType = SONY_DUALSHOCK4;
CurGamepad.USBConnection = false;
}
Expand Down Expand Up @@ -253,25 +260,23 @@ void GetBatteryInfo() {
if (CurGamepad.USBConnection)
CurGamepad.BatteryLevel = (buf[30] & DS_STATUS_BATTERY_CAPACITY) * 100 / DS4_USB_BATTERY_MAX;
else
CurGamepad.BatteryLevel = (buf[31] & DS_STATUS_BATTERY_CAPACITY) * 100 / DS_BATTERY_MAX; // offset 1?
CurGamepad.BatteryLevel = (buf[32] & DS_STATUS_BATTERY_CAPACITY) * 100 / DS_BATTERY_MAX;
}
if (CurGamepad.BatteryLevel > 100) CurGamepad.BatteryLevel = 100; // It looks like something is not right, once it gave out 125%
}
}

void ExternalPedalsDInputSearch() {
if (joyGetPosEx(JOYSTICKID1, &AppStatus.ExternalPedalsJoyInfo) == JOYERR_NOERROR &&
joyGetDevCaps(JOYSTICKID1, &AppStatus.ExternalPedalsJoyCaps, sizeof(AppStatus.ExternalPedalsJoyCaps)) == JOYERR_NOERROR &&
AppStatus.ExternalPedalsJoyCaps.wNumButtons == 16) { // DualSense - 15, DigiJoy - 16
AppStatus.ExternalPedalsJoyIndex = JOYSTICKID1;
AppStatus.ExternalPedalsDInputConnected = true;
} else if (joyGetPosEx(JOYSTICKID2, &AppStatus.ExternalPedalsJoyInfo) == JOYERR_NOERROR &&
joyGetDevCaps(JOYSTICKID2, &AppStatus.ExternalPedalsJoyCaps, sizeof(AppStatus.ExternalPedalsJoyCaps)) == JOYERR_NOERROR &&
AppStatus.ExternalPedalsJoyCaps.wNumButtons == 16) {
AppStatus.ExternalPedalsJoyIndex = JOYSTICKID2;
AppStatus.ExternalPedalsDInputConnected = true;
} else
AppStatus.ExternalPedalsDInputConnected = false;
ExternalPedalsConnected = false;
for (int JoyID = 0; JoyID < 4; ++JoyID) { // JOYSTICKID4 - 3
if (joyGetPosEx(JoyID, &AppStatus.ExternalPedalsJoyInfo) == JOYERR_NOERROR && // JoyID - JOYSTICKID1..4
joyGetDevCaps(JoyID, &AppStatus.ExternalPedalsJoyCaps, sizeof(AppStatus.ExternalPedalsJoyCaps)) == JOYERR_NOERROR &&
AppStatus.ExternalPedalsJoyCaps.wNumButtons == 16) { // DualSense - 15, DigiJoy - 16
AppStatus.ExternalPedalsJoyIndex = JoyID;
AppStatus.ExternalPedalsDInputConnected = true;
break;
}
}
}

void ExternalPedalsArduinoRead()
Expand Down Expand Up @@ -520,7 +525,7 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)

int main(int argc, char **argv)
{
SetConsoleTitle("DSAdvance 0.9.7");
SetConsoleTitle("DSAdvance 0.9.8");

WNDCLASS AppWndClass = {};
AppWndClass.lpfnWndProc = WindowProc;
Expand Down
Loading

0 comments on commit 62b7a6c

Please sign in to comment.