diff options
| author | 2022-12-20 20:27:34 -0600 | |
|---|---|---|
| committer | 2023-01-19 18:05:21 -0600 | |
| commit | f09a023292e659af46d551b9b134d94d000a57c7 (patch) | |
| tree | f34ef390cac9f32f7d807614505601635ac62e28 /src/input_common/drivers/joycon.cpp | |
| parent | input_common: Use calibration from joycon (diff) | |
| download | yuzu-f09a023292e659af46d551b9b134d94d000a57c7.tar.gz yuzu-f09a023292e659af46d551b9b134d94d000a57c7.tar.xz yuzu-f09a023292e659af46d551b9b134d94d000a57c7.zip | |
input_common: Add support for joycon input reports
Diffstat (limited to 'src/input_common/drivers/joycon.cpp')
| -rw-r--r-- | src/input_common/drivers/joycon.cpp | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp index c6f78c989..dbe730e1a 100644 --- a/src/input_common/drivers/joycon.cpp +++ b/src/input_common/drivers/joycon.cpp | |||
| @@ -167,30 +167,31 @@ void Joycons::RegisterNewDevice(SDL_hid_device_info* device_info) { | |||
| 167 | if (result == Joycon::DriverResult::Success) { | 167 | if (result == Joycon::DriverResult::Success) { |
| 168 | LOG_WARNING(Input, "Initialize device"); | 168 | LOG_WARNING(Input, "Initialize device"); |
| 169 | 169 | ||
| 170 | std::function<void(Joycon::Battery)> on_battery_data; | ||
| 171 | std::function<void(Joycon::Color)> on_button_data; | ||
| 172 | std::function<void(int, f32)> on_stick_data; | ||
| 173 | std::function<void(int, std::array<u8, 6>)> on_motion_data; | ||
| 174 | std::function<void(s16)> on_ring_data; | ||
| 175 | std::function<void(const std::vector<u8>&)> on_amiibo_data; | ||
| 176 | |||
| 177 | const std::size_t port = handle->GetDevicePort(); | 170 | const std::size_t port = handle->GetDevicePort(); |
| 178 | handle->on_battery_data = { | 171 | const Joycon::JoyconCallbacks callbacks{ |
| 179 | [this, port, type](Joycon::Battery value) { OnBatteryUpdate(port, type, value); }}; | 172 | .on_battery_data = {[this, port, type](Joycon::Battery value) { |
| 180 | handle->on_color_data = { | 173 | OnBatteryUpdate(port, type, value); |
| 181 | [this, port, type](Joycon::Color value) { OnColorUpdate(port, type, value); }}; | 174 | }}, |
| 182 | handle->on_button_data = { | 175 | .on_color_data = {[this, port, type](Joycon::Color value) { |
| 183 | [this, port, type](int id, bool value) { OnButtonUpdate(port, type, id, value); }}; | 176 | OnColorUpdate(port, type, value); |
| 184 | handle->on_stick_data = { | 177 | }}, |
| 185 | [this, port, type](int id, f32 value) { OnStickUpdate(port, type, id, value); }}; | 178 | .on_button_data = {[this, port, type](int id, bool value) { |
| 186 | handle->on_motion_data = {[this, port, type](int id, Joycon::MotionData value) { | 179 | OnButtonUpdate(port, type, id, value); |
| 187 | OnMotionUpdate(port, type, id, value); | 180 | }}, |
| 188 | }}; | 181 | .on_stick_data = {[this, port, type](int id, f32 value) { |
| 189 | handle->on_ring_data = {[this](f32 ring_data) { OnRingConUpdate(ring_data); }}; | 182 | OnStickUpdate(port, type, id, value); |
| 190 | handle->on_amiibo_data = {[this, port](const std::vector<u8>& amiibo_data) { | 183 | }}, |
| 191 | OnAmiiboUpdate(port, amiibo_data); | 184 | .on_motion_data = {[this, port, type](int id, const Joycon::MotionData& value) { |
| 192 | }}; | 185 | OnMotionUpdate(port, type, id, value); |
| 186 | }}, | ||
| 187 | .on_ring_data = {[this](f32 ring_data) { OnRingConUpdate(ring_data); }}, | ||
| 188 | .on_amiibo_data = {[this, port](const std::vector<u8>& amiibo_data) { | ||
| 189 | OnAmiiboUpdate(port, amiibo_data); | ||
| 190 | }}, | ||
| 191 | }; | ||
| 192 | |||
| 193 | handle->InitializeDevice(); | 193 | handle->InitializeDevice(); |
| 194 | handle->SetCallbacks(callbacks); | ||
| 194 | } | 195 | } |
| 195 | } | 196 | } |
| 196 | 197 | ||
| @@ -235,7 +236,7 @@ Common::Input::VibrationError Joycons::SetVibration( | |||
| 235 | .low_amplitude = vibration.low_amplitude, | 236 | .low_amplitude = vibration.low_amplitude, |
| 236 | .low_frequency = vibration.low_frequency, | 237 | .low_frequency = vibration.low_frequency, |
| 237 | .high_amplitude = vibration.high_amplitude, | 238 | .high_amplitude = vibration.high_amplitude, |
| 238 | .high_frequency = vibration.high_amplitude, | 239 | .high_frequency = vibration.high_frequency, |
| 239 | }; | 240 | }; |
| 240 | auto handle = GetHandle(identifier); | 241 | auto handle = GetHandle(identifier); |
| 241 | if (handle == nullptr) { | 242 | if (handle == nullptr) { |