summaryrefslogtreecommitdiffstats
path: root/src/common/input.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/common/input.h125
1 files changed, 89 insertions, 36 deletions
diff --git a/src/common/input.h b/src/common/input.h
index d27b1d772..ea30770ae 100644
--- a/src/common/input.h
+++ b/src/common/input.h
@@ -15,7 +15,7 @@
namespace Common::Input {
-// Type of data that is expected to recieve or send
+// Type of data that is expected to receive or send
enum class InputType {
None,
Battery,
@@ -46,11 +46,13 @@ enum class PollingMode {
// Constant polling of buttons, analogs and motion data
Active,
// Only update on button change, digital analogs
- Pasive,
+ Passive,
// Enable near field communication polling
NFC,
// Enable infrared camera polling
IR,
+ // Enable ring controller polling
+ Ring,
};
enum class CameraFormat {
@@ -62,41 +64,35 @@ enum class CameraFormat {
None,
};
-// Vibration reply from the controller
-enum class VibrationError {
- None,
+// Different results that can happen from a device request
+enum class DriverResult {
+ Success,
+ WrongReply,
+ Timeout,
+ UnsupportedControllerType,
+ HandleInUse,
+ ErrorReadingData,
+ ErrorWritingData,
+ NoDeviceDetected,
+ InvalidHandle,
NotSupported,
Disabled,
Unknown,
};
-// Polling mode reply from the controller
-enum class PollingError {
- None,
- NotSupported,
- Unknown,
-};
-
// Nfc reply from the controller
enum class NfcState {
Success,
NewAmiibo,
WaitingForAmiibo,
AmiiboRemoved,
- NotAnAmiibo,
+ InvalidTagType,
NotSupported,
WrongDeviceState,
WriteFailed,
Unknown,
};
-// Ir camera reply from the controller
-enum class CameraError {
- None,
- NotSupported,
- Unknown,
-};
-
// Hint for amplification curve to be used
enum class VibrationAmplificationType {
Linear,
@@ -107,7 +103,7 @@ enum class VibrationAmplificationType {
struct AnalogProperties {
// Anything below this value will be detected as zero
float deadzone{};
- // Anyting above this values will be detected as one
+ // Anything above this values will be detected as one
float range{1.0f};
// Minimum value to be detected as active
float threshold{0.5f};
@@ -115,6 +111,8 @@ struct AnalogProperties {
float offset{};
// Invert direction of the sensor data
bool inverted{};
+ // Invert the state if it's converted to a button
+ bool inverted_button{};
// Press once to activate, press again to release
bool toggle{};
};
@@ -134,6 +132,8 @@ struct ButtonStatus {
bool inverted{};
// Press once to activate, press again to release
bool toggle{};
+ // Spams the button when active
+ bool turbo{};
// Internal lock for the toggle status
bool locked{};
};
@@ -190,6 +190,8 @@ struct TouchStatus {
struct BodyColorStatus {
u32 body{};
u32 buttons{};
+ u32 left_grip{};
+ u32 right_grip{};
};
// HD rumble data
@@ -209,15 +211,29 @@ struct LedStatus {
bool led_4{};
};
-// Raw data fom camera
+// Raw data from camera
struct CameraStatus {
CameraFormat format{CameraFormat::None};
std::vector<u8> data{};
};
struct NfcStatus {
- NfcState state{};
- std::vector<u8> data{};
+ NfcState state{NfcState::Unknown};
+ u8 uuid_length;
+ u8 protocol;
+ u8 tag_type;
+ std::array<u8, 10> uuid;
+};
+
+struct MifareData {
+ u8 command;
+ u8 sector;
+ std::array<u8, 0x6> key;
+ std::array<u8, 0x10> data;
+};
+
+struct MifareRequest {
+ std::array<MifareData, 0x10> data;
};
// List of buttons to be passed to Qt that can be translated
@@ -228,17 +244,31 @@ enum class ButtonNames {
Engine,
// This will display the button by value instead of the button name
Value,
+
+ // Joycon button names
ButtonLeft,
ButtonRight,
ButtonDown,
ButtonUp,
- TriggerZ,
- TriggerR,
- TriggerL,
ButtonA,
ButtonB,
ButtonX,
ButtonY,
+ ButtonPlus,
+ ButtonMinus,
+ ButtonHome,
+ ButtonCapture,
+ ButtonStickL,
+ ButtonStickR,
+ TriggerL,
+ TriggerZL,
+ TriggerSL,
+ TriggerR,
+ TriggerZR,
+ TriggerSR,
+
+ // GC button names
+ TriggerZ,
ButtonStart,
// DS4 button names
@@ -278,7 +308,7 @@ struct CallbackStatus {
BatteryStatus battery_status{};
VibrationStatus vibration_status{};
CameraFormat camera_status{CameraFormat::None};
- NfcState nfc_status{NfcState::Unknown};
+ NfcStatus nfc_status{};
std::vector<u8> raw_data{};
};
@@ -316,31 +346,54 @@ class OutputDevice {
public:
virtual ~OutputDevice() = default;
- virtual void SetLED([[maybe_unused]] const LedStatus& led_status) {}
+ virtual DriverResult SetLED([[maybe_unused]] const LedStatus& led_status) {
+ return DriverResult::NotSupported;
+ }
- virtual VibrationError SetVibration([[maybe_unused]] const VibrationStatus& vibration_status) {
- return VibrationError::NotSupported;
+ virtual DriverResult SetVibration([[maybe_unused]] const VibrationStatus& vibration_status) {
+ return DriverResult::NotSupported;
}
virtual bool IsVibrationEnabled() {
return false;
}
- virtual PollingError SetPollingMode([[maybe_unused]] PollingMode polling_mode) {
- return PollingError::NotSupported;
+ virtual DriverResult SetPollingMode([[maybe_unused]] PollingMode polling_mode) {
+ return DriverResult::NotSupported;
}
- virtual CameraError SetCameraFormat([[maybe_unused]] CameraFormat camera_format) {
- return CameraError::NotSupported;
+ virtual DriverResult SetCameraFormat([[maybe_unused]] CameraFormat camera_format) {
+ return DriverResult::NotSupported;
}
virtual NfcState SupportsNfc() const {
return NfcState::NotSupported;
}
+ virtual NfcState StartNfcPolling() {
+ return NfcState::NotSupported;
+ }
+
+ virtual NfcState StopNfcPolling() {
+ return NfcState::NotSupported;
+ }
+
+ virtual NfcState ReadAmiiboData([[maybe_unused]] std::vector<u8>& out_data) {
+ return NfcState::NotSupported;
+ }
+
virtual NfcState WriteNfcData([[maybe_unused]] const std::vector<u8>& data) {
return NfcState::NotSupported;
}
+
+ virtual NfcState ReadMifareData([[maybe_unused]] const MifareRequest& request,
+ [[maybe_unused]] MifareRequest& out_data) {
+ return NfcState::NotSupported;
+ }
+
+ virtual NfcState WriteMifareData([[maybe_unused]] const MifareRequest& request) {
+ return NfcState::NotSupported;
+ }
};
/// An abstract class template for a factory that can create input devices.
@@ -412,7 +465,7 @@ inline void UnregisterOutputFactory(const std::string& name) {
}
/**
- * Create an input device from given paramters.
+ * Create an input device from given parameters.
* @tparam InputDeviceType the type of input devices to create
* @param params a serialized ParamPackage string that contains all parameters for creating the
* device