From 2b1dd52750c8c85796be4a6785fb769481ec191c Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 14 Aug 2022 11:32:22 +0200 Subject: Android: Add input device selection --- Source/Android/jni/Input/MappingCommon.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'Source/Android/jni/Input/MappingCommon.cpp') diff --git a/Source/Android/jni/Input/MappingCommon.cpp b/Source/Android/jni/Input/MappingCommon.cpp index c02f1c2ae5..4e5d88ccf6 100644 --- a/Source/Android/jni/Input/MappingCommon.cpp +++ b/Source/Android/jni/Input/MappingCommon.cpp @@ -17,6 +17,7 @@ #include "InputCommon/ControllerInterface/ControllerInterface.h" #include "InputCommon/ControllerInterface/MappingCommon.h" #include "jni/AndroidCommon/AndroidCommon.h" +#include "jni/Input/EmulatedController.h" namespace { @@ -28,10 +29,19 @@ constexpr auto INPUT_DETECT_MAXIMUM_TIME = std::chrono::seconds(5); extern "C" { JNIEXPORT jstring JNICALL -Java_org_dolphinemu_dolphinemu_features_input_model_MappingCommon_detectInput(JNIEnv* env, jclass) +Java_org_dolphinemu_dolphinemu_features_input_model_MappingCommon_detectInput( + JNIEnv* env, jclass, jobject j_emulated_controller, jboolean all_devices) { - const std::vector device_strings = g_controller_interface.GetAllDeviceStrings(); - const ciface::Core::DeviceQualifier default_device{}; + ControllerEmu::EmulatedController* emulated_controller = + EmulatedControllerFromJava(env, j_emulated_controller); + + const ciface::Core::DeviceQualifier default_device = emulated_controller->GetDefaultDevice(); + + std::vector device_strings; + if (all_devices) + device_strings = g_controller_interface.GetAllDeviceStrings(); + else + device_strings = {default_device.ToString()}; auto detections = g_controller_interface.DetectInput(device_strings, INPUT_DETECT_INITIAL_TIME, -- cgit v1.2.3