|
|
@ -15,6 +15,7 @@ |
|
|
|
|
|
|
|
|
namespace Common::Input { |
|
|
namespace Common::Input { |
|
|
|
|
|
|
|
|
|
|
|
// Type of data that is expected to recieve or send |
|
|
enum class InputType { |
|
|
enum class InputType { |
|
|
None, |
|
|
None, |
|
|
Battery, |
|
|
Battery, |
|
|
@ -30,6 +31,7 @@ enum class InputType { |
|
|
Ir, |
|
|
Ir, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Internal battery charge level |
|
|
enum class BatteryLevel : u32 { |
|
|
enum class BatteryLevel : u32 { |
|
|
None, |
|
|
None, |
|
|
Empty, |
|
|
Empty, |
|
|
@ -41,13 +43,17 @@ enum class BatteryLevel : u32 { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
enum class PollingMode { |
|
|
enum class PollingMode { |
|
|
|
|
|
// Constant polling of buttons, analogs and motion data |
|
|
Active, |
|
|
Active, |
|
|
|
|
|
// Only update on button change, digital analogs |
|
|
Pasive, |
|
|
Pasive, |
|
|
Camera, |
|
|
|
|
|
NCF, |
|
|
|
|
|
|
|
|
// Enable near field communication polling |
|
|
|
|
|
NFC, |
|
|
|
|
|
// Enable infrared camera polling |
|
|
IR, |
|
|
IR, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Vibration reply from the controller |
|
|
enum class VibrationError { |
|
|
enum class VibrationError { |
|
|
None, |
|
|
None, |
|
|
NotSupported, |
|
|
NotSupported, |
|
|
@ -55,6 +61,7 @@ enum class VibrationError { |
|
|
Unknown, |
|
|
Unknown, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Polling mode reply from the controller |
|
|
enum class PollingError { |
|
|
enum class PollingError { |
|
|
None, |
|
|
None, |
|
|
NotSupported, |
|
|
NotSupported, |
|
|
@ -67,20 +74,28 @@ enum class VibrationAmplificationType { |
|
|
Exponential, |
|
|
Exponential, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Analog properties for calibration |
|
|
struct AnalogProperties { |
|
|
struct AnalogProperties { |
|
|
|
|
|
// Anything below this value will be detected as zero |
|
|
float deadzone{}; |
|
|
float deadzone{}; |
|
|
|
|
|
// Anyting above this values will be detected as one |
|
|
float range{1.0f}; |
|
|
float range{1.0f}; |
|
|
|
|
|
// Minimum value to be detected as active |
|
|
float threshold{0.5f}; |
|
|
float threshold{0.5f}; |
|
|
|
|
|
// Drift correction applied to the raw data |
|
|
float offset{}; |
|
|
float offset{}; |
|
|
|
|
|
// Invert direction of the sensor data |
|
|
bool inverted{}; |
|
|
bool inverted{}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Single analog sensor data |
|
|
struct AnalogStatus { |
|
|
struct AnalogStatus { |
|
|
float value{}; |
|
|
float value{}; |
|
|
float raw_value{}; |
|
|
float raw_value{}; |
|
|
AnalogProperties properties{}; |
|
|
AnalogProperties properties{}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Button data |
|
|
struct ButtonStatus { |
|
|
struct ButtonStatus { |
|
|
Common::UUID uuid{}; |
|
|
Common::UUID uuid{}; |
|
|
bool value{}; |
|
|
bool value{}; |
|
|
@ -89,8 +104,10 @@ struct ButtonStatus { |
|
|
bool locked{}; |
|
|
bool locked{}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Internal battery data |
|
|
using BatteryStatus = BatteryLevel; |
|
|
using BatteryStatus = BatteryLevel; |
|
|
|
|
|
|
|
|
|
|
|
// Analog and digital joystick data |
|
|
struct StickStatus { |
|
|
struct StickStatus { |
|
|
Common::UUID uuid{}; |
|
|
Common::UUID uuid{}; |
|
|
AnalogStatus x{}; |
|
|
AnalogStatus x{}; |
|
|
@ -101,18 +118,21 @@ struct StickStatus { |
|
|
bool down{}; |
|
|
bool down{}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Analog and digital trigger data |
|
|
struct TriggerStatus { |
|
|
struct TriggerStatus { |
|
|
Common::UUID uuid{}; |
|
|
Common::UUID uuid{}; |
|
|
AnalogStatus analog{}; |
|
|
AnalogStatus analog{}; |
|
|
ButtonStatus pressed{}; |
|
|
ButtonStatus pressed{}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 3D vector representing motion input |
|
|
struct MotionSensor { |
|
|
struct MotionSensor { |
|
|
AnalogStatus x{}; |
|
|
AnalogStatus x{}; |
|
|
AnalogStatus y{}; |
|
|
AnalogStatus y{}; |
|
|
AnalogStatus z{}; |
|
|
AnalogStatus z{}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Motion data used to calculate controller orientation |
|
|
struct MotionStatus { |
|
|
struct MotionStatus { |
|
|
// Gyroscope vector measurement in radians/s. |
|
|
// Gyroscope vector measurement in radians/s. |
|
|
MotionSensor gyro{}; |
|
|
MotionSensor gyro{}; |
|
|
@ -124,6 +144,7 @@ struct MotionStatus { |
|
|
bool force_update{}; |
|
|
bool force_update{}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Data of a single point on a touch screen |
|
|
struct TouchStatus { |
|
|
struct TouchStatus { |
|
|
ButtonStatus pressed{}; |
|
|
ButtonStatus pressed{}; |
|
|
AnalogStatus x{}; |
|
|
AnalogStatus x{}; |
|
|
@ -131,11 +152,13 @@ struct TouchStatus { |
|
|
int id{}; |
|
|
int id{}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Physical controller color in RGB format |
|
|
struct BodyColorStatus { |
|
|
struct BodyColorStatus { |
|
|
u32 body{}; |
|
|
u32 body{}; |
|
|
u32 buttons{}; |
|
|
u32 buttons{}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// HD rumble data |
|
|
struct VibrationStatus { |
|
|
struct VibrationStatus { |
|
|
f32 low_amplitude{}; |
|
|
f32 low_amplitude{}; |
|
|
f32 low_frequency{}; |
|
|
f32 low_frequency{}; |
|
|
@ -144,6 +167,7 @@ struct VibrationStatus { |
|
|
VibrationAmplificationType type; |
|
|
VibrationAmplificationType type; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Physical controller LED pattern |
|
|
struct LedStatus { |
|
|
struct LedStatus { |
|
|
bool led_1{}; |
|
|
bool led_1{}; |
|
|
bool led_2{}; |
|
|
bool led_2{}; |
|
|
@ -151,6 +175,7 @@ struct LedStatus { |
|
|
bool led_4{}; |
|
|
bool led_4{}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Callback data consisting of an input type and the equivalent data status |
|
|
struct CallbackStatus { |
|
|
struct CallbackStatus { |
|
|
InputType type{InputType::None}; |
|
|
InputType type{InputType::None}; |
|
|
ButtonStatus button_status{}; |
|
|
ButtonStatus button_status{}; |
|
|
@ -164,6 +189,7 @@ struct CallbackStatus { |
|
|
VibrationStatus vibration_status{}; |
|
|
VibrationStatus vibration_status{}; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Triggered once every input change |
|
|
struct InputCallback { |
|
|
struct InputCallback { |
|
|
std::function<void(CallbackStatus)> on_change; |
|
|
std::function<void(CallbackStatus)> on_change; |
|
|
}; |
|
|
}; |
|
|
@ -178,15 +204,17 @@ public: |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Force input device to update data regarless of the current state |
|
|
|
|
|
|
|
|
// Force input device to update data regardless of the current state |
|
|
virtual void ForceUpdate() { |
|
|
virtual void ForceUpdate() { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Sets the function to be triggered when input changes |
|
|
void SetCallback(InputCallback callback_) { |
|
|
void SetCallback(InputCallback callback_) { |
|
|
callback = std::move(callback_); |
|
|
callback = std::move(callback_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Triggers the function set in the callback |
|
|
void TriggerOnChange(CallbackStatus status) { |
|
|
void TriggerOnChange(CallbackStatus status) { |
|
|
if (callback.on_change) { |
|
|
if (callback.on_change) { |
|
|
callback.on_change(status); |
|
|
callback.on_change(status); |
|
|
|