/dualshock4_cpp

my trial to get any user input from DualShock 4 v2

Primary LanguageC++

dualshock4_cpp

my trial to get any user input from DualShock 4 v2

In progress of development for Linux...

Usage example

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


int main() {
    dualshock4::GamepadEventDispatcher eventDispatcher{};

    eventDispatcher.registerEventHandler(dualshock4::KEY_UP, []() {
        std::cout << "\n";
    });

    eventDispatcher.registerEventHandler(dualshock4::KEY_DOWN, []() {
        std::cout << "\n";
    });

    eventDispatcher.registerEventHandler(dualshock4::KEY_LEFT, []() {
        std::cout << "\n";
    });

    eventDispatcher.registerEventHandler(dualshock4::KEY_RIGHT, []() {
        std::cout << "\n";
    });

    eventDispatcher.registerEventHandler(dualshock4::KEY_NORTH, []() {
        std::cout << "\n";
    });

    eventDispatcher.registerEventHandler(dualshock4::KEY_SOUTH, []() {
        std::cout << "\n";
    });

    eventDispatcher.registerEventHandler(dualshock4::KEY_EAST, []() {
        std::cout << "\n";
    });

    eventDispatcher.registerEventHandler(dualshock4::KEY_WEST, []() {
        std::cout << "\n";
    });

    eventDispatcher.start();
    eventDispatcher.wait();

    return 0;
}

Dependencies

  • hidapi - simple library for communicating with USB and Bluetooth HID devices.
    sudo apt install libhidapi-dev
  • eventpp - event dispatcher for C++.

References