Skip to content

Commit

Permalink
Changes for first release
Browse files Browse the repository at this point in the history
  • Loading branch information
Ohjurot committed Nov 27, 2020
1 parent 0d4a9b7 commit 91e6263
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 55 deletions.
34 changes: 17 additions & 17 deletions Doc/APIRef.tex
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,20 @@ \subsection{Types}
\label{APIRef_Types_vec3}
\paragraph{Vector3, Vec3} Represents a three component 16-Bit vector \\

\tbly{int16\_t}{x}{X Component} \\
\tbly{int16\_t}{x}{X Component.} \\

\tbly{int16\_t}{y}{Y Component} \\
\tbly{int16\_t}{y}{Y Component.} \\

\tbly{int16\_t}{z}{Z Component} \\
\tbly{int16\_t}{z}{Z Component.} \\

\label{APIRef_Types_color}
\paragraph{Color} RGB 8-Bit color components. The library also provides several conversion functions to turn several color formats into 8-Bit RGB values.\\

\tbly{uint8\_t}{r}{R - Red color channel}\\
\tbly{uint8\_t}{r}{R - Red color channel.}\\

\tbly{uint8\_t}{g}{G - Green color channel}\\
\tbly{uint8\_t}{g}{G - Green color channel.}\\

\tbly{uint8\_t}{b}{B - Blue color channel}\\
\tbly{uint8\_t}{b}{B - Blue color channel.}\\

\label{APIRef_Types_touch}
\paragraph{Touch} This struct contains information about a single fingers touch position. \\
Expand All @@ -146,9 +146,9 @@ \subsection{Types}
\label{APIRef_Types_micled}
\paragraph{MicLed} Enum class representation the state of the microphone LED. \\

\tblx{OFF}{Microphone LED is completely off}
\tblx{ON}{Microphone LED is on}
\tblx{PULSE}{Microphone LED is pulsing}
\tblx{OFF}{Microphone LED is completely off.}
\tblx{ON}{Microphone LED is on.}
\tblx{PULSE}{Microphone LED is pulsing.}


\label{APIRef_Types_tfxt}
Expand Down Expand Up @@ -189,21 +189,21 @@ \subsection{Types}

\tbly{bool}{EffectEx.keepEffect}{Indicates weather the effect should keep playing (vibration) when the trigger is fully pressed.}\\

\tbly{uint8\_t}{EffectEx.beginForce}{Force for the section with trigger value >= 128.}\\
\tbly{uint8\_t}{EffectEx.beginForce}{Force for the section with trigger value $\geq 128$.}\\

\tbly{uint8\_t}{EffectEx.middleForce}{Force for the section with trigger value <= 128.}\\
\tbly{uint8\_t}{EffectEx.middleForce}{Force for the section with trigger value $\leq 128$.}\\

\tbly{uint8\_t}{EffectEx.endForce}{Force applied when the trigger is fully pressed / would go beyond 255.}\\

\tbly{uint8\_t}{EffectEx.frequency}{Frequency with witch the effect is executed. More a scalar value to scale between two fixed frequency than an read frequency parameter,}\\
\tbly{uint8\_t}{EffectEx.frequency}{Frequency with witch the effect is executed. More a scalar value to scale between two fixed frequency than an real frequency parameter.}\\


\label{APIRef_Types_ledbr}
\paragraph{LedBrightness} Enum class representation the brightness of the player indication LEDs.\\

\tblx{LOW}{Low brightness player indication LEDs}
\tblx{MEDIUM}{Medium brightness player indication LEDs}
\tblx{HIGH}{High brightness player indication LEDs}
\tblx{LOW}{Low brightness player indication LEDs.}
\tblx{MEDIUM}{Medium brightness player indication LEDs.}
\tblx{HIGH}{High brightness player indication LEDs.}

\label{APIRef_Types_pleds}
\paragraph{PlayerLeds} Struct defining the player LDEs state.\\
Expand All @@ -212,7 +212,7 @@ \subsection{Types}

\tbly{bool}{playerLedFade}{Indicates weather the player LEDs should fade in when enabled.}\\

\tbly{\hyperref[APIRef_Types_ledbr]{LedBrightness}}{brightness}{Brightness of the player LEDs}\\
\tbly{\hyperref[APIRef_Types_ledbr]{LedBrightness}}{brightness}{Brightness of the player LEDs.}\\


\paragraph{DS5InputState}
Expand Down Expand Up @@ -260,7 +260,7 @@ \subsection{Types}

\tbly{\hyperref[APIRef_Types_pleds]{PlayerLeds}}{playerLeds}{State of the player LEDs.}\\

