JibbSmart / JoyShockLibrary

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

Can't even get JslConnectDevices() working. #32

Open Kablion opened 3 years ago

Kablion commented 3 years ago

I've not managed to really use this library because I can't even run JslConnectDevices(). I can build the .exe but running it just produces no output. I assume the program crashes due to JslConnectDevices() because it runs fine if I remove this line. But debugging with VSCode doesn't even run the lines before that. And no error message is produced. I just downloaded the release 2.2.0 and put the JSL directory in my project directory.

I am using the VSCode Debugger with the folllowing builld task (created automatically except the -I,-L,-l args):

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe build active file",
            "command": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "-LPATH\\TO\\MY\\PROJECT\\JSL\\x64",
                "-IPATH\\TO\\MY\\PROJECT\\JSL",
                "-lJoyShockLibrary",
                "-Wall",
                "-Wextra"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

My Code:

#include "JoyShockLibrary.h"
#include <iostream>

using namespace std;

int main()
{
    int i = -1;
    try
    {
        i = JslConnectDevices();
    }
    catch(const std::exception& e)
    {
        std::cerr << e.what() << '\n';
    }

    cout << "Test " << i << endl;

    return 1;
}

What am I doing wrong?

Allexin commented 3 years ago

I have similar issue: i have two pairs of joycons: one from DOBE - JslConnectDevices works fine one from aliexpress RETROPIE MK-02 - JslConnectDevices freezes my app.

hizbi-github commented 3 years ago

Hello!

I was having the same problem. I solved it by placing the "JoyShockLibrary.dll" in the same directory as the "main.cpp" file. The "JSL" folder was still there in the main directory of the "main.cpp" file.

Other than that, I had the same configuration as yours and was using the Visual Studio Code.

When building and running the "main.cpp" file within the VS Code, it would just crash without any errors. Only when I ran the "main.exe" manually by double-clicking it, a Windows dialog box showed up saying that it was unable to find the "JoyShockLibrary.dll".

I have since used the library with two genuine DS4 Controllers, both wired and Bluetooth, and they worked perfectly!