diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 43 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.h | 14 | ||||
| -rw-r--r-- | src/core/hid/hid_core.cpp | 10 | ||||
| -rw-r--r-- | src/core/hid/hid_core.h | 2 | ||||
| -rw-r--r-- | src/core/hid/hid_types.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 30 | ||||
| -rw-r--r-- | src/video_core/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/video_core/command_classes/codecs/codec.cpp | 115 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 131 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 3 |
10 files changed, 197 insertions, 154 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) { |
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index 5887e3e38..425b3e7c4 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h | |||
| @@ -160,6 +160,13 @@ public: | |||
| 160 | */ | 160 | */ |
| 161 | NpadStyleIndex GetNpadStyleIndex(bool get_temporary_value = false) const; | 161 | NpadStyleIndex GetNpadStyleIndex(bool get_temporary_value = false) const; |
| 162 | 162 | ||
| 163 | /** | ||
| 164 | * Sets the supported controller types. Disconnects the controller if current type is not | ||
| 165 | * supported | ||
| 166 | * @param supported_styles bitflag with supported types | ||
| 167 | */ | ||
| 168 | void SetSupportedNpadStyleTag(NpadStyleTag supported_styles); | ||
| 169 | |||
| 163 | /// Sets the connected status to true | 170 | /// Sets the connected status to true |
| 164 | void Connect(); | 171 | void Connect(); |
| 165 | 172 | ||
| @@ -311,6 +318,12 @@ private: | |||
| 311 | void LoadTASParams(); | 318 | void LoadTASParams(); |
| 312 | 319 | ||
| 313 | /** | 320 | /** |
| 321 | * Checks the current controller type against the supported_style_tag | ||
| 322 | * @return true if the controller is supported | ||
| 323 | */ | ||
| 324 | bool IsControllerSupported() const; | ||
| 325 | |||
| 326 | /** | ||
| 314 | * Updates the button status of the controller | 327 | * Updates the button status of the controller |
| 315 | * @param callback A CallbackStatus containing the button status | 328 | * @param callback A CallbackStatus containing the button status |
| 316 | * @param index Button ID of the to be updated | 329 | * @param index Button ID of the to be updated |
| @@ -354,6 +367,7 @@ private: | |||
| 354 | 367 | ||
| 355 | NpadIdType npad_id_type; | 368 | NpadIdType npad_id_type; |
| 356 | NpadStyleIndex npad_type{NpadStyleIndex::None}; | 369 | NpadStyleIndex npad_type{NpadStyleIndex::None}; |
| 370 | NpadStyleTag supported_style_tag{NpadStyleSet::All}; | ||
| 357 | bool is_connected{false}; | 371 | bool is_connected{false}; |
| 358 | bool is_configuring{false}; | 372 | bool is_configuring{false}; |
| 359 | f32 motion_sensitivity{0.01f}; | 373 | f32 motion_sensitivity{0.01f}; |
diff --git a/src/core/hid/hid_core.cpp b/src/core/hid/hid_core.cpp index 946adde00..0c3eb5a62 100644 --- a/src/core/hid/hid_core.cpp +++ b/src/core/hid/hid_core.cpp | |||
| @@ -108,6 +108,16 @@ const EmulatedController* HIDCore::GetEmulatedControllerByIndex(std::size_t inde | |||
| 108 | 108 | ||
| 109 | void HIDCore::SetSupportedStyleTag(NpadStyleTag style_tag) { | 109 | void HIDCore::SetSupportedStyleTag(NpadStyleTag style_tag) { |
| 110 | supported_style_tag.raw = style_tag.raw; | 110 | supported_style_tag.raw = style_tag.raw; |
| 111 | player_1->SetSupportedNpadStyleTag(supported_style_tag); | ||
| 112 | player_2->SetSupportedNpadStyleTag(supported_style_tag); | ||
| 113 | player_3->SetSupportedNpadStyleTag(supported_style_tag); | ||
| 114 | player_4->SetSupportedNpadStyleTag(supported_style_tag); | ||
| 115 | player_5->SetSupportedNpadStyleTag(supported_style_tag); | ||
| 116 | player_6->SetSupportedNpadStyleTag(supported_style_tag); | ||
| 117 | player_7->SetSupportedNpadStyleTag(supported_style_tag); | ||
| 118 | player_8->SetSupportedNpadStyleTag(supported_style_tag); | ||
| 119 | other->SetSupportedNpadStyleTag(supported_style_tag); | ||
| 120 | handheld->SetSupportedNpadStyleTag(supported_style_tag); | ||
| 111 | } | 121 | } |
| 112 | 122 | ||
| 113 | NpadStyleTag HIDCore::GetSupportedStyleTag() const { | 123 | NpadStyleTag HIDCore::GetSupportedStyleTag() const { |
diff --git a/src/core/hid/hid_core.h b/src/core/hid/hid_core.h index 140a0e962..2fb0f7e19 100644 --- a/src/core/hid/hid_core.h +++ b/src/core/hid/hid_core.h | |||
| @@ -73,7 +73,7 @@ private: | |||
| 73 | std::unique_ptr<EmulatedController> handheld; | 73 | std::unique_ptr<EmulatedController> handheld; |
| 74 | std::unique_ptr<EmulatedConsole> console; | 74 | std::unique_ptr<EmulatedConsole> console; |
| 75 | std::unique_ptr<EmulatedDevices> devices; | 75 | std::unique_ptr<EmulatedDevices> devices; |
| 76 | NpadStyleTag supported_style_tag; | 76 | NpadStyleTag supported_style_tag{NpadStyleSet::All}; |
| 77 | }; | 77 | }; |
| 78 | 78 | ||
| 79 | } // namespace Core::HID | 79 | } // namespace Core::HID |
diff --git a/src/core/hid/hid_types.h b/src/core/hid/hid_types.h index 780659b86..7c12f01fc 100644 --- a/src/core/hid/hid_types.h +++ b/src/core/hid/hid_types.h | |||
| @@ -256,6 +256,8 @@ enum class NpadStyleSet : u32 { | |||
| 256 | Lager = 1U << 11, | 256 | Lager = 1U << 11, |
| 257 | SystemExt = 1U << 29, | 257 | SystemExt = 1U << 29, |
| 258 | System = 1U << 30, | 258 | System = 1U << 30, |
| 259 | |||
| 260 | All = 0xFFFFFFFFU, | ||
| 259 | }; | 261 | }; |
| 260 | static_assert(sizeof(NpadStyleSet) == 4, "NpadStyleSet is an invalid size"); | 262 | static_assert(sizeof(NpadStyleSet) == 4, "NpadStyleSet is an invalid size"); |
| 261 | 263 | ||
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 6916930f7..ae56f10cf 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -126,8 +126,11 @@ void Controller_NPad::ControllerUpdate(Core::HID::ControllerTriggerType type, | |||
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | void Controller_NPad::InitNewlyAddedController(Core::HID::NpadIdType npad_id) { | 128 | void Controller_NPad::InitNewlyAddedController(Core::HID::NpadIdType npad_id) { |
| 129 | LOG_DEBUG(Service_HID, "Npad connected {}", npad_id); | ||
| 130 | auto& controller = GetControllerFromNpadIdType(npad_id); | 129 | auto& controller = GetControllerFromNpadIdType(npad_id); |
| 130 | if (!IsControllerSupported(controller.device->GetNpadStyleIndex())) { | ||
| 131 | return; | ||
| 132 | } | ||
| 133 | LOG_DEBUG(Service_HID, "Npad connected {}", npad_id); | ||
| 131 | const auto controller_type = controller.device->GetNpadStyleIndex(); | 134 | const auto controller_type = controller.device->GetNpadStyleIndex(); |
| 132 | auto& shared_memory = controller.shared_memory_entry; | 135 | auto& shared_memory = controller.shared_memory_entry; |
| 133 | if (controller_type == Core::HID::NpadStyleIndex::None) { | 136 | if (controller_type == Core::HID::NpadStyleIndex::None) { |
| @@ -255,19 +258,7 @@ void Controller_NPad::OnInit() { | |||
| 255 | 258 | ||
| 256 | if (hid_core.GetSupportedStyleTag().raw == Core::HID::NpadStyleSet::None) { | 259 | if (hid_core.GetSupportedStyleTag().raw == Core::HID::NpadStyleSet::None) { |
| 257 | // We want to support all controllers | 260 | // We want to support all controllers |
| 258 | Core::HID::NpadStyleTag style{}; | 261 | hid_core.SetSupportedStyleTag({Core::HID::NpadStyleSet::All}); |
| 259 | style.handheld.Assign(1); | ||
| 260 | style.joycon_left.Assign(1); | ||
| 261 | style.joycon_right.Assign(1); | ||
| 262 | style.joycon_dual.Assign(1); | ||
| 263 | style.fullkey.Assign(1); | ||
| 264 | style.gamecube.Assign(1); | ||
| 265 | style.palma.Assign(1); | ||
| 266 | style.lark.Assign(1); | ||
| 267 | style.lucia.Assign(1); | ||
| 268 | style.lagoon.Assign(1); | ||
| 269 | style.lager.Assign(1); | ||
| 270 | hid_core.SetSupportedStyleTag(style); | ||
| 271 | } | 262 | } |
| 272 | 263 | ||
| 273 | supported_npad_id_types.resize(npad_id_list.size()); | 264 | supported_npad_id_types.resize(npad_id_list.size()); |
| @@ -1072,13 +1063,18 @@ bool Controller_NPad::SwapNpadAssignment(Core::HID::NpadIdType npad_id_1, | |||
| 1072 | const auto& controller_2 = GetControllerFromNpadIdType(npad_id_2).device; | 1063 | const auto& controller_2 = GetControllerFromNpadIdType(npad_id_2).device; |
| 1073 | const auto type_index_1 = controller_1->GetNpadStyleIndex(); | 1064 | const auto type_index_1 = controller_1->GetNpadStyleIndex(); |
| 1074 | const auto type_index_2 = controller_2->GetNpadStyleIndex(); | 1065 | const auto type_index_2 = controller_2->GetNpadStyleIndex(); |
| 1066 | const auto is_connected_1 = controller_1->IsConnected(); | ||
| 1067 | const auto is_connected_2 = controller_2->IsConnected(); | ||
| 1075 | 1068 | ||
| 1076 | if (!IsControllerSupported(type_index_1) || !IsControllerSupported(type_index_2)) { | 1069 | if (!IsControllerSupported(type_index_1) && is_connected_1) { |
| 1070 | return false; | ||
| 1071 | } | ||
| 1072 | if (!IsControllerSupported(type_index_2) && is_connected_2) { | ||
| 1077 | return false; | 1073 | return false; |
| 1078 | } | 1074 | } |
| 1079 | 1075 | ||
| 1080 | AddNewControllerAt(type_index_2, npad_id_1); | 1076 | UpdateControllerAt(type_index_2, npad_id_1, is_connected_2); |
| 1081 | AddNewControllerAt(type_index_1, npad_id_2); | 1077 | UpdateControllerAt(type_index_1, npad_id_2, is_connected_1); |
| 1082 | 1078 | ||
| 1083 | return true; | 1079 | return true; |
| 1084 | } | 1080 | } |
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 91a30fef7..6a6325e38 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt | |||
| @@ -3,6 +3,7 @@ add_subdirectory(host_shaders) | |||
| 3 | if(LIBVA_FOUND) | 3 | if(LIBVA_FOUND) |
| 4 | set_source_files_properties(command_classes/codecs/codec.cpp | 4 | set_source_files_properties(command_classes/codecs/codec.cpp |
| 5 | PROPERTIES COMPILE_DEFINITIONS LIBVA_FOUND=1) | 5 | PROPERTIES COMPILE_DEFINITIONS LIBVA_FOUND=1) |
| 6 | list(APPEND FFmpeg_LIBRARIES ${LIBVA_LIBRARIES}) | ||
| 6 | endif() | 7 | endif() |
| 7 | 8 | ||
| 8 | add_library(video_core STATIC | 9 | add_library(video_core STATIC |
diff --git a/src/video_core/command_classes/codecs/codec.cpp b/src/video_core/command_classes/codecs/codec.cpp index 02d309170..2a532b883 100644 --- a/src/video_core/command_classes/codecs/codec.cpp +++ b/src/video_core/command_classes/codecs/codec.cpp | |||
| @@ -17,12 +17,28 @@ | |||
| 17 | 17 | ||
| 18 | extern "C" { | 18 | extern "C" { |
| 19 | #include <libavutil/opt.h> | 19 | #include <libavutil/opt.h> |
| 20 | #ifdef LIBVA_FOUND | ||
| 21 | // for querying VAAPI driver information | ||
| 22 | #include <libavutil/hwcontext_vaapi.h> | ||
| 23 | #endif | ||
| 20 | } | 24 | } |
| 21 | 25 | ||
| 22 | namespace Tegra { | 26 | namespace Tegra { |
| 23 | namespace { | 27 | namespace { |
| 24 | constexpr AVPixelFormat PREFERRED_GPU_FMT = AV_PIX_FMT_NV12; | 28 | constexpr AVPixelFormat PREFERRED_GPU_FMT = AV_PIX_FMT_NV12; |
| 25 | constexpr AVPixelFormat PREFERRED_CPU_FMT = AV_PIX_FMT_YUV420P; | 29 | constexpr AVPixelFormat PREFERRED_CPU_FMT = AV_PIX_FMT_YUV420P; |
| 30 | constexpr std::array PREFERRED_GPU_DECODERS = { | ||
| 31 | AV_HWDEVICE_TYPE_CUDA, | ||
| 32 | #ifdef _WIN32 | ||
| 33 | AV_HWDEVICE_TYPE_D3D11VA, | ||
| 34 | AV_HWDEVICE_TYPE_DXVA2, | ||
| 35 | #elif defined(__linux__) | ||
| 36 | AV_HWDEVICE_TYPE_VAAPI, | ||
| 37 | AV_HWDEVICE_TYPE_VDPAU, | ||
| 38 | #endif | ||
| 39 | // last resort for Linux Flatpak (w/ NVIDIA) | ||
| 40 | AV_HWDEVICE_TYPE_VULKAN, | ||
| 41 | }; | ||
| 26 | 42 | ||
| 27 | void AVPacketDeleter(AVPacket* ptr) { | 43 | void AVPacketDeleter(AVPacket* ptr) { |
| 28 | av_packet_free(&ptr); | 44 | av_packet_free(&ptr); |
| @@ -61,83 +77,50 @@ Codec::~Codec() { | |||
| 61 | av_buffer_unref(&av_gpu_decoder); | 77 | av_buffer_unref(&av_gpu_decoder); |
| 62 | } | 78 | } |
| 63 | 79 | ||
| 64 | #ifdef LIBVA_FOUND | 80 | // List all the currently available hwcontext in ffmpeg |
| 65 | // List all the currently loaded Linux modules | 81 | static std::vector<AVHWDeviceType> ListSupportedContexts() { |
| 66 | static std::vector<std::string> ListLinuxKernelModules() { | 82 | std::vector<AVHWDeviceType> contexts{}; |
| 67 | using FILEPtr = std::unique_ptr<FILE, decltype(&std::fclose)>; | 83 | AVHWDeviceType current_device_type = AV_HWDEVICE_TYPE_NONE; |
| 68 | auto module_listing = FILEPtr{fopen("/proc/modules", "rt"), std::fclose}; | 84 | do { |
| 69 | std::vector<std::string> modules{}; | 85 | current_device_type = av_hwdevice_iterate_types(current_device_type); |
| 70 | if (!module_listing) { | 86 | contexts.push_back(current_device_type); |
| 71 | LOG_WARNING(Service_NVDRV, "Could not open /proc/modules to collect available modules"); | 87 | } while (current_device_type != AV_HWDEVICE_TYPE_NONE); |
| 72 | return modules; | 88 | return contexts; |
| 73 | } | ||
| 74 | char* buffer = nullptr; | ||
| 75 | size_t buf_len = 0; | ||
| 76 | while (getline(&buffer, &buf_len, module_listing.get()) != -1) { | ||
| 77 | // format for the module listing file (sysfs) | ||
| 78 | // <name> <module_size> <depended_by_count> <depended_by_names> <status> <load_address> | ||
| 79 | auto line = std::string(buffer); | ||
| 80 | // we are only interested in module names | ||
| 81 | auto name_pos = line.find_first_of(" "); | ||
| 82 | if (name_pos == std::string::npos) { | ||
| 83 | continue; | ||
| 84 | } | ||
| 85 | modules.push_back(line.erase(name_pos)); | ||
| 86 | } | ||
| 87 | free(buffer); | ||
| 88 | return modules; | ||
| 89 | } | 89 | } |
| 90 | #endif | ||
| 91 | 90 | ||
| 92 | bool Codec::CreateGpuAvDevice() { | 91 | bool Codec::CreateGpuAvDevice() { |
| 93 | #if defined(LIBVA_FOUND) | 92 | static constexpr auto HW_CONFIG_METHOD = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX; |
| 94 | static constexpr std::array<const char*, 3> VAAPI_DRIVERS = { | 93 | static const auto supported_contexts = ListSupportedContexts(); |
| 95 | "i915", | 94 | for (const auto& type : PREFERRED_GPU_DECODERS) { |
| 96 | "iHD", | 95 | if (std::none_of(supported_contexts.begin(), supported_contexts.end(), |
| 97 | "amdgpu", | 96 | [&type](const auto& context) { return context == type; })) { |
| 98 | }; | 97 | LOG_DEBUG(Service_NVDRV, "{} explicitly unsupported", av_hwdevice_get_type_name(type)); |
| 99 | AVDictionary* hwdevice_options = nullptr; | ||
| 100 | const auto loaded_modules = ListLinuxKernelModules(); | ||
| 101 | av_dict_set(&hwdevice_options, "connection_type", "drm", 0); | ||
| 102 | for (const auto& driver : VAAPI_DRIVERS) { | ||
| 103 | // first check if the target driver is loaded in the kernel | ||
| 104 | bool found = std::any_of(loaded_modules.begin(), loaded_modules.end(), | ||
| 105 | [&driver](const auto& module) { return module == driver; }); | ||
| 106 | if (!found) { | ||
| 107 | LOG_DEBUG(Service_NVDRV, "Kernel driver {} is not loaded, trying the next one", driver); | ||
| 108 | continue; | 98 | continue; |
| 109 | } | 99 | } |
| 110 | av_dict_set(&hwdevice_options, "kernel_driver", driver, 0); | ||
| 111 | const int hwdevice_error = av_hwdevice_ctx_create(&av_gpu_decoder, AV_HWDEVICE_TYPE_VAAPI, | ||
| 112 | nullptr, hwdevice_options, 0); | ||
| 113 | if (hwdevice_error >= 0) { | ||
| 114 | LOG_INFO(Service_NVDRV, "Using VA-API with {}", driver); | ||
| 115 | av_dict_free(&hwdevice_options); | ||
| 116 | av_codec_ctx->pix_fmt = AV_PIX_FMT_VAAPI; | ||
| 117 | return true; | ||
| 118 | } | ||
| 119 | LOG_DEBUG(Service_NVDRV, "VA-API av_hwdevice_ctx_create failed {}", hwdevice_error); | ||
| 120 | } | ||
| 121 | LOG_DEBUG(Service_NVDRV, "VA-API av_hwdevice_ctx_create failed for all drivers"); | ||
| 122 | av_dict_free(&hwdevice_options); | ||
| 123 | #endif | ||
| 124 | static constexpr auto HW_CONFIG_METHOD = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX; | ||
| 125 | static constexpr std::array GPU_DECODER_TYPES{ | ||
| 126 | #ifdef linux | ||
| 127 | AV_HWDEVICE_TYPE_VDPAU, | ||
| 128 | #endif | ||
| 129 | AV_HWDEVICE_TYPE_CUDA, | ||
| 130 | #ifdef _WIN32 | ||
| 131 | AV_HWDEVICE_TYPE_D3D11VA, | ||
| 132 | #endif | ||
| 133 | }; | ||
| 134 | for (const auto& type : GPU_DECODER_TYPES) { | ||
| 135 | const int hwdevice_res = av_hwdevice_ctx_create(&av_gpu_decoder, type, nullptr, nullptr, 0); | 100 | const int hwdevice_res = av_hwdevice_ctx_create(&av_gpu_decoder, type, nullptr, nullptr, 0); |
| 136 | if (hwdevice_res < 0) { | 101 | if (hwdevice_res < 0) { |
| 137 | LOG_DEBUG(Service_NVDRV, "{} av_hwdevice_ctx_create failed {}", | 102 | LOG_DEBUG(Service_NVDRV, "{} av_hwdevice_ctx_create failed {}", |
| 138 | av_hwdevice_get_type_name(type), hwdevice_res); | 103 | av_hwdevice_get_type_name(type), hwdevice_res); |
| 139 | continue; | 104 | continue; |
| 140 | } | 105 | } |
| 106 | #ifdef LIBVA_FOUND | ||
| 107 | if (type == AV_HWDEVICE_TYPE_VAAPI) { | ||
| 108 | // we need to determine if this is an impersonated VAAPI driver | ||
| 109 | AVHWDeviceContext* hwctx = | ||
| 110 | static_cast<AVHWDeviceContext*>(static_cast<void*>(av_gpu_decoder->data)); | ||
| 111 | AVVAAPIDeviceContext* vactx = static_cast<AVVAAPIDeviceContext*>(hwctx->hwctx); | ||
| 112 | const char* vendor_name = vaQueryVendorString(vactx->display); | ||
| 113 | if (strstr(vendor_name, "VDPAU backend")) { | ||
| 114 | // VDPAU impersonated VAAPI impl's are super buggy, we need to skip them | ||
| 115 | LOG_DEBUG(Service_NVDRV, "Skipping vdapu impersonated VAAPI driver"); | ||
| 116 | continue; | ||
| 117 | } else { | ||
| 118 | // according to some user testing, certain vaapi driver (Intel?) could be buggy | ||
| 119 | // so let's log the driver name which may help the developers/supporters | ||
| 120 | LOG_DEBUG(Service_NVDRV, "Using VAAPI driver: {}", vendor_name); | ||
| 121 | } | ||
| 122 | } | ||
| 123 | #endif | ||
| 141 | for (int i = 0;; i++) { | 124 | for (int i = 0;; i++) { |
| 142 | const AVCodecHWConfig* config = avcodec_get_hw_config(av_codec, i); | 125 | const AVCodecHWConfig* config = avcodec_get_hw_config(av_codec, i); |
| 143 | if (!config) { | 126 | if (!config) { |
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 34099bc83..8a8be8e40 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -907,88 +907,79 @@ void ConfigureInputPlayer::UpdateUI() { | |||
| 907 | } | 907 | } |
| 908 | 908 | ||
| 909 | void ConfigureInputPlayer::SetConnectableControllers() { | 909 | void ConfigureInputPlayer::SetConnectableControllers() { |
| 910 | const auto add_controllers = [this](bool enable_all, | 910 | Core::HID::NpadStyleTag npad_style_set = hid_core.GetSupportedStyleTag(); |
| 911 | Core::HID::NpadStyleTag npad_style_set = {}) { | 911 | index_controller_type_pairs.clear(); |
| 912 | index_controller_type_pairs.clear(); | 912 | ui->comboControllerType->clear(); |
| 913 | ui->comboControllerType->clear(); | ||
| 914 | |||
| 915 | if (enable_all || npad_style_set.fullkey == 1) { | ||
| 916 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | ||
| 917 | Core::HID::NpadStyleIndex::ProController); | ||
| 918 | ui->comboControllerType->addItem(tr("Pro Controller")); | ||
| 919 | } | ||
| 920 | |||
| 921 | if (enable_all || npad_style_set.joycon_dual == 1) { | ||
| 922 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | ||
| 923 | Core::HID::NpadStyleIndex::JoyconDual); | ||
| 924 | ui->comboControllerType->addItem(tr("Dual Joycons")); | ||
| 925 | } | ||
| 926 | 913 | ||
| 927 | if (enable_all || npad_style_set.joycon_left == 1) { | 914 | if (npad_style_set.fullkey == 1) { |
| 928 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 915 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), |
| 929 | Core::HID::NpadStyleIndex::JoyconLeft); | 916 | Core::HID::NpadStyleIndex::ProController); |
| 930 | ui->comboControllerType->addItem(tr("Left Joycon")); | 917 | ui->comboControllerType->addItem(tr("Pro Controller")); |
| 931 | } | 918 | } |
| 932 | 919 | ||
| 933 | if (enable_all || npad_style_set.joycon_right == 1) { | 920 | if (npad_style_set.joycon_dual == 1) { |
| 934 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 921 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), |
| 935 | Core::HID::NpadStyleIndex::JoyconRight); | 922 | Core::HID::NpadStyleIndex::JoyconDual); |
| 936 | ui->comboControllerType->addItem(tr("Right Joycon")); | 923 | ui->comboControllerType->addItem(tr("Dual Joycons")); |
| 937 | } | 924 | } |
| 938 | 925 | ||
| 939 | if (player_index == 0 && (enable_all || npad_style_set.handheld == 1)) { | 926 | if (npad_style_set.joycon_left == 1) { |
| 940 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 927 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), |
| 941 | Core::HID::NpadStyleIndex::Handheld); | 928 | Core::HID::NpadStyleIndex::JoyconLeft); |
| 942 | ui->comboControllerType->addItem(tr("Handheld")); | 929 | ui->comboControllerType->addItem(tr("Left Joycon")); |
| 943 | } | 930 | } |
| 944 | 931 | ||
| 945 | if (enable_all || npad_style_set.gamecube == 1) { | 932 | if (npad_style_set.joycon_right == 1) { |
| 946 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 933 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), |
| 947 | Core::HID::NpadStyleIndex::GameCube); | 934 | Core::HID::NpadStyleIndex::JoyconRight); |
| 948 | ui->comboControllerType->addItem(tr("GameCube Controller")); | 935 | ui->comboControllerType->addItem(tr("Right Joycon")); |
| 949 | } | 936 | } |
| 950 | 937 | ||
| 951 | // Disable all unsupported controllers | 938 | if (player_index == 0 && npad_style_set.handheld == 1) { |
| 952 | if (!Settings::values.enable_all_controllers) { | 939 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), |
| 953 | return; | 940 | Core::HID::NpadStyleIndex::Handheld); |
| 954 | } | 941 | ui->comboControllerType->addItem(tr("Handheld")); |
| 955 | if (enable_all || npad_style_set.palma == 1) { | 942 | } |
| 956 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | ||
| 957 | Core::HID::NpadStyleIndex::Pokeball); | ||
| 958 | ui->comboControllerType->addItem(tr("Poke Ball Plus")); | ||
| 959 | } | ||
| 960 | 943 | ||
| 961 | if (enable_all || npad_style_set.lark == 1) { | 944 | if (npad_style_set.gamecube == 1) { |
| 962 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 945 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), |
| 963 | Core::HID::NpadStyleIndex::NES); | 946 | Core::HID::NpadStyleIndex::GameCube); |
| 964 | ui->comboControllerType->addItem(tr("NES Controller")); | 947 | ui->comboControllerType->addItem(tr("GameCube Controller")); |
| 965 | } | 948 | } |
| 966 | 949 | ||
| 967 | if (enable_all || npad_style_set.lucia == 1) { | 950 | // Disable all unsupported controllers |
| 968 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 951 | if (!Settings::values.enable_all_controllers) { |
| 969 | Core::HID::NpadStyleIndex::SNES); | 952 | return; |
| 970 | ui->comboControllerType->addItem(tr("SNES Controller")); | 953 | } |
| 971 | } | 954 | if (npad_style_set.palma == 1) { |
| 955 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | ||
| 956 | Core::HID::NpadStyleIndex::Pokeball); | ||
| 957 | ui->comboControllerType->addItem(tr("Poke Ball Plus")); | ||
| 958 | } | ||
| 972 | 959 | ||
| 973 | if (enable_all || npad_style_set.lagoon == 1) { | 960 | if (npad_style_set.lark == 1) { |
| 974 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 961 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), |
| 975 | Core::HID::NpadStyleIndex::N64); | 962 | Core::HID::NpadStyleIndex::NES); |
| 976 | ui->comboControllerType->addItem(tr("N64 Controller")); | 963 | ui->comboControllerType->addItem(tr("NES Controller")); |
| 977 | } | 964 | } |
| 978 | 965 | ||
| 979 | if (enable_all || npad_style_set.lager == 1) { | 966 | if (npad_style_set.lucia == 1) { |
| 980 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | 967 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), |
| 981 | Core::HID::NpadStyleIndex::SegaGenesis); | 968 | Core::HID::NpadStyleIndex::SNES); |
| 982 | ui->comboControllerType->addItem(tr("Sega Genesis")); | 969 | ui->comboControllerType->addItem(tr("SNES Controller")); |
| 983 | } | 970 | } |
| 984 | }; | ||
| 985 | 971 | ||
| 986 | if (!is_powered_on) { | 972 | if (npad_style_set.lagoon == 1) { |
| 987 | add_controllers(true); | 973 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), |
| 988 | return; | 974 | Core::HID::NpadStyleIndex::N64); |
| 975 | ui->comboControllerType->addItem(tr("N64 Controller")); | ||
| 989 | } | 976 | } |
| 990 | 977 | ||
| 991 | add_controllers(false, hid_core.GetSupportedStyleTag()); | 978 | if (npad_style_set.lager == 1) { |
| 979 | index_controller_type_pairs.emplace_back(ui->comboControllerType->count(), | ||
| 980 | Core::HID::NpadStyleIndex::SegaGenesis); | ||
| 981 | ui->comboControllerType->addItem(tr("Sega Genesis")); | ||
| 982 | } | ||
| 992 | } | 983 | } |
| 993 | 984 | ||
| 994 | Core::HID::NpadStyleIndex ConfigureInputPlayer::GetControllerTypeFromIndex(int index) const { | 985 | Core::HID::NpadStyleIndex ConfigureInputPlayer::GetControllerTypeFromIndex(int index) const { |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index f266fd963..5a9dec8f3 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -1516,6 +1516,9 @@ void GMainWindow::ShutdownGame() { | |||
| 1516 | input_subsystem->GetTas()->Stop(); | 1516 | input_subsystem->GetTas()->Stop(); |
| 1517 | OnTasStateChanged(); | 1517 | OnTasStateChanged(); |
| 1518 | 1518 | ||
| 1519 | // Enable all controllers | ||
| 1520 | system->HIDCore().SetSupportedStyleTag({Core::HID::NpadStyleSet::All}); | ||
| 1521 | |||
| 1519 | render_window->removeEventFilter(render_window); | 1522 | render_window->removeEventFilter(render_window); |
| 1520 | render_window->setAttribute(Qt::WA_Hover, false); | 1523 | render_window->setAttribute(Qt::WA_Hover, false); |
| 1521 | 1524 | ||