diff options
Diffstat (limited to 'src/core/hid/emulated_controller.cpp')
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 466ff5542..720706794 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -866,7 +866,50 @@ void EmulatedController::SetLedPattern() { | |||
| 866 | } | 866 | } |
| 867 | } | 867 | } |
| 868 | 868 | ||
| 869 | void EmulatedController::SetSupportedNpadStyleTag(NpadStyleTag supported_styles) { | ||
| 870 | supported_style_tag = supported_styles; | ||
| 871 | if (!is_connected) { | ||
| 872 | return; | ||
| 873 | } | ||
| 874 | if (!IsControllerSupported()) { | ||
| 875 | LOG_ERROR(Service_HID, "Controller type {} is not supported. Disconnecting controller", | ||
| 876 | npad_type); | ||
| 877 | Disconnect(); | ||
| 878 | } | ||
| 879 | } | ||
| 880 | |||
| 881 | bool EmulatedController::IsControllerSupported() const { | ||
| 882 | switch (npad_type) { | ||
| 883 | case NpadStyleIndex::ProController: | ||
| 884 | return supported_style_tag.fullkey; | ||
| 885 | case NpadStyleIndex::JoyconDual: | ||
| 886 | return supported_style_tag.joycon_dual; | ||
| 887 | case NpadStyleIndex::JoyconLeft: | ||
| 888 | return supported_style_tag.joycon_left; | ||
| 889 | case NpadStyleIndex::JoyconRight: | ||
| 890 | return supported_style_tag.joycon_right; | ||
| 891 | case NpadStyleIndex::GameCube: | ||
| 892 | return supported_style_tag.gamecube; | ||
| 893 | case NpadStyleIndex::Pokeball: | ||
| 894 | return supported_style_tag.palma; | ||
| 895 | case NpadStyleIndex::NES: | ||
| 896 | return supported_style_tag.lark; | ||
| 897 | case NpadStyleIndex::SNES: | ||
| 898 | return supported_style_tag.lucia; | ||
| 899 | case NpadStyleIndex::N64: | ||
| 900 | return supported_style_tag.lagoon; | ||
| 901 | case NpadStyleIndex::SegaGenesis: | ||
| 902 | return supported_style_tag.lager; | ||
| 903 | default: | ||
| 904 | return false; | ||
| 905 | } | ||
| 906 | } | ||
| 907 | |||
| 869 | void EmulatedController::Connect() { | 908 | void EmulatedController::Connect() { |
| 909 | if (!IsControllerSupported()) { | ||
| 910 | LOG_ERROR(Service_HID, "Controller type {} is not supported", npad_type); | ||
| 911 | return; | ||
| 912 | } | ||
| 870 | { | 913 | { |
| 871 | std::lock_guard lock{mutex}; | 914 | std::lock_guard lock{mutex}; |
| 872 | if (is_configuring) { | 915 | if (is_configuring) { |