diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java index abd5e8cc2c..5f3c8f839f 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java @@ -234,30 +234,6 @@ public final class NativeLibrary // 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. * @@ -277,9 +253,6 @@ public final class NativeLibrary Rumble.checkRumble(padID, state); } - public static native void SetMotionSensorsEnabled(boolean accelerometerEnabled, - boolean gyroscopeEnabled); - /** * Gets the Dolphin version string. * diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java index fb839ed41a..18372b1d20 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java @@ -64,7 +64,6 @@ import org.dolphinemu.dolphinemu.utils.AfterDirectoryInitializationRunner; import org.dolphinemu.dolphinemu.utils.ControllerMappingHelper; import org.dolphinemu.dolphinemu.utils.FileBrowserHelper; import org.dolphinemu.dolphinemu.utils.IniFile; -import org.dolphinemu.dolphinemu.utils.MotionListener; import org.dolphinemu.dolphinemu.utils.Rumble; import org.dolphinemu.dolphinemu.utils.ThemeHelper; @@ -89,7 +88,6 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP private EmulationFragment mEmulationFragment; private SharedPreferences mPreferences; - private MotionListener mMotionListener; private Settings mSettings; @@ -359,8 +357,6 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP updateOrientation(); - mMotionListener = new MotionListener(this); - // Set these options now so that the SurfaceView the game renders into is the right size. enableFullscreenImmersive(); @@ -452,16 +448,12 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP } updateOrientation(); - - if (NativeLibrary.IsGameMetadataValid()) - updateMotionListener(); } @Override protected void onPause() { super.onPause(); - mMotionListener.disable(); } @Override @@ -481,19 +473,10 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP } setTitle(NativeLibrary.GetCurrentTitleDescription()); - updateMotionListener(); mEmulationFragment.refreshInputOverlay(); } - private void updateMotionListener() - { - if (NativeLibrary.IsEmulatingWii() && IntSetting.MAIN_MOTION_CONTROLS.getInt(mSettings) != 2) - mMotionListener.enable(); - else - mMotionListener.disable(); - } - @Override protected void onDestroy() { @@ -1063,8 +1046,6 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP { IntSetting.MAIN_MOTION_CONTROLS.setInt(mSettings, indexSelected); - updateMotionListener(); - updateWiimoteNewImuIr(indexSelected); NativeLibrary.ReloadWiimoteConfig(); }) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/MotionListener.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/MotionListener.java deleted file mode 100644 index 0086f3beb5..0000000000 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/MotionListener.java +++ /dev/null @@ -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; - } -} diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp index fd6ca47359..95297664db 100644 --- a/Source/Android/jni/MainAndroid.cpp +++ b/Source/Android/jni/MainAndroid.cpp @@ -288,25 +288,6 @@ Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunningAndUnpaused(JNIEnv*, jclas return static_cast(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, jclass) {