\tbly{\hyperref[APIRef_Types_color]{Color}}{lightbar}{RGB Color of the lightbar. No affect when \texttt{disableLeds} is \texttt{true}}\\
\tbly{\hyperref[APIRef_Types_color]{Color}}{lightbar}{RGB Color of the lightbar. No affect when \texttt{disableLeds} is \texttt{true}.}\\

\tbly{\hyperref[APIRef_Types_trigfx]{TriggerEffect}}{leftTriggerEffect}{Effect of the left adaptive trigger.}\\

Expand Down
Binary file modified Doc/DualSenseWindows_Doc.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions Doc/DualSenseWindows_Doc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
keywordstyle=\color{clr-type},
keywordstyle={[2]\color{clr-constant}},
tabsize=4,
breaklines=true,
numbers=left,
numbersep=5pt
}
Expand Down
8 changes: 4 additions & 4 deletions Doc/Features.tex
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ \subsection{Feature List}
\end{figure}

\paragraph{Adaptive trigger}
The DualSense controller feature two 8-Bit analog triggers. It is possible to read the trigger values as 8-Bit continuous values or alternatively as binary button input. Aside of the normal trigger operation the adaptive triggers can be configured to simulate various force feedback effects. It is possible for example to simulate a gun trigger.
The DualSense controller features two 8-Bit analog triggers. It is possible to read the trigger values as 8-Bit continuous values or alternatively as binary button input. Aside of the normal trigger operation the adaptive triggers can be configured to simulate various force feedback effects. It is possible for example to simulate a gun trigger.
\begin{figure}[H]
\centering
\subfloat{{\includegraphics[width=8cm]{rearView_trigger} }}
Expand All @@ -57,7 +57,7 @@ \subsection{Feature List}
\end{figure}

\paragraph{DPAD and PS Buttons}
The DualSense controller feature a DPAD and the default well know PlayStation Square, Cross, Circle and Triangle buttons. The DPAD is capable of registering two simultaneously pressed buttons, however the two buttons must be neighbors. The PS-Buttons are being registered as four individual binary values.
The DualSense controller features a DPAD and the default well know PlayStation Square, Cross, Circle and Triangle buttons. The DPAD is capable of registering two simultaneously pressed buttons, however the two buttons must be neighbors. The PS-Buttons are being registered as four individual binary values.
\begin{figure}[H]
\centering
\subfloat{{\includegraphics[width=8cm]{frontView_mainbtn} }}
Expand All @@ -69,7 +69,7 @@ \subsection{Feature List}
\begin{itemize}
\item \textbf{Menu button} Should be used to open the in-game menu.
\item \textbf{Share button} Should be used to open the in-game photo mode.
\item \textbf{PlayStation button} Can be used to open a in-game overlay (Look at the know issues to get an additional use case of this button).
\item \textbf{PlayStation button} Can be used to open a in-game overlay.
\item \textbf{Mic button} Should be used to mute the microphone.
\end{itemize}
All the listed buttons are readable through individual binary values.
Expand Down Expand Up @@ -102,7 +102,7 @@ \subsection{Feature List}
\end{itemize}

\paragraph{Rumble motors / Haptic feedback}
The DualSense feature two Haptic feedback devices. Thees device work similar like normal speaker, but they are not good in producing tones, they are good in producing vibration. It is possible to send an audio signal directly to those haptic speakers (However currently not supported by this API).\\
The DualSense feature two Haptic feedback devices. Thees device work similar like normal speakers, but they are not good in producing tones, they are good in producing vibration. It is possible to send an audio signal directly to those haptic speakers (However currently not supported by this API).\\
The controller supports simulating the normal soft and hard rumble motors using the haptic speakers. When using this mode both motors can be controlled with the usual 8-Bit values. The left rumble feels hard, the right one soft.

\paragraph{Integrated speaker and microphone}
Expand Down
Binary file modified Doc/GitHub_readme/header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion Doc/ImportantInfos.tex
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
\section{Important information}
\subsection{Trademarks and affiliation}
"PlayStation", "PlayStation Family Mark", "PS5 logo", "PS5", "DualSense" and "DUALSHOCK" are registered trademarks or trademarks of Sony Interactive Entertainment Inc. "SONY" is a registered trademark of Sony Corporation.
"PlayStation", "PlayStation Family Mark", "PS5 logo", "PS5", "DualSense" and "DUALSHOCK" are registered trademarks or trademarks of Sony Interactive Entertainment Inc. "SONY" is a registered trademark of Sony Corporation. \\

"Windows" is a registered trademark of Microsoft Corporation. \\

