21#include <source_location>
24#include "../extern/hidapi/hidapi/hidapi.h"
25#include "../include/export.h"
37 std::function<void(
const std::wstring &)> logFn;
38 hid_device *gamepad =
nullptr;
41 [[nodiscard]]
virtual int getVID()
const = 0;
42 [[nodiscard]]
virtual int getPID()
const = 0;
44 void writeLog(
const std::wstring &msg, std::source_location loc = std::source_location::current())
const;
45 [[nodiscard]]
bool setButtonKey(uint16_t *btn,
const std::string &key)
const;
46 [[nodiscard]]
bool setXinputKey(uint16_t *btn,
const std::string &key)
const;
47 void setBackButtonTime(uint16_t *field,
int time)
const;
48 void setAnalogDeadzone(int8_t *field,
int value)
const;
77 [[nodiscard]]
virtual bool setButton(
Button btn,
const std::string &key)
const = 0;
95 [[nodiscard]]
virtual bool setBackButton(
int num,
int slot,
const std::string &key)
const = 0;
105 [[nodiscard]]
virtual std::string
getBackButton(
int num,
int slot)
const = 0;
165 [[nodiscard]]
virtual std::tuple<int, int, int>
getLedColor()
const = 0;
199 void enableLogging(
const std::function<
void(
const std::wstring &)> &logCB) { logFn = logCB; }
206 [[nodiscard]]
bool init();
213 [[nodiscard]]
bool hasFeature(
int feature)
const;
LedMode
led mode
Definition LedMode.h:28
RumbleMode
vibration intensity
Definition RumbleMode.h:28
Controller abstract base class.
Definition Controller.h:35
virtual LedMode getLedMode() const =0
get current led mode
virtual void setAnalogBoundary(int boundary, bool left) const =0
set the analog stick boundary offset (circularity)
virtual std::string getButton(Button btn) const =0
get the current key of button btn
virtual bool readConfig()=0
read the whole configuration
virtual bool writeConfig() const =0
write the configuration
virtual std::string getBackButton(int num, int slot) const =0
get the current key in slot slot of back button num
virtual void setAnalogCenter(int center, bool left) const =0
set the analog stick offset from center (deadzone)
void enableLogging(const std::function< void(const std::wstring &)> &logCB)
Enable log messages.
Definition Controller.h:199
virtual void setBackButtonStartTime(int num, int slot, int timeMs) const =0
set start time for key in slot slot of back button num
virtual int getAnalogBoundary(bool left) const =0
get the current analog stick boundary offset (circularity)
virtual int getBackButtonStartTime(int num, int slot) const =0
get start time for key in slot slot of back button num
virtual bool setButton(Button btn, const std::string &key) const =0
set a new key for the button btn
virtual int getAnalogCenter(bool left) const =0
get the current analog stick offset from center (deadzone)
virtual bool setBackButton(int num, int slot, const std::string &key) const =0
set a new key in slot slot for back button num
virtual void setRumble(RumbleMode mode) const =0
set vibration intensity
virtual void setLedMode(LedMode mode) const =0
set led mode
virtual int getControllerType() const =0
int value of the controller class version
virtual RumbleMode getRumbleMode() const =0
get current vibration intesity
virtual void setLedColor(int r, int g, int b) const =0
set a custom color for the leds
virtual std::tuple< int, int, int > getLedColor() const =0
get current led custom color