diff options
Diffstat (limited to 'src/input_common/helpers')
| -rw-r--r-- | src/input_common/helpers/joycon_driver.cpp | 26 | ||||
| -rw-r--r-- | src/input_common/helpers/joycon_driver.h | 10 | ||||
| -rw-r--r-- | src/input_common/helpers/joycon_protocol/joycon_types.h | 1 |
3 files changed, 19 insertions, 18 deletions
diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp index 8982a2397..b00b6110b 100644 --- a/src/input_common/helpers/joycon_driver.cpp +++ b/src/input_common/helpers/joycon_driver.cpp | |||
| @@ -459,23 +459,23 @@ SerialNumber JoyconDriver::GetHandleSerialNumber() const { | |||
| 459 | return handle_serial_number; | 459 | return handle_serial_number; |
| 460 | } | 460 | } |
| 461 | 461 | ||
| 462 | void JoyconDriver::SetCallbacks(const Joycon::JoyconCallbacks& callbacks) { | 462 | void JoyconDriver::SetCallbacks(const JoyconCallbacks& callbacks) { |
| 463 | joycon_poller->SetCallbacks(callbacks); | 463 | joycon_poller->SetCallbacks(callbacks); |
| 464 | } | 464 | } |
| 465 | 465 | ||
| 466 | Joycon::DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_info, | 466 | DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_info, |
| 467 | ControllerType& controller_type) { | 467 | ControllerType& controller_type) { |
| 468 | static constexpr std::array<std::pair<u32, Joycon::ControllerType>, 4> supported_devices{ | 468 | static constexpr std::array<std::pair<u32, ControllerType>, 4> supported_devices{ |
| 469 | std::pair<u32, Joycon::ControllerType>{0x2006, Joycon::ControllerType::Left}, | 469 | std::pair<u32, ControllerType>{0x2006, ControllerType::Left}, |
| 470 | {0x2007, Joycon::ControllerType::Right}, | 470 | {0x2007, ControllerType::Right}, |
| 471 | {0x2009, Joycon::ControllerType::Pro}, | 471 | {0x2009, ControllerType::Pro}, |
| 472 | {0x200E, Joycon::ControllerType::Grip}, | 472 | {0x200E, ControllerType::Grip}, |
| 473 | }; | 473 | }; |
| 474 | constexpr u16 nintendo_vendor_id = 0x057e; | 474 | constexpr u16 nintendo_vendor_id = 0x057e; |
| 475 | 475 | ||
| 476 | controller_type = Joycon::ControllerType::None; | 476 | controller_type = ControllerType::None; |
| 477 | if (device_info->vendor_id != nintendo_vendor_id) { | 477 | if (device_info->vendor_id != nintendo_vendor_id) { |
| 478 | return Joycon::DriverResult::UnsupportedControllerType; | 478 | return DriverResult::UnsupportedControllerType; |
| 479 | } | 479 | } |
| 480 | 480 | ||
| 481 | for (const auto& [product_id, type] : supported_devices) { | 481 | for (const auto& [product_id, type] : supported_devices) { |
| @@ -487,10 +487,10 @@ Joycon::DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_inf | |||
| 487 | return Joycon::DriverResult::UnsupportedControllerType; | 487 | return Joycon::DriverResult::UnsupportedControllerType; |
| 488 | } | 488 | } |
| 489 | 489 | ||
| 490 | Joycon::DriverResult JoyconDriver::GetSerialNumber(SDL_hid_device_info* device_info, | 490 | DriverResult JoyconDriver::GetSerialNumber(SDL_hid_device_info* device_info, |
| 491 | Joycon::SerialNumber& serial_number) { | 491 | SerialNumber& serial_number) { |
| 492 | if (device_info->serial_number == nullptr) { | 492 | if (device_info->serial_number == nullptr) { |
| 493 | return Joycon::DriverResult::Unknown; | 493 | return DriverResult::Unknown; |
| 494 | } | 494 | } |
| 495 | std::memcpy(&serial_number, device_info->serial_number, 15); | 495 | std::memcpy(&serial_number, device_info->serial_number, 15); |
| 496 | return Joycon::DriverResult::Success; | 496 | return Joycon::DriverResult::Success; |
diff --git a/src/input_common/helpers/joycon_driver.h b/src/input_common/helpers/joycon_driver.h index c9118ee93..bf38a3009 100644 --- a/src/input_common/helpers/joycon_driver.h +++ b/src/input_common/helpers/joycon_driver.h | |||
| @@ -46,15 +46,15 @@ public: | |||
| 46 | DriverResult SetNfcMode(); | 46 | DriverResult SetNfcMode(); |
| 47 | DriverResult SetRingConMode(); | 47 | DriverResult SetRingConMode(); |
| 48 | 48 | ||
| 49 | void SetCallbacks(const Joycon::JoyconCallbacks& callbacks); | 49 | void SetCallbacks(const JoyconCallbacks& callbacks); |
| 50 | 50 | ||
| 51 | // Returns device type from hidapi handle | 51 | // Returns device type from hidapi handle |
| 52 | static Joycon::DriverResult GetDeviceType(SDL_hid_device_info* device_info, | 52 | static DriverResult GetDeviceType(SDL_hid_device_info* device_info, |
| 53 | Joycon::ControllerType& controller_type); | 53 | ControllerType& controller_type); |
| 54 | 54 | ||
| 55 | // Returns serial number from hidapi handle | 55 | // Returns serial number from hidapi handle |
| 56 | static Joycon::DriverResult GetSerialNumber(SDL_hid_device_info* device_info, | 56 | static DriverResult GetSerialNumber(SDL_hid_device_info* device_info, |
| 57 | Joycon::SerialNumber& serial_number); | 57 | SerialNumber& serial_number); |
| 58 | 58 | ||
| 59 | private: | 59 | private: |
| 60 | struct SupportedFeatures { | 60 | struct SupportedFeatures { |
diff --git a/src/input_common/helpers/joycon_protocol/joycon_types.h b/src/input_common/helpers/joycon_protocol/joycon_types.h index de512fe63..36c00a8d7 100644 --- a/src/input_common/helpers/joycon_protocol/joycon_types.h +++ b/src/input_common/helpers/joycon_protocol/joycon_types.h | |||
| @@ -284,6 +284,7 @@ enum class DriverResult { | |||
| 284 | NoDeviceDetected, | 284 | NoDeviceDetected, |
| 285 | InvalidHandle, | 285 | InvalidHandle, |
| 286 | NotSupported, | 286 | NotSupported, |
| 287 | Disabled, | ||
| 287 | Unknown, | 288 | Unknown, |
| 288 | }; | 289 | }; |
| 289 | 290 | ||