JibbSmart / JoyShockLibrary

Read DualSense, DualShock 4, JoyCon, and Pro Controller input on PC -- compiled for Windows, but code should work on other platforms.
Other
226 stars 42 forks source link

Can't communicate with DualShock 4 #30

Closed AsyJAIZ closed 3 years ago

AsyJAIZ commented 3 years ago

Hi! I'm trying to get data from DualShock 4 connected via USB in C++, but i can't get any data, and JslConnectDevices says that there is 1 controller and i'm trying to get pressed buttons through JslGetButtons(1); but it always says "0". Also i created function to get connected controller type through switch (JslGetControllerType(1)) and for a second it says "DualShock 4" but after that "No data" What i did wrong? My code:

int countcontr = JslConnectDevices();
int* deviceIds = new int(countcontr);
JslGetConnectedDeviceHandles(deviceIds, countcontr);

std::string s = std::to_string(JslGetSimpleState(1).buttons);
s = "Input: " + s + " Controllers: " + std::to_string(count);
char const* pchar = s.c_str();
PutText(8, (WINDOW_HEIGHT - 8), pchar, RGB(0xFF, 0xFF, 0xFE));

PutText is function for printing strings on the screen

UPD: after four hours of reading README.md and thinking i've set callback function and it's working!