\textbf{The Author is not affiliated in any kind with Sony Interactive Entertainment Inc.!} \\
\textbf{The Author is not affiliated in any kind with Microsoft Corporation!} \\
Using this library may void your / your clients / your users / your customers controllers warranty! You as the redistributor of the precompiled or self compiled library have to make sure the controller will not be damaged by the functionality you use or at least point out the possible risk to your users / clients / customer!\\
Probably no damage or failure at all. This statement is just for my own safety!

Expand All @@ -20,6 +23,8 @@ \subsection{Sources}
\subsection{License}
\textbf{MIT License}\\

\textbf{Info} Only the implementation is licensed by the MIT license. The protocol of the DualSense 5 controller has been discovered independently and collectively by several people. You can find my sources in the GitHub repository.

Copyright (c) 2020 Ludwig Füchsl\\

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\\
Expand Down
2 changes: 1 addition & 1 deletion Doc/Introduction.tex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ \section{Introduction}
\item api references
\end{itemize}

We recommend starting with reading through all features as far as you are not familiar with the DualSense controllers feature. Continuing with the installation and getting started guide to get your own demo application up and running. Then you can use the API references to integrate the api into your application.
We recommend starting with reading through all features as far as you are not familiar with the DualSense controllers features. Continuing with the installation and getting started guide to get your own demo application up and running. Then you can use the API references to integrate the api into your application.

\newpage
1 change: 1 addition & 0 deletions Doc/QuickStart.tex
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ \subsection{Enumerate controllers}

