mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 02:47:02 +02:00
04b404f3c9
* controller: enable the DualSense HIDAPI driver, light bar and adaptive triggers Three additions. SDL was opening a DualSense through the generic gamepad path, so SDL_GameControllerHasLED and SDL_GameControllerGetNumTouchpads both reported nothing and no touchpad events ever arrived - enabling the PS5 HIDAPI driver before SDL_InitSubSystem is what makes the light bar and the existing touchpad support reachable. PadSetLightBar validated its arguments and returned OK without touching the pad; it now drives the LED. PadSetTriggerEffect did the same; it now translates the mode and parameters into a DualSense trigger block and sends it. * controller: fix DualSense effects --------- Co-authored-by: nmzik <Nmzik@mail.ru>
89 lines
3.0 KiB
C++
89 lines
3.0 KiB
C++
#ifndef EMULATOR_INCLUDE_EMULATOR_CONTROLLER_H_
|
|
#define EMULATOR_INCLUDE_EMULATOR_CONTROLLER_H_
|
|
|
|
#include "common/abi.h"
|
|
#include "common/common.h"
|
|
namespace Libs::Controller {
|
|
|
|
void Initialize();
|
|
void Shutdown();
|
|
|
|
struct Lifecycle {
|
|
static constexpr const char* name = "Controller";
|
|
static constexpr auto initialize = Libs::Controller::Initialize;
|
|
static constexpr auto shutdown = Libs::Controller::Shutdown;
|
|
};
|
|
|
|
constexpr int HOST_INPUT_CONTROLLER_ID = -1000;
|
|
|
|
constexpr uint32_t PAD_BUTTON_L3 = 0x00000002;
|
|
constexpr uint32_t PAD_BUTTON_R3 = 0x00000004;
|
|
constexpr uint32_t PAD_BUTTON_OPTIONS = 0x00000008;
|
|
constexpr uint32_t PAD_BUTTON_UP = 0x00000010;
|
|
constexpr uint32_t PAD_BUTTON_RIGHT = 0x00000020;
|
|
constexpr uint32_t PAD_BUTTON_DOWN = 0x00000040;
|
|
constexpr uint32_t PAD_BUTTON_LEFT = 0x00000080;
|
|
constexpr uint32_t PAD_BUTTON_L2 = 0x00000100;
|
|
constexpr uint32_t PAD_BUTTON_R2 = 0x00000200;
|
|
constexpr uint32_t PAD_BUTTON_L1 = 0x00000400;
|
|
constexpr uint32_t PAD_BUTTON_R1 = 0x00000800;
|
|
constexpr uint32_t PAD_BUTTON_TRIANGLE = 0x00001000;
|
|
constexpr uint32_t PAD_BUTTON_CIRCLE = 0x00002000;
|
|
constexpr uint32_t PAD_BUTTON_CROSS = 0x00004000;
|
|
constexpr uint32_t PAD_BUTTON_SQUARE = 0x00008000;
|
|
constexpr uint32_t PAD_BUTTON_TOUCH_PAD = 0x00100000;
|
|
|
|
enum class Axis {
|
|
LeftX = 0,
|
|
LeftY = 1,
|
|
RightX = 2,
|
|
RightY = 3,
|
|
TriggerLeft = 4,
|
|
TriggerRight = 5,
|
|
|
|
AxisMax
|
|
};
|
|
|
|
struct PadControllerInformation;
|
|
struct PadData;
|
|
struct PadVibrationParam;
|
|
struct PadLightBarParam;
|
|
struct PadTriggerEffectParam;
|
|
|
|
inline int controller_get_axis(int min, int max, int value) {
|
|
int v = (255 * (value - min)) / (max - min);
|
|
if (v < 0) {
|
|
return 0;
|
|
}
|
|
if (v > 255) {
|
|
return 255;
|
|
}
|
|
return v;
|
|
}
|
|
|
|
void ControllerConnect(int id);
|
|
void ControllerDisconnect(int id);
|
|
void ControllerButton(int id, uint32_t button, bool down);
|
|
void ControllerAxis(int id, Axis axis, int value);
|
|
void ControllerRightStick(int id, int x, int y);
|
|
void ControllerTouchPad(int id, int finger, bool down, float x, float y);
|
|
void ControllerResetInputState();
|
|
|
|
int KYTY_SYSV_ABI PadInit();
|
|
int KYTY_SYSV_ABI PadOpen(int user_id, int type, int index, const void* param);
|
|
int KYTY_SYSV_ABI PadGetHandle(int user_id, int type, int index);
|
|
int KYTY_SYSV_ABI PadSetMotionSensorState(int handle, bool enable);
|
|
int KYTY_SYSV_ABI PadSetAngularVelocityDeadbandState(int handle, bool enable);
|
|
int KYTY_SYSV_ABI PadResetOrientation(int handle);
|
|
int KYTY_SYSV_ABI PadGetControllerInformation(int handle, PadControllerInformation* info);
|
|
int KYTY_SYSV_ABI PadReadState(int handle, PadData* data);
|
|
int KYTY_SYSV_ABI PadRead(int handle, PadData* data, int num);
|
|
int KYTY_SYSV_ABI PadSetVibration(int handle, const PadVibrationParam* param);
|
|
int KYTY_SYSV_ABI PadSetTriggerEffect(int handle, const PadTriggerEffectParam* param);
|
|
int KYTY_SYSV_ABI PadResetLightBar(int handle);
|
|
int KYTY_SYSV_ABI PadSetLightBar(int handle, const PadLightBarParam* param);
|
|
|
|
} // namespace Libs::Controller
|
|
|
|
#endif /* EMULATOR_INCLUDE_EMULATOR_CONTROLLER_H_ */
|