mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-05-01 06:18:03 +03:00
Android: Don't use separate thread for MotionAlertDialog
This is an Android continuation of bc95c00
. We now call
InputDetector::Update immediately after receiving an input event from
Android instead of periodically calling it in a sleep loop. This
improves detection of very short inputs, which are especially likely to
occur for volume buttons on phones (or at least on my phone) if you
don't intentionally keep them held down.
This commit is contained in:
parent
1515cf6ccd
commit
516c1314d2
10 changed files with 210 additions and 90 deletions
|
@ -17,42 +17,9 @@
|
|||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
#include "InputCommon/ControllerInterface/MappingCommon.h"
|
||||
#include "jni/AndroidCommon/AndroidCommon.h"
|
||||
#include "jni/Input/EmulatedController.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr auto INPUT_DETECT_INITIAL_TIME = std::chrono::seconds(3);
|
||||
constexpr auto INPUT_DETECT_CONFIRMATION_TIME = std::chrono::milliseconds(0);
|
||||
constexpr auto INPUT_DETECT_MAXIMUM_TIME = std::chrono::seconds(5);
|
||||
} // namespace
|
||||
|
||||
extern "C" {
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_features_input_model_MappingCommon_detectInput(
|
||||
JNIEnv* env, jclass, jobject j_emulated_controller, jboolean all_devices)
|
||||
{
|
||||
ControllerEmu::EmulatedController* emulated_controller =
|
||||
EmulatedControllerFromJava(env, j_emulated_controller);
|
||||
|
||||
const ciface::Core::DeviceQualifier default_device = emulated_controller->GetDefaultDevice();
|
||||
|
||||
std::vector<std::string> 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,
|
||||
INPUT_DETECT_CONFIRMATION_TIME, INPUT_DETECT_MAXIMUM_TIME);
|
||||
|
||||
ciface::MappingCommon::RemoveSpuriousTriggerCombinations(&detections);
|
||||
|
||||
return ToJString(env, ciface::MappingCommon::BuildExpression(detections, default_device,
|
||||
ciface::MappingCommon::Quote::On));
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_features_input_model_MappingCommon_getExpressionForControl(
|
||||
JNIEnv* env, jclass, jstring j_control, jstring j_device, jstring j_default_device)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue