Android: Use input override system for touch controls

This is the first step of getting rid of the controller indirection
on Android. (Needing a way for touch controls to provide input
to the emulator core is the reason why the controller indirection
exists to begin with as far as I understand it.)
This commit is contained in:
JosJuice
2021-04-03 13:49:26 +02:00
parent b296248b49
commit 51ee05cb35
17 changed files with 819 additions and 252 deletions

View File

@ -10,6 +10,7 @@ add_library(main SHARED
GameList/GameFile.cpp
GameList/GameFile.h
GameList/GameFileCache.cpp
Input/InputOverrider.cpp
IniFile.cpp
MainAndroid.cpp
RiivolutionPatches.cpp

View File

@ -0,0 +1,62 @@
// Copyright 2021 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <jni.h>
#include "InputCommon/ControllerInterface/Touch/InputOverrider.h"
extern "C" {
JNIEXPORT void JNICALL
Java_org_dolphinemu_dolphinemu_features_input_model_InputOverrider_registerGameCube(
JNIEnv*, jclass, int controller_index)
{
ciface::Touch::RegisterGameCubeInputOverrider(controller_index);
}
JNIEXPORT void JNICALL
Java_org_dolphinemu_dolphinemu_features_input_model_InputOverrider_registerWii(JNIEnv*, jclass,
int controller_index)
{
ciface::Touch::RegisterWiiInputOverrider(controller_index);
}
JNIEXPORT void JNICALL
Java_org_dolphinemu_dolphinemu_features_input_model_InputOverrider_unregisterGameCube(
JNIEnv*, jclass, int controller_index)
{
ciface::Touch::UnregisterGameCubeInputOverrider(controller_index);
}
JNIEXPORT void JNICALL
Java_org_dolphinemu_dolphinemu_features_input_model_InputOverrider_unregisterWii(
JNIEnv*, jclass, int controller_index)
{
ciface::Touch::UnregisterWiiInputOverrider(controller_index);
}
JNIEXPORT void JNICALL
Java_org_dolphinemu_dolphinemu_features_input_model_InputOverrider_setControlState(
JNIEnv*, jclass, int controller_index, int control, double state)
{
ciface::Touch::SetControlState(controller_index, static_cast<ciface::Touch::ControlID>(control),
state);
}
JNIEXPORT void JNICALL
Java_org_dolphinemu_dolphinemu_features_input_model_InputOverrider_clearControlState(
JNIEnv*, jclass, int controller_index, int control)
{
ciface::Touch::ClearControlState(controller_index,
static_cast<ciface::Touch::ControlID>(control));
}
JNIEXPORT double JNICALL
Java_org_dolphinemu_dolphinemu_features_input_model_InputOverrider_getGateRadiusAtAngle(
JNIEnv*, jclass, int controller_index, int stick, double angle)
{
const auto casted_stick = static_cast<ciface::Touch::ControlID>(stick);
return ciface::Touch::GetGateRadiusAtAngle(controller_index, casted_stick, angle);
}
};

View File

@ -302,13 +302,6 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetMotionSen
ciface::Android::SetMotionSensorsEnabled(accelerometer_enabled, gyroscope_enabled);
}
JNIEXPORT double JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetInputRadiusAtAngle(
JNIEnv*, jclass, int emu_pad_id, int stick, double angle)
{
const auto casted_stick = static_cast<ButtonManager::ButtonType>(stick);
return ButtonManager::GetInputRadiusAtAngle(emu_pad_id, casted_stick, angle);
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv* env,
jclass)
{