mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
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:
@@ -280,9 +280,6 @@ public final class NativeLibrary
|
||||
public static native void SetMotionSensorsEnabled(boolean accelerometerEnabled,
|
||||
boolean gyroscopeEnabled);
|
||||
|
||||
// Angle is in radians and should be non-negative
|
||||
public static native double GetInputRadiusAtAngle(int emu_pad_id, int stick, double angle);
|
||||
|
||||
/**
|
||||
* Gets the Dolphin version string.
|
||||
*
|
||||
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.dolphinemu.dolphinemu.features.input.model;
|
||||
|
||||
public final class InputOverrider
|
||||
{
|
||||
public static final class ControlId
|
||||
{
|
||||
public static final int GCPAD_A_BUTTON = 0;
|
||||
public static final int GCPAD_B_BUTTON = 1;
|
||||
public static final int GCPAD_X_BUTTON = 2;
|
||||
public static final int GCPAD_Y_BUTTON = 3;
|
||||
public static final int GCPAD_Z_BUTTON = 4;
|
||||
public static final int GCPAD_START_BUTTON = 5;
|
||||
public static final int GCPAD_DPAD_UP = 6;
|
||||
public static final int GCPAD_DPAD_DOWN = 7;
|
||||
public static final int GCPAD_DPAD_LEFT = 8;
|
||||
public static final int GCPAD_DPAD_RIGHT = 9;
|
||||
public static final int GCPAD_L_DIGITAL = 10;
|
||||
public static final int GCPAD_R_DIGITAL = 11;
|
||||
public static final int GCPAD_L_ANALOG = 12;
|
||||
public static final int GCPAD_R_ANALOG = 13;
|
||||
public static final int GCPAD_MAIN_STICK_X = 14;
|
||||
public static final int GCPAD_MAIN_STICK_Y = 15;
|
||||
public static final int GCPAD_C_STICK_X = 16;
|
||||
public static final int GCPAD_C_STICK_Y = 17;
|
||||
|
||||
public static final int WIIMOTE_A_BUTTON = 18;
|
||||
public static final int WIIMOTE_B_BUTTON = 19;
|
||||
public static final int WIIMOTE_ONE_BUTTON = 20;
|
||||
public static final int WIIMOTE_TWO_BUTTON = 21;
|
||||
public static final int WIIMOTE_PLUS_BUTTON = 22;
|
||||
public static final int WIIMOTE_MINUS_BUTTON = 23;
|
||||
public static final int WIIMOTE_HOME_BUTTON = 24;
|
||||
public static final int WIIMOTE_DPAD_UP = 25;
|
||||
public static final int WIIMOTE_DPAD_DOWN = 26;
|
||||
public static final int WIIMOTE_DPAD_LEFT = 27;
|
||||
public static final int WIIMOTE_DPAD_RIGHT = 28;
|
||||
public static final int WIIMOTE_IR_X = 29;
|
||||
public static final int WIIMOTE_IR_Y = 30;
|
||||
|
||||
public static final int NUNCHUK_C_BUTTON = 31;
|
||||
public static final int NUNCHUK_Z_BUTTON = 32;
|
||||
public static final int NUNCHUK_STICK_X = 33;
|
||||
public static final int NUNCHUK_STICK_Y = 34;
|
||||
|
||||
public static final int CLASSIC_A_BUTTON = 35;
|
||||
public static final int CLASSIC_B_BUTTON = 36;
|
||||
public static final int CLASSIC_X_BUTTON = 37;
|
||||
public static final int CLASSIC_Y_BUTTON = 38;
|
||||
public static final int CLASSIC_ZL_BUTTON = 39;
|
||||
public static final int CLASSIC_ZR_BUTTON = 40;
|
||||
public static final int CLASSIC_PLUS_BUTTON = 41;
|
||||
public static final int CLASSIC_MINUS_BUTTON = 42;
|
||||
public static final int CLASSIC_HOME_BUTTON = 43;
|
||||
public static final int CLASSIC_DPAD_UP = 44;
|
||||
public static final int CLASSIC_DPAD_DOWN = 45;
|
||||
public static final int CLASSIC_DPAD_LEFT = 46;
|
||||
public static final int CLASSIC_DPAD_RIGHT = 47;
|
||||
public static final int CLASSIC_L_DIGITAL = 48;
|
||||
public static final int CLASSIC_R_DIGITAL = 49;
|
||||
public static final int CLASSIC_L_ANALOG = 50;
|
||||
public static final int CLASSIC_R_ANALOG = 51;
|
||||
public static final int CLASSIC_LEFT_STICK_X = 52;
|
||||
public static final int CLASSIC_LEFT_STICK_Y = 53;
|
||||
public static final int CLASSIC_RIGHT_STICK_X = 54;
|
||||
public static final int CLASSIC_RIGHT_STICK_Y = 55;
|
||||
}
|
||||
|
||||
public static native void registerGameCube(int controllerIndex);
|
||||
|
||||
public static native void registerWii(int controllerIndex);
|
||||
|
||||
public static native void unregisterGameCube(int controllerIndex);
|
||||
|
||||
public static native void unregisterWii(int controllerIndex);
|
||||
|
||||
public static native void setControlState(int controllerIndex, int control, double state);
|
||||
|
||||
public static native void clearControlState(int controllerIndex, int control);
|
||||
|
||||
// Angle is in radians and should be non-negative
|
||||
public static native double getGateRadiusAtAngle(int emuPadId, int stick, double angle);
|
||||
}
|
||||
+1
-2
@@ -40,8 +40,7 @@ public enum IntSetting implements AbstractIntSetting
|
||||
InputOverlayPointer.MODE_FOLLOW),
|
||||
|
||||
MAIN_DOUBLE_TAP_BUTTON(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
|
||||
"DoubleTapButton",
|
||||
InputOverlayPointer.DOUBLE_TAP_OPTIONS.get(InputOverlayPointer.DOUBLE_TAP_A)),
|
||||
"DoubleTapButton", NativeLibrary.ButtonType.WIIMOTE_BUTTON_A),
|
||||
|
||||
SYSCONF_LANGUAGE(Settings.FILE_SYSCONF, "IPL", "LNG", 0x01),
|
||||
SYSCONF_SOUND_MODE(Settings.FILE_SYSCONF, "IPL", "SND", 0x01),
|
||||
|
||||
+9
@@ -138,6 +138,15 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy()
|
||||
{
|
||||
if (mInputOverlay != null)
|
||||
mInputOverlay.onDestroy();
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach()
|
||||
{
|
||||
|
||||
+191
-94
File diff suppressed because it is too large
Load Diff
+16
-10
@@ -18,8 +18,9 @@ import android.view.MotionEvent;
|
||||
*/
|
||||
public final class InputOverlayDrawableButton
|
||||
{
|
||||
// The ID identifying what type of button this Drawable represents.
|
||||
private int mButtonType;
|
||||
// The legacy ID identifying what type of button this Drawable represents.
|
||||
private int mLegacyId;
|
||||
private int mControl;
|
||||
private int mTrackId;
|
||||
private int mPreviousTouchX, mPreviousTouchY;
|
||||
private int mControlPositionX, mControlPositionY;
|
||||
@@ -35,28 +36,33 @@ public final class InputOverlayDrawableButton
|
||||
* @param res {@link Resources} instance.
|
||||
* @param defaultStateBitmap {@link Bitmap} to use with the default state Drawable.
|
||||
* @param pressedStateBitmap {@link Bitmap} to use with the pressed state Drawable.
|
||||
* @param buttonType Identifier for this type of button.
|
||||
* @param legacyId Legacy identifier (ButtonType) for this type of button.
|
||||
* @param control Control ID for this type of button.
|
||||
*/
|
||||
public InputOverlayDrawableButton(Resources res, Bitmap defaultStateBitmap,
|
||||
Bitmap pressedStateBitmap, int buttonType)
|
||||
Bitmap pressedStateBitmap, int legacyId, int control)
|
||||
{
|
||||
mTrackId = -1;
|
||||
mDefaultStateBitmap = new BitmapDrawable(res, defaultStateBitmap);
|
||||
mPressedStateBitmap = new BitmapDrawable(res, pressedStateBitmap);
|
||||
mButtonType = buttonType;
|
||||
mLegacyId = legacyId;
|
||||
mControl = control;
|
||||
|
||||
mWidth = mDefaultStateBitmap.getIntrinsicWidth();
|
||||
mHeight = mDefaultStateBitmap.getIntrinsicHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets this InputOverlayDrawableButton's button ID.
|
||||
*
|
||||
* @return this InputOverlayDrawableButton's button ID.
|
||||
* Gets this InputOverlayDrawableButton's legacy button ID.
|
||||
*/
|
||||
public int getId()
|
||||
public int getLegacyId()
|
||||
{
|
||||
return mButtonType;
|
||||
return mLegacyId;
|
||||
}
|
||||
|
||||
public int getControl()
|
||||
{
|
||||
return mControl;
|
||||
}
|
||||
|
||||
public void setTrackId(int trackId)
|
||||
|
||||
+26
-23
@@ -18,8 +18,9 @@ import android.view.MotionEvent;
|
||||
*/
|
||||
public final class InputOverlayDrawableDpad
|
||||
{
|
||||
// The ID identifying what type of button this Drawable represents.
|
||||
private int[] mButtonType = new int[4];
|
||||
// The legacy ID identifying what type of button this Drawable represents.
|
||||
private int mLegacyId;
|
||||
private int[] mControls = new int[4];
|
||||
private int mTrackId;
|
||||
private int mPreviousTouchX, mPreviousTouchY;
|
||||
private int mControlPositionX, mControlPositionY;
|
||||
@@ -47,17 +48,15 @@ public final class InputOverlayDrawableDpad
|
||||
* @param defaultStateBitmap {@link Bitmap} of the default state.
|
||||
* @param pressedOneDirectionStateBitmap {@link Bitmap} of the pressed state in one direction.
|
||||
* @param pressedTwoDirectionsStateBitmap {@link Bitmap} of the pressed state in two direction.
|
||||
* @param buttonUp Identifier for the up button.
|
||||
* @param buttonDown Identifier for the down button.
|
||||
* @param buttonLeft Identifier for the left button.
|
||||
* @param buttonRight Identifier for the right button.
|
||||
* @param legacyId Legacy identifier (ButtonType) for the up button.
|
||||
* @param upControl Control identifier for the up button.
|
||||
* @param downControl Control identifier for the down button.
|
||||
* @param leftControl Control identifier for the left button.
|
||||
* @param rightControl Control identifier for the right button.
|
||||
*/
|
||||
public InputOverlayDrawableDpad(Resources res,
|
||||
Bitmap defaultStateBitmap,
|
||||
Bitmap pressedOneDirectionStateBitmap,
|
||||
Bitmap pressedTwoDirectionsStateBitmap,
|
||||
int buttonUp, int buttonDown,
|
||||
int buttonLeft, int buttonRight)
|
||||
public InputOverlayDrawableDpad(Resources res, Bitmap defaultStateBitmap,
|
||||
Bitmap pressedOneDirectionStateBitmap, Bitmap pressedTwoDirectionsStateBitmap,
|
||||
int legacyId, int upControl, int downControl, int leftControl, int rightControl)
|
||||
{
|
||||
mTrackId = -1;
|
||||
mDefaultStateBitmap = new BitmapDrawable(res, defaultStateBitmap);
|
||||
@@ -67,10 +66,11 @@ public final class InputOverlayDrawableDpad
|
||||
mWidth = mDefaultStateBitmap.getIntrinsicWidth();
|
||||
mHeight = mDefaultStateBitmap.getIntrinsicHeight();
|
||||
|
||||
mButtonType[0] = buttonUp;
|
||||
mButtonType[1] = buttonDown;
|
||||
mButtonType[2] = buttonLeft;
|
||||
mButtonType[3] = buttonRight;
|
||||
mLegacyId = legacyId;
|
||||
mControls[0] = upControl;
|
||||
mControls[1] = downControl;
|
||||
mControls[2] = leftControl;
|
||||
mControls[3] = rightControl;
|
||||
}
|
||||
|
||||
public void draw(Canvas canvas)
|
||||
@@ -127,14 +127,17 @@ public final class InputOverlayDrawableDpad
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets one of the InputOverlayDrawableDpad's button IDs.
|
||||
*
|
||||
* @return the requested InputOverlayDrawableDpad's button ID.
|
||||
*/
|
||||
public int getId(int direction)
|
||||
public int getLegacyId()
|
||||
{
|
||||
return mButtonType[direction];
|
||||
return mLegacyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets one of the InputOverlayDrawableDpad's control IDs.
|
||||
*/
|
||||
public int getControl(int direction)
|
||||
{
|
||||
return mControls[direction];
|
||||
}
|
||||
|
||||
public void setTrackId(int trackId)
|
||||
|
||||
+40
-35
@@ -12,7 +12,7 @@ import android.graphics.Rect;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||
import org.dolphinemu.dolphinemu.features.input.model.InputOverrider;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
|
||||
|
||||
/**
|
||||
@@ -21,10 +21,12 @@ import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
|
||||
*/
|
||||
public final class InputOverlayDrawableJoystick
|
||||
{
|
||||
private final int[] axisIDs = {0, 0, 0, 0};
|
||||
private final float[] axises = {0f, 0f};
|
||||
private float mCurrentX = 0.0f;
|
||||
private float mCurrentY = 0.0f;
|
||||
private int trackId = -1;
|
||||
private final int mJoystickType;
|
||||
private final int mJoystickLegacyId;
|
||||
private final int mJoystickXControl;
|
||||
private final int mJoystickYControl;
|
||||
private int mControlPositionX, mControlPositionY;
|
||||
private int mPreviousTouchX, mPreviousTouchY;
|
||||
private final int mWidth;
|
||||
@@ -47,16 +49,17 @@ public final class InputOverlayDrawableJoystick
|
||||
* @param bitmapInnerPressed {@link Bitmap} which represents the pressed inner movable part of the joystick.
|
||||
* @param rectOuter {@link Rect} which represents the outer joystick bounds.
|
||||
* @param rectInner {@link Rect} which represents the inner joystick bounds.
|
||||
* @param joystick Identifier for which joystick this is.
|
||||
* @param legacyId Legacy identifier (ButtonType) for which joystick this is.
|
||||
* @param xControl The control which the x value of the joystick will be written to.
|
||||
* @param yControl The control which the y value of the joystick will be written to.
|
||||
*/
|
||||
public InputOverlayDrawableJoystick(Resources res, Bitmap bitmapOuter, Bitmap bitmapInnerDefault,
|
||||
Bitmap bitmapInnerPressed, Rect rectOuter, Rect rectInner, int joystick)
|
||||
Bitmap bitmapInnerPressed, Rect rectOuter, Rect rectInner, int legacyId, int xControl,
|
||||
int yControl)
|
||||
{
|
||||
axisIDs[0] = joystick + 1;
|
||||
axisIDs[1] = joystick + 2;
|
||||
axisIDs[2] = joystick + 3;
|
||||
axisIDs[3] = joystick + 4;
|
||||
mJoystickType = joystick;
|
||||
mJoystickLegacyId = legacyId;
|
||||
mJoystickXControl = xControl;
|
||||
mJoystickYControl = yControl;
|
||||
|
||||
mOuterBitmap = new BitmapDrawable(res, bitmapOuter);
|
||||
mDefaultStateInnerBitmap = new BitmapDrawable(res, bitmapInnerDefault);
|
||||
@@ -76,13 +79,13 @@ public final class InputOverlayDrawableJoystick
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets this InputOverlayDrawableJoystick's button ID.
|
||||
* Gets this InputOverlayDrawableJoystick's legacy ID.
|
||||
*
|
||||
* @return this InputOverlayDrawableJoystick's button ID.
|
||||
* @return this InputOverlayDrawableJoystick's legacy ID.
|
||||
*/
|
||||
public int getId()
|
||||
public int getLegacyId()
|
||||
{
|
||||
return mJoystickType;
|
||||
return mJoystickLegacyId;
|
||||
}
|
||||
|
||||
public void draw(Canvas canvas)
|
||||
@@ -125,7 +128,7 @@ public final class InputOverlayDrawableJoystick
|
||||
{
|
||||
pressed = true;
|
||||
mPressedState = false;
|
||||
axises[0] = axises[1] = 0.0f;
|
||||
mCurrentX = mCurrentY = 0.0f;
|
||||
mOuterBitmap.setAlpha(mOpacity);
|
||||
mBoundsBoxBitmap.setAlpha(0);
|
||||
setVirtBounds(new Rect(mOrigBounds.left, mOrigBounds.top, mOrigBounds.right,
|
||||
@@ -153,10 +156,8 @@ public final class InputOverlayDrawableJoystick
|
||||
maxX -= getVirtBounds().centerX();
|
||||
touchY -= getVirtBounds().centerY();
|
||||
maxY -= getVirtBounds().centerY();
|
||||
final float AxisX = touchX / maxX;
|
||||
final float AxisY = touchY / maxY;
|
||||
axises[0] = AxisY;
|
||||
axises[1] = AxisX;
|
||||
mCurrentX = touchX / maxX;
|
||||
mCurrentY = touchY / maxY;
|
||||
|
||||
SetInnerBounds();
|
||||
}
|
||||
@@ -193,36 +194,40 @@ public final class InputOverlayDrawableJoystick
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public float[] getAxisValues()
|
||||
public float getX()
|
||||
{
|
||||
float[] joyaxises = {0f, 0f, 0f, 0f};
|
||||
joyaxises[1] = Math.min(axises[0], 1.0f);
|
||||
joyaxises[0] = Math.min(axises[0], 0.0f);
|
||||
joyaxises[3] = Math.min(axises[1], 1.0f);
|
||||
joyaxises[2] = Math.min(axises[1], 0.0f);
|
||||
return joyaxises;
|
||||
return mCurrentX;
|
||||
}
|
||||
|
||||
public int[] getAxisIDs()
|
||||
public float getY()
|
||||
{
|
||||
return axisIDs;
|
||||
return mCurrentY;
|
||||
}
|
||||
|
||||
public int getXControl()
|
||||
{
|
||||
return mJoystickXControl;
|
||||
}
|
||||
|
||||
public int getYControl()
|
||||
{
|
||||
return mJoystickYControl;
|
||||
}
|
||||
|
||||
private void SetInnerBounds()
|
||||
{
|
||||
double y = axises[0];
|
||||
double x = axises[1];
|
||||
double x = mCurrentX;
|
||||
double y = mCurrentY;
|
||||
|
||||
double angle = Math.atan2(y, x) + Math.PI + Math.PI;
|
||||
double radius = Math.hypot(y, x);
|
||||
double maxRadius = NativeLibrary.GetInputRadiusAtAngle(0, mJoystickType, angle);
|
||||
double maxRadius = InputOverrider.getGateRadiusAtAngle(0, mJoystickXControl, angle);
|
||||
if (radius > maxRadius)
|
||||
{
|
||||
y = maxRadius * Math.sin(angle);
|
||||
x = maxRadius * Math.cos(angle);
|
||||
axises[0] = (float) y;
|
||||
axises[1] = (float) x;
|
||||
mCurrentY = (float) y;
|
||||
mCurrentX = (float) x;
|
||||
}
|
||||
|
||||
int pixelX = getVirtBounds().centerX() + (int) (x * (getVirtBounds().width() / 2));
|
||||
|
||||
+26
-30
@@ -7,22 +7,20 @@ import android.os.Handler;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||
import org.dolphinemu.dolphinemu.features.input.model.InputOverrider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class InputOverlayPointer
|
||||
{
|
||||
public static final int DOUBLE_TAP_A = 0;
|
||||
public static final int DOUBLE_TAP_B = 1;
|
||||
public static final int DOUBLE_TAP_2 = 2;
|
||||
public static final int DOUBLE_TAP_CLASSIC_A = 3;
|
||||
|
||||
public static final int MODE_DISABLED = 0;
|
||||
public static final int MODE_FOLLOW = 1;
|
||||
public static final int MODE_DRAG = 2;
|
||||
|
||||
private final float[] axes = {0f, 0f};
|
||||
private final float[] oldaxes = {0f, 0f};
|
||||
private float mCurrentX = 0.0f;
|
||||
private float mCurrentY = 0.0f;
|
||||
private float mOldX = 0.0f;
|
||||
private float mOldY = 0.0f;
|
||||
|
||||
private float mGameCenterX;
|
||||
private float mGameCenterY;
|
||||
@@ -36,7 +34,7 @@ public class InputOverlayPointer
|
||||
private boolean mRecenter;
|
||||
|
||||
private boolean doubleTap = false;
|
||||
private int doubleTapButton;
|
||||
private int mDoubleTapControl;
|
||||
private int trackId = -1;
|
||||
|
||||
public static ArrayList<Integer> DOUBLE_TAP_OPTIONS = new ArrayList<>();
|
||||
@@ -49,9 +47,9 @@ public class InputOverlayPointer
|
||||
DOUBLE_TAP_OPTIONS.add(NativeLibrary.ButtonType.CLASSIC_BUTTON_A);
|
||||
}
|
||||
|
||||
public InputOverlayPointer(Rect surfacePosition, int button, int mode, boolean recenter)
|
||||
public InputOverlayPointer(Rect surfacePosition, int doubleTapControl, int mode, boolean recenter)
|
||||
{
|
||||
doubleTapButton = button;
|
||||
mDoubleTapControl = doubleTapControl;
|
||||
mMode = mode;
|
||||
mRecenter = recenter;
|
||||
|
||||
@@ -112,15 +110,15 @@ public class InputOverlayPointer
|
||||
|
||||
if (mMode == MODE_FOLLOW)
|
||||
{
|
||||
axes[0] = (event.getY(event.findPointerIndex(trackId)) - mGameCenterY) * mGameHeightHalfInv;
|
||||
axes[1] = (event.getX(event.findPointerIndex(trackId)) - mGameCenterX) * mGameWidthHalfInv;
|
||||
mCurrentX = (event.getX(event.findPointerIndex(trackId)) - mGameCenterX) * mGameWidthHalfInv;
|
||||
mCurrentY = (event.getY(event.findPointerIndex(trackId)) - mGameCenterY) * mGameHeightHalfInv;
|
||||
}
|
||||
else if (mMode == MODE_DRAG)
|
||||
{
|
||||
axes[0] = oldaxes[0] +
|
||||
(event.getY(event.findPointerIndex(trackId)) - mTouchStartY) * mGameHeightHalfInv;
|
||||
axes[1] = oldaxes[1] +
|
||||
mCurrentX = mOldX +
|
||||
(event.getX(event.findPointerIndex(trackId)) - mTouchStartX) * mGameWidthHalfInv;
|
||||
mCurrentY = mOldY +
|
||||
(event.getY(event.findPointerIndex(trackId)) - mTouchStartY) * mGameHeightHalfInv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,11 +128,9 @@ public class InputOverlayPointer
|
||||
{
|
||||
if (doubleTap)
|
||||
{
|
||||
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice,
|
||||
doubleTapButton, NativeLibrary.ButtonState.PRESSED);
|
||||
new Handler()
|
||||
.postDelayed(() -> NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice,
|
||||
doubleTapButton, NativeLibrary.ButtonState.RELEASED), 50);
|
||||
InputOverrider.setControlState(0, mDoubleTapControl, 1.0);
|
||||
new Handler().postDelayed(() -> InputOverrider.setControlState(0, mDoubleTapControl, 0.0),
|
||||
50);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -146,23 +142,23 @@ public class InputOverlayPointer
|
||||
|
||||
private void updateOldAxes()
|
||||
{
|
||||
oldaxes[0] = axes[0];
|
||||
oldaxes[1] = axes[1];
|
||||
mOldX = mCurrentX;
|
||||
mOldY = mCurrentY;
|
||||
}
|
||||
|
||||
private void reset()
|
||||
{
|
||||
axes[0] = axes[1] = oldaxes[0] = oldaxes[1] = 0f;
|
||||
mCurrentX = mCurrentY = mOldX = mOldY = 0.0f;
|
||||
}
|
||||
|
||||
public float[] getAxisValues()
|
||||
public float getX()
|
||||
{
|
||||
float[] iraxes = {0f, 0f, 0f, 0f};
|
||||
iraxes[1] = axes[0];
|
||||
iraxes[0] = axes[0];
|
||||
iraxes[3] = axes[1];
|
||||
iraxes[2] = axes[1];
|
||||
return iraxes;
|
||||
return mCurrentX;
|
||||
}
|
||||
|
||||
public float getY()
|
||||
{
|
||||
return mCurrentY;
|
||||
}
|
||||
|
||||
public void setMode(int mode)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user