91 lines
3.1 KiB
C++
91 lines
3.1 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();
|
|
void EmergencyShutdown();
|
|
|
|
struct Lifecycle {
|
|
static constexpr const char* name = "Controller";
|
|
static constexpr auto initialize = Libs::Controller::Initialize;
|
|
static constexpr auto shutdown = Libs::Controller::Shutdown;
|
|
static constexpr auto emergency_shutdown = Libs::Controller::EmergencyShutdown;
|
|
};
|
|
|
|
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 Connect(int id);
|
|
void Disconnect(int id);
|
|
void SetButton(int id, uint32_t button, bool down);
|
|
void SetAxis(int id, Axis axis, int value);
|
|
void SetRightStick(int id, int x, int y);
|
|
void SetTouchPad(int id, int finger, bool down, float x, float y);
|
|
void ResetInputState();
|
|
|
|
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_ */
|