Merge pull request #7400 from zackhow/phone-rumble
Android: Add rumble for phone
This commit is contained in:
commit
85961f996e
|
@ -18,6 +18,7 @@
|
|||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="com.android.providers.tv.permission.READ_EPG_DATA"/>
|
||||
<uses-permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
|
||||
<application
|
||||
android:name=".DolphinApplication"
|
||||
|
|
|
@ -25,6 +25,7 @@ Triggers/R = `Axis 21`
|
|||
Triggers/L-Analog = `Axis 20`
|
||||
Triggers/R-Analog = `Axis 21`
|
||||
Triggers/Threshold = 90,000000
|
||||
Rumble/Motor = `Rumble 700`
|
||||
[GCPad2]
|
||||
Device = Android/1/Touchscreen
|
||||
Buttons/A = `Button 0`
|
||||
|
@ -52,6 +53,7 @@ Triggers/R = `Axis 21`
|
|||
Triggers/L-Analog = `Axis 20`
|
||||
Triggers/R-Analog = `Axis 21`
|
||||
Triggers/Threshold = 90,000000
|
||||
Rumble/Motor = `Rumble 700`
|
||||
[GCPad3]
|
||||
Device = Android/2/Touchscreen
|
||||
Buttons/A = `Button 0`
|
||||
|
@ -79,6 +81,7 @@ Triggers/R = `Axis 21`
|
|||
Triggers/L-Analog = `Axis 20`
|
||||
Triggers/R-Analog = `Axis 21`
|
||||
Triggers/Threshold = 90,000000
|
||||
Rumble/Motor = `Rumble 700`
|
||||
[GCPad4]
|
||||
Device = Android/3/Touchscreen
|
||||
Buttons/A = `Button 0`
|
||||
|
@ -106,3 +109,4 @@ Triggers/R = `Axis 21`
|
|||
Triggers/L-Analog = `Axis 20`
|
||||
Triggers/R-Analog = `Axis 21`
|
||||
Triggers/Threshold = 90,000000
|
||||
Rumble/Motor = `Rumble 700`
|
||||
|
|
|
@ -133,6 +133,7 @@ Turntable/Effect/Dial = `Axis 621`
|
|||
Turntable/Crossfade/Left = `Axis 623`
|
||||
Turntable/Crossfade/Right = `Axis 624`
|
||||
Source = 1
|
||||
Rumble/Motor = `Rumble 700`
|
||||
[Wiimote2]
|
||||
Device = Android/5/Touchscreen
|
||||
Buttons/A = `Button 100`
|
||||
|
@ -268,6 +269,7 @@ Turntable/Effect/Dial = `Axis 621`
|
|||
Turntable/Crossfade/Left = `Axis 623`
|
||||
Turntable/Crossfade/Right = `Axis 624`
|
||||
Source = 0
|
||||
Rumble/Motor = `Rumble 700`
|
||||
[Wiimote3]
|
||||
Device = Android/6/Touchscreen
|
||||
Buttons/A = `Button 100`
|
||||
|
@ -403,6 +405,7 @@ Turntable/Effect/Dial = `Axis 621`
|
|||
Turntable/Crossfade/Left = `Axis 623`
|
||||
Turntable/Crossfade/Right = `Axis 624`
|
||||
Source = 0
|
||||
Rumble/Motor = `Rumble 700`
|
||||
[Wiimote4]
|
||||
Device = Android/7/Touchscreen
|
||||
Buttons/A = `Button 100`
|
||||
|
@ -538,3 +541,4 @@ Turntable/Effect/Dial = `Axis 621`
|
|||
Turntable/Crossfade/Left = `Axis 623`
|
||||
Turntable/Crossfade/Right = `Axis 624`
|
||||
Source = 0
|
||||
Rumble/Motor = `Rumble 700`
|
||||
|
|
|
@ -7,6 +7,11 @@
|
|||
package org.dolphinemu.dolphinemu;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.Surface;
|
||||
|
||||
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
|
||||
|
@ -225,6 +230,39 @@ public final class NativeLibrary
|
|||
*/
|
||||
public static native void onGamePadMoveEvent(String Device, int Axis, float Value);
|
||||
|
||||
/**
|
||||
* Rumble sent from native. Currently only supports phone rumble.
|
||||
*
|
||||
* @param padID Ignored for now. Future use would be to pass rumble to a connected controller
|
||||
* @param state Ignored for now since phone rumble can't just be 'turned' on/off
|
||||
*/
|
||||
public static void rumble(int padID, double state)
|
||||
{
|
||||
final EmulationActivity emulationActivity = sEmulationActivity.get();
|
||||
if (emulationActivity == null)
|
||||
{
|
||||
Log.warning("[NativeLibrary] EmulationActivity is null");
|
||||
return;
|
||||
}
|
||||
|
||||
if (PreferenceManager.getDefaultSharedPreferences(emulationActivity)
|
||||
.getBoolean("phoneRumble", true))
|
||||
{
|
||||
Vibrator vibrator = (Vibrator) emulationActivity.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
if (vibrator != null && vibrator.hasVibrator())
|
||||
{
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||
{
|
||||
vibrator.vibrate(VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE));
|
||||
}
|
||||
else
|
||||
{
|
||||
vibrator.vibrate(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static native String GetUserSetting(String gameID, String Section, String Key);
|
||||
|
||||
public static native void SetUserSetting(String gameID, String Section, String Key, String Value);
|
||||
|
|
|
@ -124,6 +124,7 @@ public final class EmulationActivity extends AppCompatActivity
|
|||
public static final int MENU_ACTION_EXIT = 22;
|
||||
public static final int MENU_ACTION_CHANGE_DISC = 23;
|
||||
public static final int MENU_ACTION_JOYSTICK_REL_CENTER = 24;
|
||||
public static final int MENU_ACTION_RUMBLE = 25;
|
||||
|
||||
|
||||
private static SparseIntArray buttonsActionsMap = new SparseIntArray();
|
||||
|
@ -163,6 +164,7 @@ public final class EmulationActivity extends AppCompatActivity
|
|||
buttonsActionsMap.append(R.id.menu_exit, EmulationActivity.MENU_ACTION_EXIT);
|
||||
buttonsActionsMap.append(R.id.menu_emulation_joystick_rel_center,
|
||||
EmulationActivity.MENU_ACTION_JOYSTICK_REL_CENTER);
|
||||
buttonsActionsMap.append(R.id.menu_emulation_rumble, EmulationActivity.MENU_ACTION_RUMBLE);
|
||||
}
|
||||
|
||||
public static void launch(FragmentActivity activity, GameFile gameFile, int position,
|
||||
|
@ -473,6 +475,8 @@ public final class EmulationActivity extends AppCompatActivity
|
|||
// Populate the checkbox value for joystick center on touch
|
||||
menu.findItem(R.id.menu_emulation_joystick_rel_center)
|
||||
.setChecked(mPreferences.getBoolean("joystickRelCenter", true));
|
||||
menu.findItem(R.id.menu_emulation_rumble)
|
||||
.setChecked(mPreferences.getBoolean("phoneRumble", true));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -504,7 +508,11 @@ public final class EmulationActivity extends AppCompatActivity
|
|||
case MENU_ACTION_JOYSTICK_REL_CENTER:
|
||||
item.setChecked(!item.isChecked());
|
||||
toggleJoystickRelCenter(item.isChecked());
|
||||
return;
|
||||
break;
|
||||
case MENU_ACTION_RUMBLE:
|
||||
item.setChecked(!item.isChecked());
|
||||
toggleRumble(item.isChecked());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -636,6 +644,13 @@ public final class EmulationActivity extends AppCompatActivity
|
|||
editor.commit();
|
||||
}
|
||||
|
||||
private void toggleRumble(boolean state)
|
||||
{
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean("phoneRumble", state);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
|
||||
private void editControlsPlacement()
|
||||
{
|
||||
|
|
|
@ -98,6 +98,10 @@
|
|||
android:id="@+id/menu_emulation_joystick_rel_center"
|
||||
android:checkable="true"
|
||||
android:title="@string/emulation_control_joystick_rel_center"/>
|
||||
<item
|
||||
android:id="@+id/menu_emulation_rumble"
|
||||
android:checkable="true"
|
||||
android:title="@string/emulation_control_rumble"/>
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
|
|
|
@ -98,11 +98,16 @@
|
|||
android:id="@+id/menu_emulation_joystick_rel_center"
|
||||
android:checkable="true"
|
||||
android:title="@string/emulation_control_joystick_rel_center"/>
|
||||
<item
|
||||
android:id="@+id/menu_emulation_rumble"
|
||||
android:checkable="true"
|
||||
android:title="@string/emulation_control_rumble"/>
|
||||
</group>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_emulation_choose_controller"
|
||||
android:title="@string/emulation_choose_controller"/>
|
||||
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
|
|
|
@ -271,6 +271,7 @@
|
|||
<string name="emulation_toggle_all">Toggle All</string>
|
||||
<string name="emulation_control_scale">Adjust Scale</string>
|
||||
<string name="emulation_control_joystick_rel_center">Relative Stick Center</string>
|
||||
<string name="emulation_control_rumble">Rumble</string>
|
||||
<string name="emulation_choose_controller">Choose Controller</string>
|
||||
<string name="emulation_controller_changed">You may have to reload the game after changing extensions.</string>
|
||||
<string name="emulation_touch_button_help">To change the button layout, open the menu -> Configure Controls -> Edit Layout</string>
|
||||
|
|
|
@ -18,83 +18,309 @@ const std::string touchScreenKey = "Touchscreen";
|
|||
std::unordered_map<std::string, InputDevice*> m_controllers;
|
||||
std::vector<std::string> configStrings = {
|
||||
// GC
|
||||
"InputA", "InputB", "InputStart", "InputX", "InputY", "InputZ", "DPadUp", "DPadDown",
|
||||
"DPadLeft", "DPadRight", "MainUp", "MainDown", "MainLeft", "MainRight", "CStickUp",
|
||||
"CStickDown", "CStickLeft", "CStickRight", "InputL", "InputR",
|
||||
"InputA",
|
||||
"InputB",
|
||||
"InputStart",
|
||||
"InputX",
|
||||
"InputY",
|
||||
"InputZ",
|
||||
"DPadUp",
|
||||
"DPadDown",
|
||||
"DPadLeft",
|
||||
"DPadRight",
|
||||
"MainUp",
|
||||
"MainDown",
|
||||
"MainLeft",
|
||||
"MainRight",
|
||||
"CStickUp",
|
||||
"CStickDown",
|
||||
"CStickLeft",
|
||||
"CStickRight",
|
||||
"InputL",
|
||||
"InputR",
|
||||
// Wiimote
|
||||
"WiimoteA", "WiimoteB", "WiimoteMinus", "WiimotePlus", "WiimoteHome", "Wiimote1", "Wiimote2",
|
||||
"WiimoteUp", "WiimoteDown", "WiimoteLeft", "WiimoteRight", "IRUp", "IRDown", "IRLeft",
|
||||
"IRRight", "IRForward", "IRBackward", "IRHide", "SwingUp", "SwingDown", "SwingLeft",
|
||||
"SwingRight", "SwingForward", "SwingBackward", "TiltForward", "TiltBackward", "TiltLeft",
|
||||
"TiltRight", "TiltModifier", "ShakeX", "ShakeY", "ShakeZ",
|
||||
"WiimoteA",
|
||||
"WiimoteB",
|
||||
"WiimoteMinus",
|
||||
"WiimotePlus",
|
||||
"WiimoteHome",
|
||||
"Wiimote1",
|
||||
"Wiimote2",
|
||||
"WiimoteUp",
|
||||
"WiimoteDown",
|
||||
"WiimoteLeft",
|
||||
"WiimoteRight",
|
||||
"IRUp",
|
||||
"IRDown",
|
||||
"IRLeft",
|
||||
"IRRight",
|
||||
"IRForward",
|
||||
"IRBackward",
|
||||
"IRHide",
|
||||
"SwingUp",
|
||||
"SwingDown",
|
||||
"SwingLeft",
|
||||
"SwingRight",
|
||||
"SwingForward",
|
||||
"SwingBackward",
|
||||
"TiltForward",
|
||||
"TiltBackward",
|
||||
"TiltLeft",
|
||||
"TiltRight",
|
||||
"TiltModifier",
|
||||
"ShakeX",
|
||||
"ShakeY",
|
||||
"ShakeZ",
|
||||
// Nunchuk
|
||||
"NunchukC", "NunchukZ", "NunchukUp", "NunchukDown", "NunchukLeft", "NunchukRight",
|
||||
"NunchukSwingUp", "NunchukSwingDown", "NunchukSwingLeft", "NunchukSwingRight",
|
||||
"NunchukSwingForward", "NunchukSwingBackward", "NunchukTiltForward", "NunchukTiltBackward",
|
||||
"NunchukTiltLeft", "NunchukTiltRight", "NunchukTiltModifier", "NunchukShakeX", "NunchukShakeY",
|
||||
"NunchukC",
|
||||
"NunchukZ",
|
||||
"NunchukUp",
|
||||
"NunchukDown",
|
||||
"NunchukLeft",
|
||||
"NunchukRight",
|
||||
"NunchukSwingUp",
|
||||
"NunchukSwingDown",
|
||||
"NunchukSwingLeft",
|
||||
"NunchukSwingRight",
|
||||
"NunchukSwingForward",
|
||||
"NunchukSwingBackward",
|
||||
"NunchukTiltForward",
|
||||
"NunchukTiltBackward",
|
||||
"NunchukTiltLeft",
|
||||
"NunchukTiltRight",
|
||||
"NunchukTiltModifier",
|
||||
"NunchukShakeX",
|
||||
"NunchukShakeY",
|
||||
"NunchukShakeZ",
|
||||
// Classic
|
||||
"ClassicA", "ClassicB", "ClassicX", "ClassicY", "ClassicMinus", "ClassicPlus", "ClassicHome",
|
||||
"ClassicZL", "ClassicZR", "ClassicUp", "ClassicDown", "ClassicLeft", "ClassicRight",
|
||||
"ClassicLeftStickUp", "ClassicLeftStickDown", "ClassicLeftStickLeft", "ClassicLeftStickRight",
|
||||
"ClassicRightStickUp", "ClassicRightStickDown", "ClassicRightStickLeft",
|
||||
"ClassicRightStickRight", "ClassicTriggerL", "ClassicTriggerR",
|
||||
"ClassicA",
|
||||
"ClassicB",
|
||||
"ClassicX",
|
||||
"ClassicY",
|
||||
"ClassicMinus",
|
||||
"ClassicPlus",
|
||||
"ClassicHome",
|
||||
"ClassicZL",
|
||||
"ClassicZR",
|
||||
"ClassicUp",
|
||||
"ClassicDown",
|
||||
"ClassicLeft",
|
||||
"ClassicRight",
|
||||
"ClassicLeftStickUp",
|
||||
"ClassicLeftStickDown",
|
||||
"ClassicLeftStickLeft",
|
||||
"ClassicLeftStickRight",
|
||||
"ClassicRightStickUp",
|
||||
"ClassicRightStickDown",
|
||||
"ClassicRightStickLeft",
|
||||
"ClassicRightStickRight",
|
||||
"ClassicTriggerL",
|
||||
"ClassicTriggerR",
|
||||
// Guitar
|
||||
"GuitarMinus", "GuitarPlus", "GuitarGreen", "GuitarRed", "GuitarYellow", "GuitarBue",
|
||||
"GuitarOrange", "GuitarStrumUp", "GuitarStrumDown", "GuitarUp", "GuitarDown", "GuitarLeft",
|
||||
"GuitarRight", "GuitarWhammy",
|
||||
"GuitarMinus",
|
||||
"GuitarPlus",
|
||||
"GuitarGreen",
|
||||
"GuitarRed",
|
||||
"GuitarYellow",
|
||||
"GuitarBue",
|
||||
"GuitarOrange",
|
||||
"GuitarStrumUp",
|
||||
"GuitarStrumDown",
|
||||
"GuitarUp",
|
||||
"GuitarDown",
|
||||
"GuitarLeft",
|
||||
"GuitarRight",
|
||||
"GuitarWhammy",
|
||||
// Drums
|
||||
"DrumsMinus", "DrumsPlus", "DrumsRed", "DrumsYellow", "DrumsBlue", "DrumsGreen", "DrumsOrange",
|
||||
"DrumsBass", "DrumsUp", "DrumsDown", "DrumsLeft", "DrumsRight",
|
||||
"DrumsMinus",
|
||||
"DrumsPlus",
|
||||
"DrumsRed",
|
||||
"DrumsYellow",
|
||||
"DrumsBlue",
|
||||
"DrumsGreen",
|
||||
"DrumsOrange",
|
||||
"DrumsBass",
|
||||
"DrumsUp",
|
||||
"DrumsDown",
|
||||
"DrumsLeft",
|
||||
"DrumsRight",
|
||||
// Turntable
|
||||
"TurntableGreenLeft", "TurntableRedLeft", "TurntableBlueLeft", "TurntableGreenRight",
|
||||
"TurntableRedRight", "TurntableBlueRight", "TurntableMinus", "TurntablePlus", "TurntableHome",
|
||||
"TurntableEuphoria", "TurntableLeftTLeft", "TurntableLeftTRight", "TurntableRightTLeft",
|
||||
"TurntableRightTRight", "TurntableUp", "TurntableDown", "TurntableLeft", "TurntableRight",
|
||||
"TurntableEffDial", "TurntableCrossLeft", "TurntableCrossRight",
|
||||
"TurntableGreenLeft",
|
||||
"TurntableRedLeft",
|
||||
"TurntableBlueLeft",
|
||||
"TurntableGreenRight",
|
||||
"TurntableRedRight",
|
||||
"TurntableBlueRight",
|
||||
"TurntableMinus",
|
||||
"TurntablePlus",
|
||||
"TurntableHome",
|
||||
"TurntableEuphoria",
|
||||
"TurntableLeftTLeft",
|
||||
"TurntableLeftTRight",
|
||||
"TurntableRightTLeft",
|
||||
"TurntableRightTRight",
|
||||
"TurntableUp",
|
||||
"TurntableDown",
|
||||
"TurntableLeft",
|
||||
"TurntableRight",
|
||||
"TurntableEffDial",
|
||||
"TurntableCrossLeft",
|
||||
"TurntableCrossRight",
|
||||
// Rumble
|
||||
"Rumble",
|
||||
};
|
||||
std::vector<ButtonType> configTypes = {
|
||||
// GC
|
||||
BUTTON_A, BUTTON_B, BUTTON_START, BUTTON_X, BUTTON_Y, BUTTON_Z, BUTTON_UP, BUTTON_DOWN,
|
||||
BUTTON_LEFT, BUTTON_RIGHT, STICK_MAIN_UP, STICK_MAIN_DOWN, STICK_MAIN_LEFT, STICK_MAIN_RIGHT,
|
||||
STICK_C_UP, STICK_C_DOWN, STICK_C_LEFT, STICK_C_RIGHT, TRIGGER_L, TRIGGER_R,
|
||||
BUTTON_A,
|
||||
BUTTON_B,
|
||||
BUTTON_START,
|
||||
BUTTON_X,
|
||||
BUTTON_Y,
|
||||
BUTTON_Z,
|
||||
BUTTON_UP,
|
||||
BUTTON_DOWN,
|
||||
BUTTON_LEFT,
|
||||
BUTTON_RIGHT,
|
||||
STICK_MAIN_UP,
|
||||
STICK_MAIN_DOWN,
|
||||
STICK_MAIN_LEFT,
|
||||
STICK_MAIN_RIGHT,
|
||||
STICK_C_UP,
|
||||
STICK_C_DOWN,
|
||||
STICK_C_LEFT,
|
||||
STICK_C_RIGHT,
|
||||
TRIGGER_L,
|
||||
TRIGGER_R,
|
||||
// Wiimote
|
||||
WIIMOTE_BUTTON_A, WIIMOTE_BUTTON_B, WIIMOTE_BUTTON_MINUS, WIIMOTE_BUTTON_PLUS,
|
||||
WIIMOTE_BUTTON_HOME, WIIMOTE_BUTTON_1, WIIMOTE_BUTTON_2, WIIMOTE_UP, WIIMOTE_DOWN, WIIMOTE_LEFT,
|
||||
WIIMOTE_RIGHT, WIIMOTE_IR_UP, WIIMOTE_IR_DOWN, WIIMOTE_IR_LEFT, WIIMOTE_IR_RIGHT,
|
||||
WIIMOTE_IR_FORWARD, WIIMOTE_IR_BACKWARD, WIIMOTE_IR_HIDE, WIIMOTE_SWING_UP, WIIMOTE_SWING_DOWN,
|
||||
WIIMOTE_SWING_LEFT, WIIMOTE_SWING_RIGHT, WIIMOTE_SWING_FORWARD, WIIMOTE_SWING_BACKWARD,
|
||||
WIIMOTE_TILT_FORWARD, WIIMOTE_TILT_BACKWARD, WIIMOTE_TILT_LEFT, WIIMOTE_TILT_RIGHT,
|
||||
WIIMOTE_TILT_MODIFIER, WIIMOTE_SHAKE_X, WIIMOTE_SHAKE_Y, WIIMOTE_SHAKE_Z,
|
||||
WIIMOTE_BUTTON_A,
|
||||
WIIMOTE_BUTTON_B,
|
||||
WIIMOTE_BUTTON_MINUS,
|
||||
WIIMOTE_BUTTON_PLUS,
|
||||
WIIMOTE_BUTTON_HOME,
|
||||
WIIMOTE_BUTTON_1,
|
||||
WIIMOTE_BUTTON_2,
|
||||
WIIMOTE_UP,
|
||||
WIIMOTE_DOWN,
|
||||
WIIMOTE_LEFT,
|
||||
WIIMOTE_RIGHT,
|
||||
WIIMOTE_IR_UP,
|
||||
WIIMOTE_IR_DOWN,
|
||||
WIIMOTE_IR_LEFT,
|
||||
WIIMOTE_IR_RIGHT,
|
||||
WIIMOTE_IR_FORWARD,
|
||||
WIIMOTE_IR_BACKWARD,
|
||||
WIIMOTE_IR_HIDE,
|
||||
WIIMOTE_SWING_UP,
|
||||
WIIMOTE_SWING_DOWN,
|
||||
WIIMOTE_SWING_LEFT,
|
||||
WIIMOTE_SWING_RIGHT,
|
||||
WIIMOTE_SWING_FORWARD,
|
||||
WIIMOTE_SWING_BACKWARD,
|
||||
WIIMOTE_TILT_FORWARD,
|
||||
WIIMOTE_TILT_BACKWARD,
|
||||
WIIMOTE_TILT_LEFT,
|
||||
WIIMOTE_TILT_RIGHT,
|
||||
WIIMOTE_TILT_MODIFIER,
|
||||
WIIMOTE_SHAKE_X,
|
||||
WIIMOTE_SHAKE_Y,
|
||||
WIIMOTE_SHAKE_Z,
|
||||
// Nunchuk
|
||||
NUNCHUK_BUTTON_C, NUNCHUK_BUTTON_Z, NUNCHUK_STICK_UP, NUNCHUK_STICK_DOWN, NUNCHUK_STICK_LEFT,
|
||||
NUNCHUK_STICK_RIGHT, NUNCHUK_SWING_UP, NUNCHUK_SWING_DOWN, NUNCHUK_SWING_LEFT,
|
||||
NUNCHUK_SWING_RIGHT, NUNCHUK_SWING_FORWARD, NUNCHUK_SWING_BACKWARD, NUNCHUK_TILT_FORWARD,
|
||||
NUNCHUK_TILT_BACKWARD, NUNCHUK_TILT_LEFT, NUNCHUK_TILT_RIGHT, NUNCHUK_TILT_MODIFIER,
|
||||
NUNCHUK_SHAKE_X, NUNCHUK_SHAKE_Y, NUNCHUK_SHAKE_Z,
|
||||
NUNCHUK_BUTTON_C,
|
||||
NUNCHUK_BUTTON_Z,
|
||||
NUNCHUK_STICK_UP,
|
||||
NUNCHUK_STICK_DOWN,
|
||||
NUNCHUK_STICK_LEFT,
|
||||
NUNCHUK_STICK_RIGHT,
|
||||
NUNCHUK_SWING_UP,
|
||||
NUNCHUK_SWING_DOWN,
|
||||
NUNCHUK_SWING_LEFT,
|
||||
NUNCHUK_SWING_RIGHT,
|
||||
NUNCHUK_SWING_FORWARD,
|
||||
NUNCHUK_SWING_BACKWARD,
|
||||
NUNCHUK_TILT_FORWARD,
|
||||
NUNCHUK_TILT_BACKWARD,
|
||||
NUNCHUK_TILT_LEFT,
|
||||
NUNCHUK_TILT_RIGHT,
|
||||
NUNCHUK_TILT_MODIFIER,
|
||||
NUNCHUK_SHAKE_X,
|
||||
NUNCHUK_SHAKE_Y,
|
||||
NUNCHUK_SHAKE_Z,
|
||||
// Classic
|
||||
CLASSIC_BUTTON_A, CLASSIC_BUTTON_B, CLASSIC_BUTTON_X, CLASSIC_BUTTON_Y, CLASSIC_BUTTON_MINUS,
|
||||
CLASSIC_BUTTON_PLUS, CLASSIC_BUTTON_HOME, CLASSIC_BUTTON_ZL, CLASSIC_BUTTON_ZR, CLASSIC_DPAD_UP,
|
||||
CLASSIC_DPAD_DOWN, CLASSIC_DPAD_LEFT, CLASSIC_DPAD_RIGHT, CLASSIC_STICK_LEFT_UP,
|
||||
CLASSIC_STICK_LEFT_DOWN, CLASSIC_STICK_LEFT_LEFT, CLASSIC_STICK_LEFT_RIGHT,
|
||||
CLASSIC_STICK_RIGHT_UP, CLASSIC_STICK_RIGHT_DOWN, CLASSIC_STICK_RIGHT_LEFT,
|
||||
CLASSIC_STICK_RIGHT_RIGHT, CLASSIC_TRIGGER_L, CLASSIC_TRIGGER_R,
|
||||
CLASSIC_BUTTON_A,
|
||||
CLASSIC_BUTTON_B,
|
||||
CLASSIC_BUTTON_X,
|
||||
CLASSIC_BUTTON_Y,
|
||||
CLASSIC_BUTTON_MINUS,
|
||||
CLASSIC_BUTTON_PLUS,
|
||||
CLASSIC_BUTTON_HOME,
|
||||
CLASSIC_BUTTON_ZL,
|
||||
CLASSIC_BUTTON_ZR,
|
||||
CLASSIC_DPAD_UP,
|
||||
CLASSIC_DPAD_DOWN,
|
||||
CLASSIC_DPAD_LEFT,
|
||||
CLASSIC_DPAD_RIGHT,
|
||||
CLASSIC_STICK_LEFT_UP,
|
||||
CLASSIC_STICK_LEFT_DOWN,
|
||||
CLASSIC_STICK_LEFT_LEFT,
|
||||
CLASSIC_STICK_LEFT_RIGHT,
|
||||
CLASSIC_STICK_RIGHT_UP,
|
||||
CLASSIC_STICK_RIGHT_DOWN,
|
||||
CLASSIC_STICK_RIGHT_LEFT,
|
||||
CLASSIC_STICK_RIGHT_RIGHT,
|
||||
CLASSIC_TRIGGER_L,
|
||||
CLASSIC_TRIGGER_R,
|
||||
// Guitar
|
||||
GUITAR_BUTTON_MINUS, GUITAR_BUTTON_PLUS, GUITAR_FRET_GREEN, GUITAR_FRET_RED, GUITAR_FRET_YELLOW,
|
||||
GUITAR_FRET_BLUE, GUITAR_FRET_ORANGE, GUITAR_STRUM_UP, GUITAR_STRUM_DOWN, GUITAR_STICK_UP,
|
||||
GUITAR_STICK_DOWN, GUITAR_STICK_LEFT, GUITAR_STICK_RIGHT, GUITAR_WHAMMY_BAR,
|
||||
GUITAR_BUTTON_MINUS,
|
||||
GUITAR_BUTTON_PLUS,
|
||||
GUITAR_FRET_GREEN,
|
||||
GUITAR_FRET_RED,
|
||||
GUITAR_FRET_YELLOW,
|
||||
GUITAR_FRET_BLUE,
|
||||
GUITAR_FRET_ORANGE,
|
||||
GUITAR_STRUM_UP,
|
||||
GUITAR_STRUM_DOWN,
|
||||
GUITAR_STICK_UP,
|
||||
GUITAR_STICK_DOWN,
|
||||
GUITAR_STICK_LEFT,
|
||||
GUITAR_STICK_RIGHT,
|
||||
GUITAR_WHAMMY_BAR,
|
||||
// Drums
|
||||
DRUMS_BUTTON_MINUS, DRUMS_BUTTON_PLUS, DRUMS_PAD_RED, DRUMS_PAD_YELLOW, DRUMS_PAD_BLUE,
|
||||
DRUMS_PAD_GREEN, DRUMS_PAD_ORANGE, DRUMS_PAD_BASS, DRUMS_STICK_UP, DRUMS_STICK_DOWN,
|
||||
DRUMS_STICK_LEFT, DRUMS_STICK_RIGHT,
|
||||
DRUMS_BUTTON_MINUS,
|
||||
DRUMS_BUTTON_PLUS,
|
||||
DRUMS_PAD_RED,
|
||||
DRUMS_PAD_YELLOW,
|
||||
DRUMS_PAD_BLUE,
|
||||
DRUMS_PAD_GREEN,
|
||||
DRUMS_PAD_ORANGE,
|
||||
DRUMS_PAD_BASS,
|
||||
DRUMS_STICK_UP,
|
||||
DRUMS_STICK_DOWN,
|
||||
DRUMS_STICK_LEFT,
|
||||
DRUMS_STICK_RIGHT,
|
||||
// Turntable
|
||||
TURNTABLE_BUTTON_GREEN_LEFT, TURNTABLE_BUTTON_RED_LEFT, TURNTABLE_BUTTON_BLUE_LEFT,
|
||||
TURNTABLE_BUTTON_GREEN_RIGHT, TURNTABLE_BUTTON_RED_RIGHT, TURNTABLE_BUTTON_BLUE_RIGHT,
|
||||
TURNTABLE_BUTTON_MINUS, TURNTABLE_BUTTON_PLUS, TURNTABLE_BUTTON_HOME, TURNTABLE_BUTTON_EUPHORIA,
|
||||
TURNTABLE_TABLE_LEFT_LEFT, TURNTABLE_TABLE_LEFT_RIGHT, TURNTABLE_TABLE_RIGHT_LEFT,
|
||||
TURNTABLE_TABLE_RIGHT_RIGHT, TURNTABLE_STICK_UP, TURNTABLE_STICK_DOWN, TURNTABLE_STICK_LEFT,
|
||||
TURNTABLE_STICK_RIGHT, TURNTABLE_EFFECT_DIAL, TURNTABLE_CROSSFADE_LEFT,
|
||||
TURNTABLE_BUTTON_GREEN_LEFT,
|
||||
TURNTABLE_BUTTON_RED_LEFT,
|
||||
TURNTABLE_BUTTON_BLUE_LEFT,
|
||||
TURNTABLE_BUTTON_GREEN_RIGHT,
|
||||
TURNTABLE_BUTTON_RED_RIGHT,
|
||||
TURNTABLE_BUTTON_BLUE_RIGHT,
|
||||
TURNTABLE_BUTTON_MINUS,
|
||||
TURNTABLE_BUTTON_PLUS,
|
||||
TURNTABLE_BUTTON_HOME,
|
||||
TURNTABLE_BUTTON_EUPHORIA,
|
||||
TURNTABLE_TABLE_LEFT_LEFT,
|
||||
TURNTABLE_TABLE_LEFT_RIGHT,
|
||||
TURNTABLE_TABLE_RIGHT_LEFT,
|
||||
TURNTABLE_TABLE_RIGHT_RIGHT,
|
||||
TURNTABLE_STICK_UP,
|
||||
TURNTABLE_STICK_DOWN,
|
||||
TURNTABLE_STICK_LEFT,
|
||||
TURNTABLE_STICK_RIGHT,
|
||||
TURNTABLE_EFFECT_DIAL,
|
||||
TURNTABLE_CROSSFADE_LEFT,
|
||||
TURNTABLE_CROSSFADE_RIGHT,
|
||||
// Rumble
|
||||
RUMBLE,
|
||||
};
|
||||
|
||||
static void AddBind(const std::string& dev, sBind* bind)
|
||||
|
@ -367,6 +593,7 @@ void Init()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GetButtonPressed(int padID, ButtonType button)
|
||||
{
|
||||
bool pressed = m_controllers[touchScreenKey]->ButtonValue(padID, button);
|
||||
|
@ -376,6 +603,7 @@ bool GetButtonPressed(int padID, ButtonType button)
|
|||
|
||||
return pressed;
|
||||
}
|
||||
|
||||
float GetAxisValue(int padID, ButtonType axis)
|
||||
{
|
||||
float value = m_controllers[touchScreenKey]->AxisValue(padID, axis);
|
||||
|
@ -390,6 +618,7 @@ float GetAxisValue(int padID, ButtonType axis)
|
|||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
bool GamepadEvent(const std::string& dev, int button, int action)
|
||||
{
|
||||
auto it = m_controllers.find(dev);
|
||||
|
@ -397,12 +626,14 @@ bool GamepadEvent(const std::string& dev, int button, int action)
|
|||
return it->second->PressEvent(button, action);
|
||||
return false;
|
||||
}
|
||||
|
||||
void GamepadAxisEvent(const std::string& dev, int axis, float value)
|
||||
{
|
||||
auto it = m_controllers.find(dev);
|
||||
if (it != m_controllers.end())
|
||||
it->second->AxisEvent(axis, value);
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
for (const auto& controller : m_controllers)
|
||||
|
@ -427,6 +658,7 @@ bool InputDevice::PressEvent(int button, int action)
|
|||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
void InputDevice::AxisEvent(int axis, float value)
|
||||
{
|
||||
for (const auto& binding : _inputbinds)
|
||||
|
@ -440,6 +672,7 @@ void InputDevice::AxisEvent(int axis, float value)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool InputDevice::ButtonValue(int padID, ButtonType button)
|
||||
{
|
||||
const auto& binding = _inputbinds.find(std::make_pair(padID, button));
|
||||
|
@ -451,6 +684,7 @@ bool InputDevice::ButtonValue(int padID, ButtonType button)
|
|||
else
|
||||
return (_axises[binding->second->_buttontype] * binding->second->_neg) > 0.5f;
|
||||
}
|
||||
|
||||
float InputDevice::AxisValue(int padID, ButtonType axis)
|
||||
{
|
||||
const auto& binding = _inputbinds.find(std::make_pair(padID, axis));
|
||||
|
|
|
@ -176,6 +176,8 @@ enum ButtonType
|
|||
TURNTABLE_CROSSFADE = 622, // To Be Used on Java Side
|
||||
TURNTABLE_CROSSFADE_LEFT = 623,
|
||||
TURNTABLE_CROSSFADE_RIGHT = 624,
|
||||
// Rumble
|
||||
RUMBLE = 700,
|
||||
};
|
||||
enum ButtonState
|
||||
{
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
// Refer to the license.txt file included.
|
||||
|
||||
#include "InputCommon/ControllerInterface/Android/Android.h"
|
||||
#include <jni/AndroidCommon/IDCache.h>
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
|
||||
namespace ciface
|
||||
|
@ -190,6 +192,8 @@ Touchscreen::Touchscreen(int padID) : _padID(padID)
|
|||
new Axis(_padID, ButtonManager::TURNTABLE_CROSSFADE_RIGHT));
|
||||
AddAnalogInputs(new Axis(_padID, ButtonManager::TURNTABLE_EFFECT_DIAL),
|
||||
new Axis(_padID, ButtonManager::TURNTABLE_EFFECT_DIAL));
|
||||
// Rumble
|
||||
AddOutput(new Motor(_padID, ButtonManager::RUMBLE));
|
||||
}
|
||||
// Buttons and stuff
|
||||
|
||||
|
@ -215,5 +219,34 @@ ControlState Touchscreen::Axis::GetState() const
|
|||
{
|
||||
return ButtonManager::GetAxisValue(_padID, _index) * _neg;
|
||||
}
|
||||
|
||||
Touchscreen::Motor::~Motor()
|
||||
{
|
||||
}
|
||||
|
||||
std::string Touchscreen::Motor::GetName() const
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "Rumble " << (int)_index;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void Touchscreen::Motor::SetState(ControlState state)
|
||||
{
|
||||
if (state > 0)
|
||||
{
|
||||
std::thread(Rumble, _padID, state).detach();
|
||||
}
|
||||
}
|
||||
|
||||
void Touchscreen::Motor::Rumble(int padID, double state)
|
||||
{
|
||||
JNIEnv* env;
|
||||
IDCache::GetJavaVM()->AttachCurrentThread(&env, nullptr);
|
||||
jmethodID rumbleMethod =
|
||||
env->GetStaticMethodID(IDCache::GetNativeLibraryClass(), "rumble", "(ID)V");
|
||||
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), rumbleMethod, padID, state);
|
||||
IDCache::GetJavaVM()->DetachCurrentThread();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,19 @@ private:
|
|||
const ButtonManager::ButtonType _index;
|
||||
const float _neg;
|
||||
};
|
||||
class Motor : public Core::Device::Output
|
||||
{
|
||||
public:
|
||||
Motor(int padID, ButtonManager::ButtonType index) : _padID(padID), _index(index) {}
|
||||
~Motor();
|
||||
std::string GetName() const override;
|
||||
void SetState(ControlState state) override;
|
||||
|
||||
private:
|
||||
const int _padID;
|
||||
const ButtonManager::ButtonType _index;
|
||||
static void Rumble(int padID, double state);
|
||||
};
|
||||
|
||||
public:
|
||||
Touchscreen(int padID);
|
||||
|
|
Loading…
Reference in New Issue