mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Merge pull request #9624 from JosJuice/input-override
Add new "input override" system for TAS input and Android touch controls
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)
|
||||
{
|
||||
|
||||
@@ -36,62 +36,47 @@ static const u16 trigger_bitmasks[] = {
|
||||
static const u16 dpad_bitmasks[] = {PAD_BUTTON_UP, PAD_BUTTON_DOWN, PAD_BUTTON_LEFT,
|
||||
PAD_BUTTON_RIGHT};
|
||||
|
||||
static const char* const named_buttons[] = {"A", "B", "X", "Y", "Z", "Start"};
|
||||
|
||||
static const char* const named_triggers[] = {
|
||||
// i18n: The left trigger button (labeled L on real controllers)
|
||||
_trans("L"),
|
||||
// i18n: The right trigger button (labeled R on real controllers)
|
||||
_trans("R"),
|
||||
// i18n: The left trigger button (labeled L on real controllers) used as an analog input
|
||||
_trans("L-Analog"),
|
||||
// i18n: The right trigger button (labeled R on real controllers) used as an analog input
|
||||
_trans("R-Analog")};
|
||||
|
||||
GCPad::GCPad(const unsigned int index) : m_index(index)
|
||||
{
|
||||
// buttons
|
||||
groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons")));
|
||||
for (const char* named_button : named_buttons)
|
||||
groups.emplace_back(m_buttons = new ControllerEmu::Buttons(BUTTONS_GROUP));
|
||||
for (const char* named_button : {A_BUTTON, B_BUTTON, X_BUTTON, Y_BUTTON, Z_BUTTON})
|
||||
{
|
||||
const bool is_start = named_button == std::string("Start");
|
||||
const ControllerEmu::Translatability translate =
|
||||
is_start ? ControllerEmu::Translate : ControllerEmu::DoNotTranslate;
|
||||
// i18n: The START/PAUSE button on GameCube controllers
|
||||
std::string ui_name = is_start ? _trans("START") : named_button;
|
||||
m_buttons->AddInput(translate, named_button, std::move(ui_name));
|
||||
m_buttons->AddInput(ControllerEmu::DoNotTranslate, named_button);
|
||||
}
|
||||
// i18n: The START/PAUSE button on GameCube controllers
|
||||
m_buttons->AddInput(ControllerEmu::Translate, START_BUTTON, _trans("START"));
|
||||
|
||||
// sticks
|
||||
groups.emplace_back(m_main_stick = new ControllerEmu::OctagonAnalogStick(
|
||||
"Main Stick", _trans("Control Stick"), MAIN_STICK_GATE_RADIUS));
|
||||
MAIN_STICK_GROUP, _trans("Control Stick"), MAIN_STICK_GATE_RADIUS));
|
||||
groups.emplace_back(m_c_stick = new ControllerEmu::OctagonAnalogStick(
|
||||
"C-Stick", _trans("C Stick"), C_STICK_GATE_RADIUS));
|
||||
C_STICK_GROUP, _trans("C Stick"), C_STICK_GATE_RADIUS));
|
||||
|
||||
// triggers
|
||||
groups.emplace_back(m_triggers = new ControllerEmu::MixedTriggers(_trans("Triggers")));
|
||||
for (const char* named_trigger : named_triggers)
|
||||
groups.emplace_back(m_triggers = new ControllerEmu::MixedTriggers(TRIGGERS_GROUP));
|
||||
for (const char* named_trigger : {L_DIGITAL, R_DIGITAL, L_ANALOG, R_ANALOG})
|
||||
{
|
||||
m_triggers->AddInput(ControllerEmu::Translate, named_trigger);
|
||||
}
|
||||
|
||||
// rumble
|
||||
groups.emplace_back(m_rumble = new ControllerEmu::ControlGroup(_trans("Rumble")));
|
||||
groups.emplace_back(m_rumble = new ControllerEmu::ControlGroup(RUMBLE_GROUP));
|
||||
m_rumble->AddOutput(ControllerEmu::Translate, _trans("Motor"));
|
||||
|
||||
// Microphone
|
||||
groups.emplace_back(m_mic = new ControllerEmu::Buttons(_trans("Microphone")));
|
||||
groups.emplace_back(m_mic = new ControllerEmu::Buttons(MIC_GROUP));
|
||||
m_mic->AddInput(ControllerEmu::Translate, _trans("Button"));
|
||||
|
||||
// dpad
|
||||
groups.emplace_back(m_dpad = new ControllerEmu::Buttons(_trans("D-Pad")));
|
||||
groups.emplace_back(m_dpad = new ControllerEmu::Buttons(DPAD_GROUP));
|
||||
for (const char* named_direction : named_directions)
|
||||
{
|
||||
m_dpad->AddInput(ControllerEmu::Translate, named_direction);
|
||||
}
|
||||
|
||||
// options
|
||||
groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options")));
|
||||
groups.emplace_back(m_options = new ControllerEmu::ControlGroup(OPTIONS_GROUP));
|
||||
m_options->AddSetting(
|
||||
&m_always_connected_setting,
|
||||
// i18n: Treat a controller as always being connected regardless of what
|
||||
@@ -138,14 +123,15 @@ GCPadStatus GCPad::GetInput() const
|
||||
const auto lock = GetStateLock();
|
||||
GCPadStatus pad = {};
|
||||
|
||||
if (!(m_always_connected_setting.GetValue() || IsDefaultDeviceConnected()))
|
||||
if (!(m_always_connected_setting.GetValue() || IsDefaultDeviceConnected() ||
|
||||
m_input_override_function))
|
||||
{
|
||||
pad.isConnected = false;
|
||||
return pad;
|
||||
}
|
||||
|
||||
// buttons
|
||||
m_buttons->GetState(&pad.button, button_bitmasks);
|
||||
m_buttons->GetState(&pad.button, button_bitmasks, m_input_override_function);
|
||||
|
||||
// set analog A/B analog to full or w/e, prolly not needed
|
||||
if (pad.button & PAD_BUTTON_A)
|
||||
@@ -154,20 +140,20 @@ GCPadStatus GCPad::GetInput() const
|
||||
pad.analogB = 0xFF;
|
||||
|
||||
// dpad
|
||||
m_dpad->GetState(&pad.button, dpad_bitmasks);
|
||||
m_dpad->GetState(&pad.button, dpad_bitmasks, m_input_override_function);
|
||||
|
||||
// sticks
|
||||
const auto main_stick_state = m_main_stick->GetState();
|
||||
const auto main_stick_state = m_main_stick->GetState(m_input_override_function);
|
||||
pad.stickX = MapFloat<u8>(main_stick_state.x, GCPadStatus::MAIN_STICK_CENTER_X, 1);
|
||||
pad.stickY = MapFloat<u8>(main_stick_state.y, GCPadStatus::MAIN_STICK_CENTER_Y, 1);
|
||||
|
||||
const auto c_stick_state = m_c_stick->GetState();
|
||||
const auto c_stick_state = m_c_stick->GetState(m_input_override_function);
|
||||
pad.substickX = MapFloat<u8>(c_stick_state.x, GCPadStatus::C_STICK_CENTER_X, 1);
|
||||
pad.substickY = MapFloat<u8>(c_stick_state.y, GCPadStatus::C_STICK_CENTER_Y, 1);
|
||||
|
||||
// triggers
|
||||
std::array<ControlState, 2> triggers;
|
||||
m_triggers->GetState(&pad.button, trigger_bitmasks, triggers.data());
|
||||
m_triggers->GetState(&pad.button, trigger_bitmasks, triggers.data(), m_input_override_function);
|
||||
pad.triggerLeft = MapFloat<u8>(triggers[0], 0);
|
||||
pad.triggerRight = MapFloat<u8>(triggers[1], 0);
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Common/Common.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||
@@ -49,6 +51,31 @@ public:
|
||||
static constexpr ControlState MAIN_STICK_GATE_RADIUS = 0.7937125;
|
||||
static constexpr ControlState C_STICK_GATE_RADIUS = 0.7221375;
|
||||
|
||||
static constexpr const char* BUTTONS_GROUP = _trans("Buttons");
|
||||
static constexpr const char* MAIN_STICK_GROUP = "Main Stick";
|
||||
static constexpr const char* C_STICK_GROUP = "C-Stick";
|
||||
static constexpr const char* DPAD_GROUP = _trans("D-Pad");
|
||||
static constexpr const char* TRIGGERS_GROUP = _trans("Triggers");
|
||||
static constexpr const char* RUMBLE_GROUP = _trans("Rumble");
|
||||
static constexpr const char* MIC_GROUP = _trans("Microphone");
|
||||
static constexpr const char* OPTIONS_GROUP = _trans("Options");
|
||||
|
||||
static constexpr const char* A_BUTTON = "A";
|
||||
static constexpr const char* B_BUTTON = "B";
|
||||
static constexpr const char* X_BUTTON = "X";
|
||||
static constexpr const char* Y_BUTTON = "Y";
|
||||
static constexpr const char* Z_BUTTON = "Z";
|
||||
static constexpr const char* START_BUTTON = "Start";
|
||||
|
||||
// i18n: The left trigger button (labeled L on real controllers)
|
||||
static constexpr const char* L_DIGITAL = _trans("L");
|
||||
// i18n: The right trigger button (labeled R on real controllers)
|
||||
static constexpr const char* R_DIGITAL = _trans("R");
|
||||
// i18n: The left trigger button (labeled L on real controllers) used as an analog input
|
||||
static constexpr const char* L_ANALOG = _trans("L-Analog");
|
||||
// i18n: The right trigger button (labeled R on real controllers) used as an analog input
|
||||
static constexpr const char* R_ANALOG = _trans("R-Analog");
|
||||
|
||||
private:
|
||||
ControllerEmu::Buttons* m_buttons;
|
||||
ControllerEmu::AnalogStick* m_main_stick;
|
||||
|
||||
@@ -119,8 +119,6 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)
|
||||
|
||||
void CSIDevice_GCController::HandleMoviePadStatus(int device_number, GCPadStatus* pad_status)
|
||||
{
|
||||
Movie::CallGCInputManip(pad_status, device_number);
|
||||
|
||||
Movie::SetPolledDevice();
|
||||
if (NetPlay_GetInput(device_number, pad_status))
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <optional>
|
||||
|
||||
#include "Common/MathUtil.h"
|
||||
#include "Core/Config/SYSCONFSettings.h"
|
||||
@@ -221,9 +222,10 @@ WiimoteCommon::AccelData ConvertAccelData(const Common::Vec3& accel, u16 zero_g,
|
||||
u16(std::clamp(std::lround(scaled_accel.z + zero_g), 0l, MAX_VALUE))});
|
||||
}
|
||||
|
||||
void EmulatePoint(MotionState* state, ControllerEmu::Cursor* ir_group, float time_elapsed)
|
||||
void EmulatePoint(MotionState* state, ControllerEmu::Cursor* ir_group,
|
||||
const ControllerEmu::InputOverrideFunction& override_func, float time_elapsed)
|
||||
{
|
||||
const auto cursor = ir_group->GetState(true);
|
||||
const auto cursor = ir_group->GetState(true, override_func);
|
||||
|
||||
if (!cursor.IsVisible())
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/IMUCursor.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Tilt.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
@@ -81,7 +82,8 @@ void ApproachAngleWithAccel(RotationalState* state, const Common::Vec3& target,
|
||||
void EmulateShake(PositionalState* state, ControllerEmu::Shake* shake_group, float time_elapsed);
|
||||
void EmulateTilt(RotationalState* state, ControllerEmu::Tilt* tilt_group, float time_elapsed);
|
||||
void EmulateSwing(MotionState* state, ControllerEmu::Force* swing_group, float time_elapsed);
|
||||
void EmulatePoint(MotionState* state, ControllerEmu::Cursor* ir_group, float time_elapsed);
|
||||
void EmulatePoint(MotionState* state, ControllerEmu::Cursor* ir_group,
|
||||
const ControllerEmu::InputOverrideFunction& override_func, float time_elapsed);
|
||||
void EmulateIMUCursor(IMUCursorState* state, ControllerEmu::IMUCursor* imu_ir_group,
|
||||
ControllerEmu::IMUAccelerometer* imu_accelerometer_group,
|
||||
ControllerEmu::IMUGyroscope* imu_gyroscope_group, float time_elapsed);
|
||||
|
||||
@@ -39,34 +39,11 @@ constexpr std::array<u16, 9> classic_button_bitmasks{{
|
||||
Classic::BUTTON_HOME,
|
||||
}};
|
||||
|
||||
constexpr std::array<std::string_view, 9> classic_button_names{{
|
||||
"A",
|
||||
"B",
|
||||
"X",
|
||||
"Y",
|
||||
"ZL",
|
||||
"ZR",
|
||||
"-",
|
||||
"+",
|
||||
"Home",
|
||||
}};
|
||||
|
||||
constexpr std::array<u16, 2> classic_trigger_bitmasks{{
|
||||
Classic::TRIGGER_L,
|
||||
Classic::TRIGGER_R,
|
||||
}};
|
||||
|
||||
constexpr std::array<const char*, 4> classic_trigger_names{{
|
||||
// i18n: The left trigger button (labeled L on real controllers)
|
||||
_trans("L"),
|
||||
// i18n: The right trigger button (labeled R on real controllers)
|
||||
_trans("R"),
|
||||
// i18n: The left trigger button (labeled L on real controllers) used as an analog input
|
||||
_trans("L-Analog"),
|
||||
// i18n: The right trigger button (labeled R on real controllers) used as an analog input
|
||||
_trans("R-Analog"),
|
||||
}};
|
||||
|
||||
constexpr std::array<u16, 4> classic_dpad_bitmasks{{
|
||||
Classic::PAD_UP,
|
||||
Classic::PAD_DOWN,
|
||||
@@ -77,30 +54,30 @@ constexpr std::array<u16, 4> classic_dpad_bitmasks{{
|
||||
Classic::Classic() : Extension1stParty("Classic", _trans("Classic Controller"))
|
||||
{
|
||||
// buttons
|
||||
groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons")));
|
||||
for (auto& button_name : classic_button_names)
|
||||
groups.emplace_back(m_buttons = new ControllerEmu::Buttons(BUTTONS_GROUP));
|
||||
for (auto& button_name :
|
||||
{A_BUTTON, B_BUTTON, X_BUTTON, Y_BUTTON, ZL_BUTTON, ZR_BUTTON, MINUS_BUTTON, PLUS_BUTTON})
|
||||
{
|
||||
std::string_view ui_name = (button_name == "Home") ? "HOME" : button_name;
|
||||
m_buttons->AddInput(ControllerEmu::DoNotTranslate, std::string(button_name),
|
||||
std::string(ui_name));
|
||||
m_buttons->AddInput(ControllerEmu::DoNotTranslate, button_name);
|
||||
}
|
||||
m_buttons->AddInput(ControllerEmu::DoNotTranslate, HOME_BUTTON, "HOME");
|
||||
|
||||
// sticks
|
||||
constexpr auto gate_radius = ControlState(STICK_GATE_RADIUS) / CAL_STICK_RANGE;
|
||||
constexpr auto gate_radius = ControlState(STICK_GATE_RADIUS) / CAL_STICK_RADIUS;
|
||||
groups.emplace_back(m_left_stick =
|
||||
new ControllerEmu::OctagonAnalogStick(_trans("Left Stick"), gate_radius));
|
||||
groups.emplace_back(
|
||||
m_right_stick = new ControllerEmu::OctagonAnalogStick(_trans("Right Stick"), gate_radius));
|
||||
new ControllerEmu::OctagonAnalogStick(LEFT_STICK_GROUP, gate_radius));
|
||||
groups.emplace_back(m_right_stick =
|
||||
new ControllerEmu::OctagonAnalogStick(RIGHT_STICK_GROUP, gate_radius));
|
||||
|
||||
// triggers
|
||||
groups.emplace_back(m_triggers = new ControllerEmu::MixedTriggers(_trans("Triggers")));
|
||||
for (const char* trigger_name : classic_trigger_names)
|
||||
groups.emplace_back(m_triggers = new ControllerEmu::MixedTriggers(TRIGGERS_GROUP));
|
||||
for (const char* trigger_name : {L_DIGITAL, R_DIGITAL, L_ANALOG, R_ANALOG})
|
||||
{
|
||||
m_triggers->AddInput(ControllerEmu::Translate, trigger_name);
|
||||
}
|
||||
|
||||
// dpad
|
||||
groups.emplace_back(m_dpad = new ControllerEmu::Buttons(_trans("D-Pad")));
|
||||
groups.emplace_back(m_dpad = new ControllerEmu::Buttons(DPAD_GROUP));
|
||||
for (const char* named_direction : named_directions)
|
||||
{
|
||||
m_dpad->AddInput(ControllerEmu::Translate, named_direction);
|
||||
@@ -113,20 +90,22 @@ void Classic::BuildDesiredExtensionState(DesiredExtensionState* target_state)
|
||||
|
||||
// left stick
|
||||
{
|
||||
const ControllerEmu::AnalogStick::StateData left_stick_state = m_left_stick->GetState();
|
||||
const ControllerEmu::AnalogStick::StateData left_stick_state =
|
||||
m_left_stick->GetState(m_input_override_function);
|
||||
|
||||
const u8 x = static_cast<u8>(LEFT_STICK_CENTER + (left_stick_state.x * LEFT_STICK_RADIUS));
|
||||
const u8 y = static_cast<u8>(LEFT_STICK_CENTER + (left_stick_state.y * LEFT_STICK_RADIUS));
|
||||
const u8 x = MapFloat<u8>(left_stick_state.x, LEFT_STICK_CENTER, 0, LEFT_STICK_RANGE);
|
||||
const u8 y = MapFloat<u8>(left_stick_state.y, LEFT_STICK_CENTER, 0, LEFT_STICK_RANGE);
|
||||
|
||||
classic_data.SetLeftStick({x, y});
|
||||
}
|
||||
|
||||
// right stick
|
||||
{
|
||||
const ControllerEmu::AnalogStick::StateData right_stick_data = m_right_stick->GetState();
|
||||
const ControllerEmu::AnalogStick::StateData right_stick_data =
|
||||
m_right_stick->GetState(m_input_override_function);
|
||||
|
||||
const u8 x = static_cast<u8>(RIGHT_STICK_CENTER + (right_stick_data.x * RIGHT_STICK_RADIUS));
|
||||
const u8 y = static_cast<u8>(RIGHT_STICK_CENTER + (right_stick_data.y * RIGHT_STICK_RADIUS));
|
||||
const u8 x = MapFloat<u8>(right_stick_data.x, RIGHT_STICK_CENTER, 0, RIGHT_STICK_RANGE);
|
||||
const u8 y = MapFloat<u8>(right_stick_data.y, RIGHT_STICK_CENTER, 0, RIGHT_STICK_RANGE);
|
||||
|
||||
classic_data.SetRightStick({x, y});
|
||||
}
|
||||
@@ -135,19 +114,20 @@ void Classic::BuildDesiredExtensionState(DesiredExtensionState* target_state)
|
||||
|
||||
// triggers
|
||||
{
|
||||
ControlState trigs[2] = {0, 0};
|
||||
m_triggers->GetState(&buttons, classic_trigger_bitmasks.data(), trigs);
|
||||
ControlState triggers[2] = {0, 0};
|
||||
m_triggers->GetState(&buttons, classic_trigger_bitmasks.data(), triggers,
|
||||
m_input_override_function);
|
||||
|
||||
const u8 lt = static_cast<u8>(trigs[0] * TRIGGER_RANGE);
|
||||
const u8 rt = static_cast<u8>(trigs[1] * TRIGGER_RANGE);
|
||||
const u8 lt = MapFloat<u8>(triggers[0], 0, 0, TRIGGER_RANGE);
|
||||
const u8 rt = MapFloat<u8>(triggers[1], 0, 0, TRIGGER_RANGE);
|
||||
|
||||
classic_data.SetLeftTrigger(lt);
|
||||
classic_data.SetRightTrigger(rt);
|
||||
}
|
||||
|
||||
// buttons and dpad
|
||||
m_buttons->GetState(&buttons, classic_button_bitmasks.data());
|
||||
m_dpad->GetState(&buttons, classic_dpad_bitmasks.data());
|
||||
m_buttons->GetState(&buttons, classic_button_bitmasks.data(), m_input_override_function);
|
||||
m_dpad->GetState(&buttons, classic_dpad_bitmasks.data(), m_input_override_function);
|
||||
|
||||
classic_data.SetButtons(buttons);
|
||||
|
||||
|
||||
@@ -205,16 +205,42 @@ public:
|
||||
static constexpr u8 STICK_GATE_RADIUS = 0x61;
|
||||
|
||||
static constexpr u8 CAL_STICK_CENTER = 0x80;
|
||||
static constexpr u8 CAL_STICK_RANGE = 0x7f;
|
||||
static constexpr u8 CAL_STICK_RADIUS = 0x7f;
|
||||
static constexpr u8 CAL_STICK_RANGE = 0xff;
|
||||
|
||||
static constexpr u8 LEFT_STICK_CENTER = CAL_STICK_CENTER >> (CAL_STICK_BITS - LEFT_STICK_BITS);
|
||||
static constexpr u8 LEFT_STICK_RADIUS = CAL_STICK_RANGE >> (CAL_STICK_BITS - LEFT_STICK_BITS);
|
||||
static constexpr u8 LEFT_STICK_RANGE = CAL_STICK_RANGE >> (CAL_STICK_BITS - LEFT_STICK_BITS);
|
||||
|
||||
static constexpr u8 RIGHT_STICK_CENTER = CAL_STICK_CENTER >> (CAL_STICK_BITS - RIGHT_STICK_BITS);
|
||||
static constexpr u8 RIGHT_STICK_RADIUS = CAL_STICK_RANGE >> (CAL_STICK_BITS - RIGHT_STICK_BITS);
|
||||
static constexpr u8 RIGHT_STICK_RANGE = CAL_STICK_RANGE >> (CAL_STICK_BITS - RIGHT_STICK_BITS);
|
||||
|
||||
static constexpr u8 TRIGGER_RANGE = 0x1F;
|
||||
|
||||
static constexpr const char* BUTTONS_GROUP = _trans("Buttons");
|
||||
static constexpr const char* LEFT_STICK_GROUP = _trans("Left Stick");
|
||||
static constexpr const char* RIGHT_STICK_GROUP = _trans("Right Stick");
|
||||
static constexpr const char* TRIGGERS_GROUP = _trans("Triggers");
|
||||
static constexpr const char* DPAD_GROUP = _trans("D-Pad");
|
||||
|
||||
static constexpr const char* A_BUTTON = "A";
|
||||
static constexpr const char* B_BUTTON = "B";
|
||||
static constexpr const char* X_BUTTON = "X";
|
||||
static constexpr const char* Y_BUTTON = "Y";
|
||||
static constexpr const char* ZL_BUTTON = "ZL";
|
||||
static constexpr const char* ZR_BUTTON = "ZR";
|
||||
static constexpr const char* MINUS_BUTTON = "-";
|
||||
static constexpr const char* PLUS_BUTTON = "+";
|
||||
static constexpr const char* HOME_BUTTON = "Home";
|
||||
|
||||
// i18n: The left trigger button (labeled L on real controllers)
|
||||
static constexpr const char* L_DIGITAL = _trans("L");
|
||||
// i18n: The right trigger button (labeled R on real controllers)
|
||||
static constexpr const char* R_DIGITAL = _trans("R");
|
||||
// i18n: The left trigger button (labeled L on real controllers) used as an analog input
|
||||
static constexpr const char* L_ANALOG = _trans("L-Analog");
|
||||
// i18n: The right trigger button (labeled R on real controllers) used as an analog input
|
||||
static constexpr const char* R_ANALOG = _trans("R-Analog");
|
||||
|
||||
private:
|
||||
ControllerEmu::Buttons* m_buttons;
|
||||
ControllerEmu::MixedTriggers* m_triggers;
|
||||
|
||||
@@ -44,12 +44,12 @@ void DrawsomeTablet::BuildDesiredExtensionState(DesiredExtensionState* target_st
|
||||
// the "Drawsome" game expects you to go "off screen" a bit to access some menu items.
|
||||
constexpr u16 MIN_Y = 0x15ff + 0x100;
|
||||
constexpr u16 MAX_Y = 0x00;
|
||||
constexpr double CENTER_X = (MAX_X + MIN_X) / 2.0;
|
||||
constexpr double CENTER_Y = (MAX_Y + MIN_Y) / 2.0;
|
||||
constexpr u16 CENTER_X = (MAX_X + MIN_X + 1) / 2;
|
||||
constexpr u16 CENTER_Y = (MAX_Y + MIN_Y + 1) / 2;
|
||||
|
||||
const auto stylus_state = m_stylus->GetState();
|
||||
const auto stylus_x = u16(std::lround(CENTER_X + stylus_state.x * (MAX_X - CENTER_X)));
|
||||
const auto stylus_y = u16(std::lround(CENTER_Y + stylus_state.y * (MAX_Y - CENTER_Y)));
|
||||
const auto stylus_state = m_stylus->GetState(m_input_override_function);
|
||||
const u16 stylus_x = MapFloat<u16>(stylus_state.x, CENTER_X, MIN_X, MAX_X);
|
||||
const u16 stylus_y = MapFloat<u16>(-stylus_state.y, CENTER_Y, MAX_Y, MIN_Y);
|
||||
|
||||
tablet_data.stylus_x1 = u8(stylus_x);
|
||||
tablet_data.stylus_x2 = u8(stylus_x >> 8);
|
||||
@@ -74,8 +74,8 @@ void DrawsomeTablet::BuildDesiredExtensionState(DesiredExtensionState* target_st
|
||||
// Pressure (0 - 0x7ff):
|
||||
constexpr u16 MAX_PRESSURE = 0x7ff;
|
||||
|
||||
const auto touch_state = m_touch->GetState();
|
||||
const auto pressure = u16(std::lround(touch_state.data[0] * MAX_PRESSURE));
|
||||
const auto touch_state = m_touch->GetState(m_input_override_function);
|
||||
const u16 pressure = MapFloat<u16>(touch_state.data[0], 0, 0, MAX_PRESSURE);
|
||||
|
||||
tablet_data.pressure1 = u8(pressure);
|
||||
tablet_data.pressure2 = u8(pressure >> 8);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user