Android: Remove old motion input implementation
This commit is contained in:
parent
0150f521f7
commit
9e7a2ee0fb
|
@ -234,30 +234,6 @@ public final class NativeLibrary
|
||||||
// Disallows instantiation.
|
// Disallows instantiation.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Default touchscreen device
|
|
||||||
*/
|
|
||||||
public static final String TouchScreenDevice = "Touchscreen";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles button press events for a gamepad.
|
|
||||||
*
|
|
||||||
* @param Device The input descriptor of the gamepad.
|
|
||||||
* @param Button Key code identifying which button was pressed.
|
|
||||||
* @param Action Mask identifying which action is happening (button pressed down, or button released).
|
|
||||||
* @return If we handled the button press.
|
|
||||||
*/
|
|
||||||
public static native boolean onGamePadEvent(String Device, int Button, int Action);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles gamepad movement events.
|
|
||||||
*
|
|
||||||
* @param Device The device ID of the gamepad.
|
|
||||||
* @param Axis The axis ID
|
|
||||||
* @param Value The value of the axis represented by the given ID.
|
|
||||||
*/
|
|
||||||
public static native void onGamePadMoveEvent(String Device, int Axis, float Value);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rumble sent from native. Currently only supports phone rumble.
|
* Rumble sent from native. Currently only supports phone rumble.
|
||||||
*
|
*
|
||||||
|
@ -277,9 +253,6 @@ public final class NativeLibrary
|
||||||
Rumble.checkRumble(padID, state);
|
Rumble.checkRumble(padID, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static native void SetMotionSensorsEnabled(boolean accelerometerEnabled,
|
|
||||||
boolean gyroscopeEnabled);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Dolphin version string.
|
* Gets the Dolphin version string.
|
||||||
*
|
*
|
||||||
|
|
|
@ -64,7 +64,6 @@ import org.dolphinemu.dolphinemu.utils.AfterDirectoryInitializationRunner;
|
||||||
import org.dolphinemu.dolphinemu.utils.ControllerMappingHelper;
|
import org.dolphinemu.dolphinemu.utils.ControllerMappingHelper;
|
||||||
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
|
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
|
||||||
import org.dolphinemu.dolphinemu.utils.IniFile;
|
import org.dolphinemu.dolphinemu.utils.IniFile;
|
||||||
import org.dolphinemu.dolphinemu.utils.MotionListener;
|
|
||||||
import org.dolphinemu.dolphinemu.utils.Rumble;
|
import org.dolphinemu.dolphinemu.utils.Rumble;
|
||||||
import org.dolphinemu.dolphinemu.utils.ThemeHelper;
|
import org.dolphinemu.dolphinemu.utils.ThemeHelper;
|
||||||
|
|
||||||
|
@ -89,7 +88,6 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
||||||
private EmulationFragment mEmulationFragment;
|
private EmulationFragment mEmulationFragment;
|
||||||
|
|
||||||
private SharedPreferences mPreferences;
|
private SharedPreferences mPreferences;
|
||||||
private MotionListener mMotionListener;
|
|
||||||
|
|
||||||
private Settings mSettings;
|
private Settings mSettings;
|
||||||
|
|
||||||
|
@ -359,8 +357,6 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
||||||
|
|
||||||
updateOrientation();
|
updateOrientation();
|
||||||
|
|
||||||
mMotionListener = new MotionListener(this);
|
|
||||||
|
|
||||||
// Set these options now so that the SurfaceView the game renders into is the right size.
|
// Set these options now so that the SurfaceView the game renders into is the right size.
|
||||||
enableFullscreenImmersive();
|
enableFullscreenImmersive();
|
||||||
|
|
||||||
|
@ -452,16 +448,12 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
||||||
}
|
}
|
||||||
|
|
||||||
updateOrientation();
|
updateOrientation();
|
||||||
|
|
||||||
if (NativeLibrary.IsGameMetadataValid())
|
|
||||||
updateMotionListener();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause()
|
protected void onPause()
|
||||||
{
|
{
|
||||||
super.onPause();
|
super.onPause();
|
||||||
mMotionListener.disable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -481,19 +473,10 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
||||||
}
|
}
|
||||||
|
|
||||||
setTitle(NativeLibrary.GetCurrentTitleDescription());
|
setTitle(NativeLibrary.GetCurrentTitleDescription());
|
||||||
updateMotionListener();
|
|
||||||
|
|
||||||
mEmulationFragment.refreshInputOverlay();
|
mEmulationFragment.refreshInputOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMotionListener()
|
|
||||||
{
|
|
||||||
if (NativeLibrary.IsEmulatingWii() && IntSetting.MAIN_MOTION_CONTROLS.getInt(mSettings) != 2)
|
|
||||||
mMotionListener.enable();
|
|
||||||
else
|
|
||||||
mMotionListener.disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy()
|
protected void onDestroy()
|
||||||
{
|
{
|
||||||
|
@ -1063,8 +1046,6 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
||||||
{
|
{
|
||||||
IntSetting.MAIN_MOTION_CONTROLS.setInt(mSettings, indexSelected);
|
IntSetting.MAIN_MOTION_CONTROLS.setInt(mSettings, indexSelected);
|
||||||
|
|
||||||
updateMotionListener();
|
|
||||||
|
|
||||||
updateWiimoteNewImuIr(indexSelected);
|
updateWiimoteNewImuIr(indexSelected);
|
||||||
NativeLibrary.ReloadWiimoteConfig();
|
NativeLibrary.ReloadWiimoteConfig();
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,128 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
package org.dolphinemu.dolphinemu.utils;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.hardware.Sensor;
|
|
||||||
import android.hardware.SensorEvent;
|
|
||||||
import android.hardware.SensorEventListener;
|
|
||||||
import android.hardware.SensorManager;
|
|
||||||
import android.view.Surface;
|
|
||||||
|
|
||||||
import org.dolphinemu.dolphinemu.NativeLibrary;
|
|
||||||
import org.dolphinemu.dolphinemu.NativeLibrary.ButtonType;
|
|
||||||
|
|
||||||
public class MotionListener implements SensorEventListener
|
|
||||||
{
|
|
||||||
private final Activity mActivity;
|
|
||||||
private final SensorManager mSensorManager;
|
|
||||||
private final Sensor mAccelSensor;
|
|
||||||
private final Sensor mGyroSensor;
|
|
||||||
|
|
||||||
private boolean mEnabled = false;
|
|
||||||
|
|
||||||
// The same sampling period as for Wii Remotes
|
|
||||||
private static final int SAMPLING_PERIOD_US = 1000000 / 200;
|
|
||||||
|
|
||||||
public MotionListener(Activity activity)
|
|
||||||
{
|
|
||||||
mActivity = activity;
|
|
||||||
mSensorManager = (SensorManager) activity.getSystemService(Context.SENSOR_SERVICE);
|
|
||||||
mAccelSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
|
||||||
mGyroSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSensorChanged(SensorEvent sensorEvent)
|
|
||||||
{
|
|
||||||
float x, y;
|
|
||||||
float z = sensorEvent.values[2];
|
|
||||||
int orientation = mActivity.getWindowManager().getDefaultDisplay().getRotation();
|
|
||||||
switch (orientation)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case Surface.ROTATION_0:
|
|
||||||
x = -sensorEvent.values[0];
|
|
||||||
y = -sensorEvent.values[1];
|
|
||||||
break;
|
|
||||||
case Surface.ROTATION_90:
|
|
||||||
x = sensorEvent.values[1];
|
|
||||||
y = -sensorEvent.values[0];
|
|
||||||
break;
|
|
||||||
case Surface.ROTATION_180:
|
|
||||||
x = sensorEvent.values[0];
|
|
||||||
y = sensorEvent.values[1];
|
|
||||||
break;
|
|
||||||
case Surface.ROTATION_270:
|
|
||||||
x = -sensorEvent.values[1];
|
|
||||||
y = sensorEvent.values[0];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sensorEvent.sensor == mAccelSensor)
|
|
||||||
{
|
|
||||||
NativeLibrary.onGamePadMoveEvent(NativeLibrary.TouchScreenDevice,
|
|
||||||
ButtonType.WIIMOTE_ACCEL_LEFT, x);
|
|
||||||
NativeLibrary.onGamePadMoveEvent(NativeLibrary.TouchScreenDevice,
|
|
||||||
ButtonType.WIIMOTE_ACCEL_RIGHT, x);
|
|
||||||
NativeLibrary.onGamePadMoveEvent(NativeLibrary.TouchScreenDevice,
|
|
||||||
ButtonType.WIIMOTE_ACCEL_FORWARD, y);
|
|
||||||
NativeLibrary.onGamePadMoveEvent(NativeLibrary.TouchScreenDevice,
|
|
||||||
ButtonType.WIIMOTE_ACCEL_BACKWARD, y);
|
|
||||||
NativeLibrary.onGamePadMoveEvent(NativeLibrary.TouchScreenDevice,
|
|
||||||
ButtonType.WIIMOTE_ACCEL_UP, z);
|
|
||||||
NativeLibrary.onGamePadMoveEvent(NativeLibrary.TouchScreenDevice,
|
|
||||||
ButtonType.WIIMOTE_ACCEL_DOWN, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sensorEvent.sensor == mGyroSensor)
|
|
||||||
{
|
|
||||||
NativeLibrary.onGamePadMoveEvent(NativeLibrary.TouchScreenDevice,
|
|
||||||
ButtonType.WIIMOTE_GYRO_PITCH_UP, x);
|
|
||||||
NativeLibrary.onGamePadMoveEvent(NativeLibrary.TouchScreenDevice,
|
|
||||||
ButtonType.WIIMOTE_GYRO_PITCH_DOWN, x);
|
|
||||||
NativeLibrary.onGamePadMoveEvent(NativeLibrary.TouchScreenDevice,
|
|
||||||
ButtonType.WIIMOTE_GYRO_ROLL_LEFT, y);
|
|
||||||
NativeLibrary.onGamePadMoveEvent(NativeLibrary.TouchScreenDevice,
|
|
||||||
ButtonType.WIIMOTE_GYRO_ROLL_RIGHT, y);
|
|
||||||
NativeLibrary.onGamePadMoveEvent(NativeLibrary.TouchScreenDevice,
|
|
||||||
ButtonType.WIIMOTE_GYRO_YAW_LEFT, z);
|
|
||||||
NativeLibrary.onGamePadMoveEvent(NativeLibrary.TouchScreenDevice,
|
|
||||||
ButtonType.WIIMOTE_GYRO_YAW_RIGHT, z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAccuracyChanged(Sensor sensor, int i)
|
|
||||||
{
|
|
||||||
// We don't care about this
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enable()
|
|
||||||
{
|
|
||||||
if (mEnabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (mAccelSensor != null)
|
|
||||||
mSensorManager.registerListener(this, mAccelSensor, SAMPLING_PERIOD_US);
|
|
||||||
if (mGyroSensor != null)
|
|
||||||
mSensorManager.registerListener(this, mGyroSensor, SAMPLING_PERIOD_US);
|
|
||||||
|
|
||||||
NativeLibrary.SetMotionSensorsEnabled(mAccelSensor != null, mGyroSensor != null);
|
|
||||||
|
|
||||||
mEnabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void disable()
|
|
||||||
{
|
|
||||||
if (!mEnabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mSensorManager.unregisterListener(this);
|
|
||||||
|
|
||||||
NativeLibrary.SetMotionSensorsEnabled(false, false);
|
|
||||||
|
|
||||||
mEnabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -288,25 +288,6 @@ Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunningAndUnpaused(JNIEnv*, jclas
|
||||||
return static_cast<jboolean>(Core::GetState() == Core::State::Running);
|
return static_cast<jboolean>(Core::GetState() == Core::State::Running);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadEvent(
|
|
||||||
JNIEnv* env, jclass, jstring jDevice, jint Button, jint Action)
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadMoveEvent(
|
|
||||||
JNIEnv* env, jclass, jstring jDevice, jint Axis, jfloat Value)
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetMotionSensorsEnabled(
|
|
||||||
JNIEnv*, jclass, jboolean accelerometer_enabled, jboolean gyroscope_enabled)
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv* env,
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv* env,
|
||||||
jclass)
|
jclass)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue