ControllerInterface/Android: Rip out ButtonManager

ButtonManager is very different from how a normal input backend works,
and is making it hard for us to improve controller support on Android.
The following commits will add a new input backend in its place.
This commit is contained in:
JosJuice
2021-08-14 15:03:54 +02:00
parent 95ce41ac56
commit 0150f521f7
10 changed files with 9 additions and 1474 deletions

View File

@ -44,7 +44,7 @@ public final class NativeLibrary
}
/**
* Button type for use in onTouchEvent
* Button type, for legacy use only
*/
public static final class ButtonType
{

View File

@ -894,21 +894,8 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
return super.dispatchKeyEvent(event);
}
int action;
switch (event.getAction())
{
case KeyEvent.ACTION_DOWN:
action = NativeLibrary.ButtonState.PRESSED;
break;
case KeyEvent.ACTION_UP:
action = NativeLibrary.ButtonState.RELEASED;
break;
default:
return false;
}
InputDevice input = event.getDevice();
return NativeLibrary.onGamePadEvent(input.getDescriptor(), event.getKeyCode(), action);
// TODO
return false;
}
private void toggleControls()
@ -1271,36 +1258,8 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
return false;
}
if (((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0))
{
return super.dispatchGenericMotionEvent(event);
}
// Don't attempt to do anything if we are disconnecting a device.
if (event.getActionMasked() == MotionEvent.ACTION_CANCEL)
return true;
InputDevice input = event.getDevice();
List<InputDevice.MotionRange> motions = input.getMotionRanges();
for (InputDevice.MotionRange range : motions)
{
int axis = range.getAxis();
float origValue = event.getAxisValue(axis);
float value = ControllerMappingHelper.scaleAxis(input, axis, origValue);
// If the input is still in the "flat" area, that means it's really zero.
// This is used to compensate for imprecision in joysticks.
if (Math.abs(value) > range.getFlat())
{
NativeLibrary.onGamePadMoveEvent(input.getDescriptor(), axis, value);
}
else
{
NativeLibrary.onGamePadMoveEvent(input.getDescriptor(), axis, 0.0f);
}
}
return true;
// TODO
return false;
}
private void showSubMenu(SaveLoadStateFragment.SaveOrLoad saveOrLoad)

View File

@ -51,8 +51,6 @@
#include "DiscIO/ScrubbedBlob.h"
#include "DiscIO/Volume.h"
#include "InputCommon/ControllerInterface/Android/Android.h"
#include "InputCommon/ControllerInterface/Touch/ButtonManager.h"
#include "InputCommon/GCAdapter.h"
#include "UICommon/GameFile.h"
@ -293,19 +291,20 @@ Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunningAndUnpaused(JNIEnv*, jclas
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadEvent(
JNIEnv* env, jclass, jstring jDevice, jint Button, jint Action)
{
return ButtonManager::GamepadEvent(GetJString(env, jDevice), Button, Action);
// TODO
return JNI_FALSE;
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadMoveEvent(
JNIEnv* env, jclass, jstring jDevice, jint Axis, jfloat Value)
{
ButtonManager::GamepadAxisEvent(GetJString(env, jDevice), Axis, Value);
// TODO
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetMotionSensorsEnabled(
JNIEnv*, jclass, jboolean accelerometer_enabled, jboolean gyroscope_enabled)
{
ciface::Android::SetMotionSensorsEnabled(accelerometer_enabled, gyroscope_enabled);
// TODO
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv* env,
@ -583,8 +582,6 @@ static void Run(JNIEnv* env, std::unique_ptr<BootParameters>&& boot, bool riivol
if (BootManager::BootCore(std::move(boot), wsi))
{
ButtonManager::Init(SConfig::GetInstance().GetGameID());
static constexpr int WAIT_STEP = 25;
while (Core::GetState() == Core::State::Starting)
std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_STEP));
@ -604,7 +601,6 @@ static void Run(JNIEnv* env, std::unique_ptr<BootParameters>&& boot, bool riivol
s_game_metadata_is_valid = false;
Core::Shutdown();
ButtonManager::Shutdown();
host_identity_guard.unlock();
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(),