mirror of
https://github.com/starr-dusT/yuzu-mainline
synced 2024-03-05 21:12:25 -08:00
input_common: Use DriverResult on all engines
This commit is contained in:
parent
e1a3bda4d9
commit
527dad7097
@ -64,20 +64,19 @@ enum class CameraFormat {
|
|||||||
None,
|
None,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Vibration reply from the controller
|
// Different results that can happen from a device request
|
||||||
enum class VibrationError {
|
enum class DriverResult {
|
||||||
None,
|
Success,
|
||||||
|
WrongReply,
|
||||||
|
Timeout,
|
||||||
|
UnsupportedControllerType,
|
||||||
|
HandleInUse,
|
||||||
|
ErrorReadingData,
|
||||||
|
ErrorWritingData,
|
||||||
|
NoDeviceDetected,
|
||||||
|
InvalidHandle,
|
||||||
NotSupported,
|
NotSupported,
|
||||||
Disabled,
|
Disabled,
|
||||||
InvalidHandle,
|
|
||||||
Unknown,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Polling mode reply from the controller
|
|
||||||
enum class PollingError {
|
|
||||||
None,
|
|
||||||
NotSupported,
|
|
||||||
InvalidHandle,
|
|
||||||
Unknown,
|
Unknown,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -94,13 +93,6 @@ enum class NfcState {
|
|||||||
Unknown,
|
Unknown,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Ir camera reply from the controller
|
|
||||||
enum class CameraError {
|
|
||||||
None,
|
|
||||||
NotSupported,
|
|
||||||
Unknown,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Hint for amplification curve to be used
|
// Hint for amplification curve to be used
|
||||||
enum class VibrationAmplificationType {
|
enum class VibrationAmplificationType {
|
||||||
Linear,
|
Linear,
|
||||||
@ -336,22 +328,24 @@ class OutputDevice {
|
|||||||
public:
|
public:
|
||||||
virtual ~OutputDevice() = default;
|
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) {
|
virtual DriverResult SetVibration([[maybe_unused]] const VibrationStatus& vibration_status) {
|
||||||
return VibrationError::NotSupported;
|
return DriverResult::NotSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool IsVibrationEnabled() {
|
virtual bool IsVibrationEnabled() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual PollingError SetPollingMode([[maybe_unused]] PollingMode polling_mode) {
|
virtual DriverResult SetPollingMode([[maybe_unused]] PollingMode polling_mode) {
|
||||||
return PollingError::NotSupported;
|
return DriverResult::NotSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual CameraError SetCameraFormat([[maybe_unused]] CameraFormat camera_format) {
|
virtual DriverResult SetCameraFormat([[maybe_unused]] CameraFormat camera_format) {
|
||||||
return CameraError::NotSupported;
|
return DriverResult::NotSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual NfcState SupportsNfc() const {
|
virtual NfcState SupportsNfc() const {
|
||||||
|
@ -1178,7 +1178,7 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v
|
|||||||
.type = type,
|
.type = type,
|
||||||
};
|
};
|
||||||
return output_devices[device_index]->SetVibration(status) ==
|
return output_devices[device_index]->SetVibration(status) ==
|
||||||
Common::Input::VibrationError::None;
|
Common::Input::DriverResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EmulatedController::IsVibrationEnabled(std::size_t device_index) {
|
bool EmulatedController::IsVibrationEnabled(std::size_t device_index) {
|
||||||
@ -1208,8 +1208,8 @@ bool EmulatedController::SetPollingMode(Common::Input::PollingMode polling_mode)
|
|||||||
const auto virtual_nfc_result = nfc_output_device->SetPollingMode(polling_mode);
|
const auto virtual_nfc_result = nfc_output_device->SetPollingMode(polling_mode);
|
||||||
const auto mapped_nfc_result = output_device->SetPollingMode(polling_mode);
|
const auto mapped_nfc_result = output_device->SetPollingMode(polling_mode);
|
||||||
|
|
||||||
return virtual_nfc_result == Common::Input::PollingError::None ||
|
return virtual_nfc_result == Common::Input::DriverResult::Success ||
|
||||||
mapped_nfc_result == Common::Input::PollingError::None;
|
mapped_nfc_result == Common::Input::DriverResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EmulatedController::SetCameraFormat(
|
bool EmulatedController::SetCameraFormat(
|
||||||
@ -1220,13 +1220,13 @@ bool EmulatedController::SetCameraFormat(
|
|||||||
auto& camera_output_device = output_devices[2];
|
auto& camera_output_device = output_devices[2];
|
||||||
|
|
||||||
if (right_output_device->SetCameraFormat(static_cast<Common::Input::CameraFormat>(
|
if (right_output_device->SetCameraFormat(static_cast<Common::Input::CameraFormat>(
|
||||||
camera_format)) == Common::Input::CameraError::None) {
|
camera_format)) == Common::Input::DriverResult::Success) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to Qt camera if native device doesn't have support
|
// Fallback to Qt camera if native device doesn't have support
|
||||||
return camera_output_device->SetCameraFormat(static_cast<Common::Input::CameraFormat>(
|
return camera_output_device->SetCameraFormat(static_cast<Common::Input::CameraFormat>(
|
||||||
camera_format)) == Common::Input::CameraError::None;
|
camera_format)) == Common::Input::DriverResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::ParamPackage EmulatedController::GetRingParam() const {
|
Common::ParamPackage EmulatedController::GetRingParam() const {
|
||||||
|
@ -72,11 +72,11 @@ std::size_t Camera::getImageHeight() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Input::CameraError Camera::SetCameraFormat(
|
Common::Input::DriverResult Camera::SetCameraFormat(
|
||||||
[[maybe_unused]] const PadIdentifier& identifier_,
|
[[maybe_unused]] const PadIdentifier& identifier_,
|
||||||
const Common::Input::CameraFormat camera_format) {
|
const Common::Input::CameraFormat camera_format) {
|
||||||
status.format = camera_format;
|
status.format = camera_format;
|
||||||
return Common::Input::CameraError::None;
|
return Common::Input::DriverResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace InputCommon
|
} // namespace InputCommon
|
||||||
|
@ -22,7 +22,7 @@ public:
|
|||||||
std::size_t getImageWidth() const;
|
std::size_t getImageWidth() const;
|
||||||
std::size_t getImageHeight() const;
|
std::size_t getImageHeight() const;
|
||||||
|
|
||||||
Common::Input::CameraError SetCameraFormat(const PadIdentifier& identifier_,
|
Common::Input::DriverResult SetCameraFormat(const PadIdentifier& identifier_,
|
||||||
Common::Input::CameraFormat camera_format) override;
|
Common::Input::CameraFormat camera_format) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -324,7 +324,7 @@ bool GCAdapter::GetGCEndpoint(libusb_device* device) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Input::VibrationError GCAdapter::SetVibration(
|
Common::Input::DriverResult GCAdapter::SetVibration(
|
||||||
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) {
|
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) {
|
||||||
const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f;
|
const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f;
|
||||||
const auto processed_amplitude =
|
const auto processed_amplitude =
|
||||||
@ -333,9 +333,9 @@ Common::Input::VibrationError GCAdapter::SetVibration(
|
|||||||
pads[identifier.port].rumble_amplitude = processed_amplitude;
|
pads[identifier.port].rumble_amplitude = processed_amplitude;
|
||||||
|
|
||||||
if (!rumble_enabled) {
|
if (!rumble_enabled) {
|
||||||
return Common::Input::VibrationError::Disabled;
|
return Common::Input::DriverResult::Disabled;
|
||||||
}
|
}
|
||||||
return Common::Input::VibrationError::None;
|
return Common::Input::DriverResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GCAdapter::IsVibrationEnabled([[maybe_unused]] const PadIdentifier& identifier) {
|
bool GCAdapter::IsVibrationEnabled([[maybe_unused]] const PadIdentifier& identifier) {
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
explicit GCAdapter(std::string input_engine_);
|
explicit GCAdapter(std::string input_engine_);
|
||||||
~GCAdapter() override;
|
~GCAdapter() override;
|
||||||
|
|
||||||
Common::Input::VibrationError SetVibration(
|
Common::Input::DriverResult SetVibration(
|
||||||
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override;
|
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override;
|
||||||
|
|
||||||
bool IsVibrationEnabled(const PadIdentifier& identifier) override;
|
bool IsVibrationEnabled(const PadIdentifier& identifier) override;
|
||||||
|
@ -233,8 +233,8 @@ bool Joycons::IsVibrationEnabled(const PadIdentifier& identifier) {
|
|||||||
return handle->IsVibrationEnabled();
|
return handle->IsVibrationEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Input::VibrationError Joycons::SetVibration(
|
Common::Input::DriverResult Joycons::SetVibration(const PadIdentifier& identifier,
|
||||||
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) {
|
const Common::Input::VibrationStatus& vibration) {
|
||||||
const Joycon::VibrationValue native_vibration{
|
const Joycon::VibrationValue native_vibration{
|
||||||
.low_amplitude = vibration.low_amplitude,
|
.low_amplitude = vibration.low_amplitude,
|
||||||
.low_frequency = vibration.low_frequency,
|
.low_frequency = vibration.low_frequency,
|
||||||
@ -243,32 +243,31 @@ Common::Input::VibrationError Joycons::SetVibration(
|
|||||||
};
|
};
|
||||||
auto handle = GetHandle(identifier);
|
auto handle = GetHandle(identifier);
|
||||||
if (handle == nullptr) {
|
if (handle == nullptr) {
|
||||||
return Common::Input::VibrationError::InvalidHandle;
|
return Common::Input::DriverResult::InvalidHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle->SetVibration(native_vibration);
|
handle->SetVibration(native_vibration);
|
||||||
return Common::Input::VibrationError::None;
|
return Common::Input::DriverResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Joycons::SetLeds(const PadIdentifier& identifier, const Common::Input::LedStatus& led_status) {
|
Common::Input::DriverResult Joycons::SetLeds(const PadIdentifier& identifier,
|
||||||
|
const Common::Input::LedStatus& led_status) {
|
||||||
auto handle = GetHandle(identifier);
|
auto handle = GetHandle(identifier);
|
||||||
if (handle == nullptr) {
|
if (handle == nullptr) {
|
||||||
return;
|
return Common::Input::DriverResult::InvalidHandle;
|
||||||
}
|
}
|
||||||
int led_config = led_status.led_1 ? 1 : 0;
|
int led_config = led_status.led_1 ? 1 : 0;
|
||||||
led_config += led_status.led_2 ? 2 : 0;
|
led_config += led_status.led_2 ? 2 : 0;
|
||||||
led_config += led_status.led_3 ? 4 : 0;
|
led_config += led_status.led_3 ? 4 : 0;
|
||||||
led_config += led_status.led_4 ? 8 : 0;
|
led_config += led_status.led_4 ? 8 : 0;
|
||||||
|
|
||||||
const auto result = handle->SetLedConfig(static_cast<u8>(led_config));
|
return static_cast<Common::Input::DriverResult>(
|
||||||
if (result != Joycon::DriverResult::Success) {
|
handle->SetLedConfig(static_cast<u8>(led_config)));
|
||||||
LOG_ERROR(Input, "Failed to set led config");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Input::CameraError Joycons::SetCameraFormat(const PadIdentifier& identifier_,
|
Common::Input::DriverResult Joycons::SetCameraFormat(const PadIdentifier& identifier_,
|
||||||
Common::Input::CameraFormat camera_format) {
|
Common::Input::CameraFormat camera_format) {
|
||||||
return Common::Input::CameraError::NotSupported;
|
return Common::Input::DriverResult::NotSupported;
|
||||||
};
|
};
|
||||||
|
|
||||||
Common::Input::NfcState Joycons::SupportsNfc(const PadIdentifier& identifier_) const {
|
Common::Input::NfcState Joycons::SupportsNfc(const PadIdentifier& identifier_) const {
|
||||||
@ -280,32 +279,30 @@ Common::Input::NfcState Joycons::WriteNfcData(const PadIdentifier& identifier_,
|
|||||||
return Common::Input::NfcState::NotSupported;
|
return Common::Input::NfcState::NotSupported;
|
||||||
};
|
};
|
||||||
|
|
||||||
Common::Input::PollingError Joycons::SetPollingMode(const PadIdentifier& identifier,
|
Common::Input::DriverResult Joycons::SetPollingMode(const PadIdentifier& identifier,
|
||||||
const Common::Input::PollingMode polling_mode) {
|
const Common::Input::PollingMode polling_mode) {
|
||||||
auto handle = GetHandle(identifier);
|
auto handle = GetHandle(identifier);
|
||||||
if (handle == nullptr) {
|
if (handle == nullptr) {
|
||||||
LOG_ERROR(Input, "Invalid handle {}", identifier.port);
|
LOG_ERROR(Input, "Invalid handle {}", identifier.port);
|
||||||
return Common::Input::PollingError::InvalidHandle;
|
return Common::Input::DriverResult::InvalidHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (polling_mode) {
|
switch (polling_mode) {
|
||||||
case Common::Input::PollingMode::NFC:
|
case Common::Input::PollingMode::NFC:
|
||||||
handle->SetNfcMode();
|
return static_cast<Common::Input::DriverResult>(handle->SetNfcMode());
|
||||||
break;
|
break;
|
||||||
case Common::Input::PollingMode::Active:
|
case Common::Input::PollingMode::Active:
|
||||||
handle->SetActiveMode();
|
return static_cast<Common::Input::DriverResult>(handle->SetActiveMode());
|
||||||
break;
|
break;
|
||||||
case Common::Input::PollingMode::Pasive:
|
case Common::Input::PollingMode::Pasive:
|
||||||
handle->SetPasiveMode();
|
return static_cast<Common::Input::DriverResult>(handle->SetPasiveMode());
|
||||||
break;
|
break;
|
||||||
case Common::Input::PollingMode::Ring:
|
case Common::Input::PollingMode::Ring:
|
||||||
handle->SetRingConMode();
|
return static_cast<Common::Input::DriverResult>(handle->SetRingConMode());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return Common::Input::PollingError::NotSupported;
|
return Common::Input::DriverResult::NotSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Common::Input::PollingError::None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Joycons::OnBatteryUpdate(std::size_t port, Joycon::ControllerType type,
|
void Joycons::OnBatteryUpdate(std::size_t port, Joycon::ControllerType type,
|
||||||
|
@ -29,20 +29,20 @@ public:
|
|||||||
~Joycons();
|
~Joycons();
|
||||||
|
|
||||||
bool IsVibrationEnabled(const PadIdentifier& identifier) override;
|
bool IsVibrationEnabled(const PadIdentifier& identifier) override;
|
||||||
Common::Input::VibrationError SetVibration(
|
Common::Input::DriverResult SetVibration(
|
||||||
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override;
|
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override;
|
||||||
|
|
||||||
void SetLeds(const PadIdentifier& identifier,
|
Common::Input::DriverResult SetLeds(const PadIdentifier& identifier,
|
||||||
const Common::Input::LedStatus& led_status) override;
|
const Common::Input::LedStatus& led_status) override;
|
||||||
|
|
||||||
Common::Input::CameraError SetCameraFormat(const PadIdentifier& identifier_,
|
Common::Input::DriverResult SetCameraFormat(const PadIdentifier& identifier_,
|
||||||
Common::Input::CameraFormat camera_format) override;
|
Common::Input::CameraFormat camera_format) override;
|
||||||
|
|
||||||
Common::Input::NfcState SupportsNfc(const PadIdentifier& identifier_) const override;
|
Common::Input::NfcState SupportsNfc(const PadIdentifier& identifier_) const override;
|
||||||
Common::Input::NfcState WriteNfcData(const PadIdentifier& identifier_,
|
Common::Input::NfcState WriteNfcData(const PadIdentifier& identifier_,
|
||||||
const std::vector<u8>& data) override;
|
const std::vector<u8>& data) override;
|
||||||
|
|
||||||
Common::Input::PollingError SetPollingMode(
|
Common::Input::DriverResult SetPollingMode(
|
||||||
const PadIdentifier& identifier, const Common::Input::PollingMode polling_mode) override;
|
const PadIdentifier& identifier, const Common::Input::PollingMode polling_mode) override;
|
||||||
|
|
||||||
/// Used for automapping features
|
/// Used for automapping features
|
||||||
|
@ -545,7 +545,7 @@ std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const {
|
|||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Input::VibrationError SDLDriver::SetVibration(
|
Common::Input::DriverResult SDLDriver::SetVibration(
|
||||||
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) {
|
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) {
|
||||||
const auto joystick =
|
const auto joystick =
|
||||||
GetSDLJoystickByGUID(identifier.guid.RawString(), static_cast<int>(identifier.port));
|
GetSDLJoystickByGUID(identifier.guid.RawString(), static_cast<int>(identifier.port));
|
||||||
@ -579,7 +579,7 @@ Common::Input::VibrationError SDLDriver::SetVibration(
|
|||||||
.vibration = new_vibration,
|
.vibration = new_vibration,
|
||||||
});
|
});
|
||||||
|
|
||||||
return Common::Input::VibrationError::None;
|
return Common::Input::DriverResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDLDriver::IsVibrationEnabled(const PadIdentifier& identifier) {
|
bool SDLDriver::IsVibrationEnabled(const PadIdentifier& identifier) {
|
||||||
|
@ -63,7 +63,7 @@ public:
|
|||||||
|
|
||||||
bool IsStickInverted(const Common::ParamPackage& params) override;
|
bool IsStickInverted(const Common::ParamPackage& params) override;
|
||||||
|
|
||||||
Common::Input::VibrationError SetVibration(
|
Common::Input::DriverResult SetVibration(
|
||||||
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override;
|
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) override;
|
||||||
|
|
||||||
bool IsVibrationEnabled(const PadIdentifier& identifier) override;
|
bool IsVibrationEnabled(const PadIdentifier& identifier) override;
|
||||||
|
@ -22,7 +22,7 @@ VirtualAmiibo::VirtualAmiibo(std::string input_engine_) : InputEngine(std::move(
|
|||||||
|
|
||||||
VirtualAmiibo::~VirtualAmiibo() = default;
|
VirtualAmiibo::~VirtualAmiibo() = default;
|
||||||
|
|
||||||
Common::Input::PollingError VirtualAmiibo::SetPollingMode(
|
Common::Input::DriverResult VirtualAmiibo::SetPollingMode(
|
||||||
[[maybe_unused]] const PadIdentifier& identifier_,
|
[[maybe_unused]] const PadIdentifier& identifier_,
|
||||||
const Common::Input::PollingMode polling_mode_) {
|
const Common::Input::PollingMode polling_mode_) {
|
||||||
polling_mode = polling_mode_;
|
polling_mode = polling_mode_;
|
||||||
@ -37,7 +37,7 @@ Common::Input::PollingError VirtualAmiibo::SetPollingMode(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Common::Input::PollingError::None;
|
return Common::Input::DriverResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Input::NfcState VirtualAmiibo::SupportsNfc(
|
Common::Input::NfcState VirtualAmiibo::SupportsNfc(
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
~VirtualAmiibo() override;
|
~VirtualAmiibo() override;
|
||||||
|
|
||||||
// Sets polling mode to a controller
|
// Sets polling mode to a controller
|
||||||
Common::Input::PollingError SetPollingMode(
|
Common::Input::DriverResult SetPollingMode(
|
||||||
const PadIdentifier& identifier_, const Common::Input::PollingMode polling_mode_) override;
|
const PadIdentifier& identifier_, const Common::Input::PollingMode polling_mode_) override;
|
||||||
|
|
||||||
Common::Input::NfcState SupportsNfc(const PadIdentifier& identifier_) const override;
|
Common::Input::NfcState SupportsNfc(const PadIdentifier& identifier_) const override;
|
||||||
|
@ -459,23 +459,23 @@ SerialNumber JoyconDriver::GetHandleSerialNumber() const {
|
|||||||
return handle_serial_number;
|
return handle_serial_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JoyconDriver::SetCallbacks(const Joycon::JoyconCallbacks& callbacks) {
|
void JoyconDriver::SetCallbacks(const JoyconCallbacks& callbacks) {
|
||||||
joycon_poller->SetCallbacks(callbacks);
|
joycon_poller->SetCallbacks(callbacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
Joycon::DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_info,
|
DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_info,
|
||||||
ControllerType& controller_type) {
|
ControllerType& controller_type) {
|
||||||
static constexpr std::array<std::pair<u32, Joycon::ControllerType>, 4> supported_devices{
|
static constexpr std::array<std::pair<u32, ControllerType>, 4> supported_devices{
|
||||||
std::pair<u32, Joycon::ControllerType>{0x2006, Joycon::ControllerType::Left},
|
std::pair<u32, ControllerType>{0x2006, ControllerType::Left},
|
||||||
{0x2007, Joycon::ControllerType::Right},
|
{0x2007, ControllerType::Right},
|
||||||
{0x2009, Joycon::ControllerType::Pro},
|
{0x2009, ControllerType::Pro},
|
||||||
{0x200E, Joycon::ControllerType::Grip},
|
{0x200E, ControllerType::Grip},
|
||||||
};
|
};
|
||||||
constexpr u16 nintendo_vendor_id = 0x057e;
|
constexpr u16 nintendo_vendor_id = 0x057e;
|
||||||
|
|
||||||
controller_type = Joycon::ControllerType::None;
|
controller_type = ControllerType::None;
|
||||||
if (device_info->vendor_id != nintendo_vendor_id) {
|
if (device_info->vendor_id != nintendo_vendor_id) {
|
||||||
return Joycon::DriverResult::UnsupportedControllerType;
|
return DriverResult::UnsupportedControllerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& [product_id, type] : supported_devices) {
|
for (const auto& [product_id, type] : supported_devices) {
|
||||||
@ -487,10 +487,10 @@ Joycon::DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_inf
|
|||||||
return Joycon::DriverResult::UnsupportedControllerType;
|
return Joycon::DriverResult::UnsupportedControllerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
Joycon::DriverResult JoyconDriver::GetSerialNumber(SDL_hid_device_info* device_info,
|
DriverResult JoyconDriver::GetSerialNumber(SDL_hid_device_info* device_info,
|
||||||
Joycon::SerialNumber& serial_number) {
|
SerialNumber& serial_number) {
|
||||||
if (device_info->serial_number == nullptr) {
|
if (device_info->serial_number == nullptr) {
|
||||||
return Joycon::DriverResult::Unknown;
|
return DriverResult::Unknown;
|
||||||
}
|
}
|
||||||
std::memcpy(&serial_number, device_info->serial_number, 15);
|
std::memcpy(&serial_number, device_info->serial_number, 15);
|
||||||
return Joycon::DriverResult::Success;
|
return Joycon::DriverResult::Success;
|
||||||
|
@ -46,15 +46,15 @@ public:
|
|||||||
DriverResult SetNfcMode();
|
DriverResult SetNfcMode();
|
||||||
DriverResult SetRingConMode();
|
DriverResult SetRingConMode();
|
||||||
|
|
||||||
void SetCallbacks(const Joycon::JoyconCallbacks& callbacks);
|
void SetCallbacks(const JoyconCallbacks& callbacks);
|
||||||
|
|
||||||
// Returns device type from hidapi handle
|
// Returns device type from hidapi handle
|
||||||
static Joycon::DriverResult GetDeviceType(SDL_hid_device_info* device_info,
|
static DriverResult GetDeviceType(SDL_hid_device_info* device_info,
|
||||||
Joycon::ControllerType& controller_type);
|
ControllerType& controller_type);
|
||||||
|
|
||||||
// Returns serial number from hidapi handle
|
// Returns serial number from hidapi handle
|
||||||
static Joycon::DriverResult GetSerialNumber(SDL_hid_device_info* device_info,
|
static DriverResult GetSerialNumber(SDL_hid_device_info* device_info,
|
||||||
Joycon::SerialNumber& serial_number);
|
SerialNumber& serial_number);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct SupportedFeatures {
|
struct SupportedFeatures {
|
||||||
|
@ -284,6 +284,7 @@ enum class DriverResult {
|
|||||||
NoDeviceDetected,
|
NoDeviceDetected,
|
||||||
InvalidHandle,
|
InvalidHandle,
|
||||||
NotSupported,
|
NotSupported,
|
||||||
|
Disabled,
|
||||||
Unknown,
|
Unknown,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -105,14 +105,17 @@ public:
|
|||||||
void EndConfiguration();
|
void EndConfiguration();
|
||||||
|
|
||||||
// Sets a led pattern for a controller
|
// Sets a led pattern for a controller
|
||||||
virtual void SetLeds([[maybe_unused]] const PadIdentifier& identifier,
|
virtual Common::Input::DriverResult SetLeds(
|
||||||
[[maybe_unused]] const Common::Input::LedStatus& led_status) {}
|
[[maybe_unused]] const PadIdentifier& identifier,
|
||||||
|
[[maybe_unused]] const Common::Input::LedStatus& led_status) {
|
||||||
|
return Common::Input::DriverResult::NotSupported;
|
||||||
|
}
|
||||||
|
|
||||||
// Sets rumble to a controller
|
// Sets rumble to a controller
|
||||||
virtual Common::Input::VibrationError SetVibration(
|
virtual Common::Input::DriverResult SetVibration(
|
||||||
[[maybe_unused]] const PadIdentifier& identifier,
|
[[maybe_unused]] const PadIdentifier& identifier,
|
||||||
[[maybe_unused]] const Common::Input::VibrationStatus& vibration) {
|
[[maybe_unused]] const Common::Input::VibrationStatus& vibration) {
|
||||||
return Common::Input::VibrationError::NotSupported;
|
return Common::Input::DriverResult::NotSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if device supports vibrations
|
// Returns true if device supports vibrations
|
||||||
@ -121,17 +124,17 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sets polling mode to a controller
|
// Sets polling mode to a controller
|
||||||
virtual Common::Input::PollingError SetPollingMode(
|
virtual Common::Input::DriverResult SetPollingMode(
|
||||||
[[maybe_unused]] const PadIdentifier& identifier,
|
[[maybe_unused]] const PadIdentifier& identifier,
|
||||||
[[maybe_unused]] const Common::Input::PollingMode polling_mode) {
|
[[maybe_unused]] const Common::Input::PollingMode polling_mode) {
|
||||||
return Common::Input::PollingError::NotSupported;
|
return Common::Input::DriverResult::NotSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets camera format to a controller
|
// Sets camera format to a controller
|
||||||
virtual Common::Input::CameraError SetCameraFormat(
|
virtual Common::Input::DriverResult SetCameraFormat(
|
||||||
[[maybe_unused]] const PadIdentifier& identifier,
|
[[maybe_unused]] const PadIdentifier& identifier,
|
||||||
[[maybe_unused]] Common::Input::CameraFormat camera_format) {
|
[[maybe_unused]] Common::Input::CameraFormat camera_format) {
|
||||||
return Common::Input::CameraError::NotSupported;
|
return Common::Input::DriverResult::NotSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns success if nfc is supported
|
// Returns success if nfc is supported
|
||||||
|
@ -806,11 +806,11 @@ public:
|
|||||||
explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_)
|
explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_)
|
||||||
: identifier(identifier_), input_engine(input_engine_) {}
|
: identifier(identifier_), input_engine(input_engine_) {}
|
||||||
|
|
||||||
void SetLED(const Common::Input::LedStatus& led_status) override {
|
Common::Input::DriverResult SetLED(const Common::Input::LedStatus& led_status) override {
|
||||||
input_engine->SetLeds(identifier, led_status);
|
return input_engine->SetLeds(identifier, led_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Input::VibrationError SetVibration(
|
Common::Input::DriverResult SetVibration(
|
||||||
const Common::Input::VibrationStatus& vibration_status) override {
|
const Common::Input::VibrationStatus& vibration_status) override {
|
||||||
return input_engine->SetVibration(identifier, vibration_status);
|
return input_engine->SetVibration(identifier, vibration_status);
|
||||||
}
|
}
|
||||||
@ -819,11 +819,12 @@ public:
|
|||||||
return input_engine->IsVibrationEnabled(identifier);
|
return input_engine->IsVibrationEnabled(identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Input::PollingError SetPollingMode(Common::Input::PollingMode polling_mode) override {
|
Common::Input::DriverResult SetPollingMode(Common::Input::PollingMode polling_mode) override {
|
||||||
return input_engine->SetPollingMode(identifier, polling_mode);
|
return input_engine->SetPollingMode(identifier, polling_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Input::CameraError SetCameraFormat(Common::Input::CameraFormat camera_format) override {
|
Common::Input::DriverResult SetCameraFormat(
|
||||||
|
Common::Input::CameraFormat camera_format) override {
|
||||||
return input_engine->SetCameraFormat(identifier, camera_format);
|
return input_engine->SetCameraFormat(identifier, camera_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user