// Call enumerate function and switch on return value
switch(DS5W::enumDevices(infos, 16, &controllersCount)){
case DS5W_OK:
// The buffer was not big enough. Ignore for now
case DS5W_E_INSUFFICIENT_BUFFER:
break;
Expand Down
6 changes: 6 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
MIT License

----------------------------------- Info -----------------------------------
Only the implementation is licensed by the MIT license. The protocol of the
DualSense 5 controller has been discovered independently and collectively by
several people. You can find my sources in the GitHub repository.
----------------------------------------------------------------------------

Copyright (c) 2020 Ludwig Füchsl

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
129 changes: 98 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,120 @@
# DualSense / PS5 Controller on Windows [API]
Windows API for the PS5 DualSense controller. Written in C++ for C++
# DualSense on Windows [API]
![](https://raw.githubusercontent.com/Ohjurot/DualSense-Windows/main/Doc/GitHub_readme/header.png)

First Release coming soon!

#### Road map to first preview release:

- ~~Reading the input state from the controller using USB~~. DONE!
- ~~Reading input via bluetooth~~. DONE!
- ~~Writing Output state to the controller using USB~~. DONE!
- ~~Controlling and reading the adaptive triggers.~~ DONE!
- ~~Writing Output state via bluetooth.~~ DONE!
- Addition input / output parameters. *Work in progress*
- Calibrating the gyroscope *Work in progress*
- Documenting the API *Work in progress*
- Updating the github repo and publish release
Windows API for the PS5 DualSense controller. Written in C++ for C++. This API will help you using the DualSense controller in your windows C++ Applications / Projects.

First preview should be released before 28.11.2020 (The hard work is done - The USB and BT protocol is, at least partially, reverse engineered)
> :exclamation: ​Warning: The current release state is still a preview release. The library may not work as intended!
#### Features of the first preview
## Features

- Reading all buttons and analog values (triggers and sticks) which are on the controller
- Reading all button input from the controller
- Reading the analog sticks and analog triggers
- Reading the two finger touch positions
- Reading the accelerometer
- Reading the gyroscope (Currently only raw / uncalibrated values)
- Reading the connection state of the headphone jack
- Setting the rumble motors speed
- Setting various effects to the force feedback triggers
- Retrieving force feedback triggers feedback
- controlling the RGB-Leds, Microphone Led and User Leds
- Reading the Accelerometer and Gyroscope
- Using the haptic feedback for default rumbleing
- Controlling the adaptive triggers (3 Types of effects) and reading back the users force while active
- Controlling the RGB color of the lighbar
- Setting the player indication LEDs and the microphone LED

Fully working over USB and Bluetooth!
The library is still in active development and will be extended with additional features soon. Consider checking out our [Road-map](https://github.com/Ohjurot/DualSense-Windows/blob/main/ROADMAP.md) for further information.

#### Feature planed for the future
## Using the API

- Using the haptic feedback
- Internal speaker and mic
1. Download the `DualSenseWindows_VX.X.zip` file from the latest release found at the [Release Page](https://github.com/Ohjurot/DualSense-Windows/releases)
2. Unzip the archive to your computer
3. Read the `DualSenseWindows.pdf` PDF documentation to get the specific information for your current release

#### Know issues
If you don't want to mess your time documentation - this is the minimal example on how to use the library:

```c++
#include <Windows.h>
#include <ds5w.h>
#include <iostream>

int main(int argc, char** argv){
// Array of controller infos
DS5W::DeviceEnumInfo infos[16];

// Number of controllers found
unsigned int controllersCount = 0;

// Call enumerate function and switch on return value
switch(DS5W::enumDevices(infos, 16, &controllersCount)){
case DS5W_OK:
// The buffer was not big enough. Ignore for now
case DS5W_E_INSUFFICIENT_BUFFER:
break;

// Any other error will terminate the application
default:
// Insert your error handling
return -1;
}

// Check number of controllers
if(!controllersCount){
return -1;
}

// Context for controller
DS5W::DeviceContext con;

// Init controller and close application is failed
if(DS5W_FAILED(DS5W::initDeviceContext(&infos[0], &con))){
return -1;
}

// Main loop
while(true){
// Input state
DS5W::DS5InputState inState;

// Retrieve data
if (DS5W_SUCCESS(DS5W::getDeviceInputState(&con, &inState))){
// Check for the Logo button
if(inState.buttonsB & DS5W_ISTATE_BTN_B_PLAYSTATION_LOGO){
// Break from while loop
break;
}

// Create struct and zero it
DS5W::DS5OutputState outState;
ZeroMemory(&outState, sizeof(DS5W::DS5OutputState));

// Set output data
outState.leftRumble = inState.leftTrigger;
outState.rightRumble = inState.rightTrigger;

// Send output to the controller
DS5W::setDeviceOutputState(&con, &outState);
}
}

// Shutdown context
DS5W::freeDeviceContext(&con);

// Return zero
return 0;
}
```
## Known issues
- When the controller being shut down while connected via Bluetooth (Holding the PS button). The lib will encounter a dead lock within `getDeviceInputState(...)` call. The function will return as soon as the controller is getting reconnected. Not encountering over USB, over USB the expected `DS5W_E_DEVICE_REMOVED` error is returned.
#### Sources
## Special thanks to
I have partially used the following sources to implement the functionality:
- The GitHub community on this project and https://github.com/Ryochan7/DS4Windows/issues/1545
- https://www.reddit.com/r/gamedev/comments/jumvi5/dualsense_haptics_leds_and_more_hid_output_report/
- https://gist.github.com/dogtopus/894da226d73afb3bdd195df41b3a26aa
- https://gist.github.com/Ryochan7/ef8fabae34c0d8b30e2ab057f3e6e039
- https://gist.github.com/Ryochan7/91a9759deb5dff3096fc5afd50ba19e2
- https://github.com/Ryochan7/DS4Windows/tree/dualsense-integration (Copyright (c) 2019 Travis Nickles - [MIT License](https://github.com/Ryochan7/DS4Windows/blob/jay/LICENSE.txt))
- https://www.reddit.com/r/gamedev/comments/jumvi5/dualsense_haptics_leds_and_more_hid_output_report/
[Important Informations about Trademarks](https://github.com/Ohjurot/DualSense-Windows/blob/main/TRADEMARKS.md)
10 changes: 10 additions & 0 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Road-Map

This is my list of feature I would like to see being supported by my API:

- Getting addition input working (Battery, ...)
- Using the haptic feedback
- Playing audio through all channels (somewhat related to haptic feedback)
- Listening to the user with the integrated microphone
- Controlling all that audio related stuff (Volume / Mute / ...)

5 changes: 5 additions & 0 deletions TRADEMARKS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"PlayStation", "PlayStation Family Mark", "PS5 logo", "PS5", "DualSense" and "DUALSHOCK" are registered trademarks or trademarks of Sony Interactive Entertainment Inc. "SONY" is a registered trademark of Sony Corporation.

"Windows" is a registered trademark of Microsoft Corporation.

The Author is not affiliated in any kind with Sony Interactive Entertainment Inc.! The Author is not affiliated in any kind with Microsoft Corporation!
2 changes: 1 addition & 1 deletion VS19_Solution/DS5W_Test/src/wWinMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ INT WINAPI wWinMain(HINSTANCE _In_ hInstance, HINSTANCE _In_opt_ hPrevInstance,
outState.rightRumble = (rrmbl & 0xFF00) >> 8UL;

// Lightbar
outState.lightbar = DS5W::color_R8G8B8_UCHAR_A32_UNORM(255, 0, 0, intensity);
outState.lightbar = DS5W::color_R8G8B8_UCHAR_A32_FLOAT(255, 0, 0, intensity);
intensity -= 0.0025f / btMul;
if (intensity <= 0.0f) {
intensity = 1.0f;
Expand Down

0 comments on commit 91e6263

Please sign in to comment.