| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
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.
❗ Warning: The current release state is still a preview release. The library may not work as intended!
The library is still in active development and will be extended with additional features soon. Consider checking out our Road-map for further information.
If you don't want to waste time reading the documentation - this is the minimal example on how to use the library:
#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;
}I have partially used the following sources to implement the functionality:
| Back | FazBrowse Home | New Git URL |