mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 16:19:28 +01:00
Android: Remove old rumble implementation
This commit is contained in:
parent
9e7a2ee0fb
commit
68ebb5c33e
@ -18,7 +18,6 @@ import org.dolphinemu.dolphinemu.activities.EmulationActivity;
|
|||||||
import org.dolphinemu.dolphinemu.dialogs.AlertMessage;
|
import org.dolphinemu.dolphinemu.dialogs.AlertMessage;
|
||||||
import org.dolphinemu.dolphinemu.utils.CompressCallback;
|
import org.dolphinemu.dolphinemu.utils.CompressCallback;
|
||||||
import org.dolphinemu.dolphinemu.utils.Log;
|
import org.dolphinemu.dolphinemu.utils.Log;
|
||||||
import org.dolphinemu.dolphinemu.utils.Rumble;
|
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
@ -234,25 +233,6 @@ public final class NativeLibrary
|
|||||||
// Disallows instantiation.
|
// Disallows instantiation.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
@Keep
|
|
||||||
public static void rumble(int padID, double state)
|
|
||||||
{
|
|
||||||
final EmulationActivity emulationActivity = sEmulationActivity.get();
|
|
||||||
if (emulationActivity == null)
|
|
||||||
{
|
|
||||||
Log.warning("[NativeLibrary] EmulationActivity is null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Rumble.checkRumble(padID, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Dolphin version string.
|
* Gets the Dolphin version string.
|
||||||
*
|
*
|
||||||
|
@ -64,7 +64,6 @@ import org.dolphinemu.dolphinemu.utils.AfterDirectoryInitializationRunner;
|
|||||||
import org.dolphinemu.dolphinemu.utils.ControllerMappingHelper;
|
import org.dolphinemu.dolphinemu.utils.ControllerMappingHelper;
|
||||||
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
|
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
|
||||||
import org.dolphinemu.dolphinemu.utils.IniFile;
|
import org.dolphinemu.dolphinemu.utils.IniFile;
|
||||||
import org.dolphinemu.dolphinemu.utils.Rumble;
|
|
||||||
import org.dolphinemu.dolphinemu.utils.ThemeHelper;
|
import org.dolphinemu.dolphinemu.utils.ThemeHelper;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -157,7 +156,6 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
|||||||
public static final int MENU_ACTION_EXIT = 22;
|
public static final int MENU_ACTION_EXIT = 22;
|
||||||
public static final int MENU_ACTION_CHANGE_DISC = 23;
|
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_JOYSTICK_REL_CENTER = 24;
|
||||||
public static final int MENU_ACTION_RUMBLE = 25;
|
|
||||||
public static final int MENU_ACTION_RESET_OVERLAY = 26;
|
public static final int MENU_ACTION_RESET_OVERLAY = 26;
|
||||||
public static final int MENU_SET_IR_RECENTER = 27;
|
public static final int MENU_SET_IR_RECENTER = 27;
|
||||||
public static final int MENU_SET_IR_MODE = 28;
|
public static final int MENU_SET_IR_MODE = 28;
|
||||||
@ -192,7 +190,6 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
|||||||
EmulationActivity.MENU_ACTION_CHOOSE_CONTROLLER);
|
EmulationActivity.MENU_ACTION_CHOOSE_CONTROLLER);
|
||||||
buttonsActionsMap.append(R.id.menu_emulation_joystick_rel_center,
|
buttonsActionsMap.append(R.id.menu_emulation_joystick_rel_center,
|
||||||
EmulationActivity.MENU_ACTION_JOYSTICK_REL_CENTER);
|
EmulationActivity.MENU_ACTION_JOYSTICK_REL_CENTER);
|
||||||
buttonsActionsMap.append(R.id.menu_emulation_rumble, EmulationActivity.MENU_ACTION_RUMBLE);
|
|
||||||
buttonsActionsMap
|
buttonsActionsMap
|
||||||
.append(R.id.menu_emulation_reset_overlay, EmulationActivity.MENU_ACTION_RESET_OVERLAY);
|
.append(R.id.menu_emulation_reset_overlay, EmulationActivity.MENU_ACTION_RESET_OVERLAY);
|
||||||
buttonsActionsMap.append(R.id.menu_emulation_ir_recenter,
|
buttonsActionsMap.append(R.id.menu_emulation_ir_recenter,
|
||||||
@ -360,8 +357,6 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
|||||||
// Set these options now so that the SurfaceView the game renders into is the right size.
|
// Set these options now so that the SurfaceView the game renders into is the right size.
|
||||||
enableFullscreenImmersive();
|
enableFullscreenImmersive();
|
||||||
|
|
||||||
Rumble.initRumble(this);
|
|
||||||
|
|
||||||
ActivityEmulationBinding binding = ActivityEmulationBinding.inflate(getLayoutInflater());
|
ActivityEmulationBinding binding = ActivityEmulationBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
@ -627,8 +622,6 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
|||||||
// Populate the switch value for joystick center on touch
|
// Populate the switch value for joystick center on touch
|
||||||
menu.findItem(R.id.menu_emulation_joystick_rel_center)
|
menu.findItem(R.id.menu_emulation_joystick_rel_center)
|
||||||
.setChecked(BooleanSetting.MAIN_JOYSTICK_REL_CENTER.getBoolean(mSettings));
|
.setChecked(BooleanSetting.MAIN_JOYSTICK_REL_CENTER.getBoolean(mSettings));
|
||||||
menu.findItem(R.id.menu_emulation_rumble)
|
|
||||||
.setChecked(BooleanSetting.MAIN_PHONE_RUMBLE.getBoolean(mSettings));
|
|
||||||
if (wii)
|
if (wii)
|
||||||
{
|
{
|
||||||
menu.findItem(R.id.menu_emulation_ir_recenter)
|
menu.findItem(R.id.menu_emulation_ir_recenter)
|
||||||
@ -668,10 +661,6 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
|||||||
item.setChecked(!item.isChecked());
|
item.setChecked(!item.isChecked());
|
||||||
toggleJoystickRelCenter(item.isChecked());
|
toggleJoystickRelCenter(item.isChecked());
|
||||||
break;
|
break;
|
||||||
case MENU_ACTION_RUMBLE:
|
|
||||||
item.setChecked(!item.isChecked());
|
|
||||||
toggleRumble(item.isChecked());
|
|
||||||
break;
|
|
||||||
case MENU_SET_IR_RECENTER:
|
case MENU_SET_IR_RECENTER:
|
||||||
item.setChecked(!item.isChecked());
|
item.setChecked(!item.isChecked());
|
||||||
toggleRecenter(item.isChecked());
|
toggleRecenter(item.isChecked());
|
||||||
@ -842,12 +831,6 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
|||||||
BooleanSetting.MAIN_JOYSTICK_REL_CENTER.setBoolean(mSettings, state);
|
BooleanSetting.MAIN_JOYSTICK_REL_CENTER.setBoolean(mSettings, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleRumble(boolean state)
|
|
||||||
{
|
|
||||||
BooleanSetting.MAIN_PHONE_RUMBLE.setBoolean(mSettings, state);
|
|
||||||
Rumble.setPhoneVibrator(state, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toggleRecenter(boolean state)
|
private void toggleRecenter(boolean state)
|
||||||
{
|
{
|
||||||
BooleanSetting.MAIN_IR_ALWAYS_RECENTER.setBoolean(mSettings, state);
|
BooleanSetting.MAIN_IR_ALWAYS_RECENTER.setBoolean(mSettings, state);
|
||||||
|
@ -100,8 +100,6 @@ public enum BooleanSetting implements AbstractBooleanSetting
|
|||||||
"UseBlackBackgrounds", false),
|
"UseBlackBackgrounds", false),
|
||||||
MAIN_JOYSTICK_REL_CENTER(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,
|
MAIN_JOYSTICK_REL_CENTER(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,
|
||||||
"JoystickRelCenter", true),
|
"JoystickRelCenter", true),
|
||||||
MAIN_PHONE_RUMBLE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,
|
|
||||||
"PhoneRumble", true),
|
|
||||||
MAIN_SHOW_INPUT_OVERLAY(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,
|
MAIN_SHOW_INPUT_OVERLAY(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,
|
||||||
"ShowInputOverlay", true),
|
"ShowInputOverlay", true),
|
||||||
MAIN_IR_ALWAYS_RECENTER(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,
|
MAIN_IR_ALWAYS_RECENTER(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,
|
||||||
|
@ -1,97 +0,0 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
package org.dolphinemu.dolphinemu.utils;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.VibrationEffect;
|
|
||||||
import android.os.Vibrator;
|
|
||||||
import android.util.SparseArray;
|
|
||||||
import android.view.InputDevice;
|
|
||||||
|
|
||||||
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
|
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.AdHocStringSetting;
|
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
|
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
|
|
||||||
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
|
|
||||||
|
|
||||||
public class Rumble
|
|
||||||
{
|
|
||||||
private static Vibrator phoneVibrator;
|
|
||||||
private static final SparseArray<Vibrator> emuVibrators = new SparseArray<>();
|
|
||||||
|
|
||||||
public static void initRumble(EmulationActivity activity)
|
|
||||||
{
|
|
||||||
clear();
|
|
||||||
|
|
||||||
if (BooleanSetting.MAIN_PHONE_RUMBLE.getBooleanGlobal())
|
|
||||||
{
|
|
||||||
setPhoneVibrator(true, activity);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++)
|
|
||||||
{
|
|
||||||
String deviceName = AdHocStringSetting.getStringGlobal(Settings.FILE_DOLPHIN,
|
|
||||||
Settings.SECTION_BINDINGS, SettingsFile.KEY_EMU_RUMBLE + i, "");
|
|
||||||
|
|
||||||
if (!deviceName.isEmpty())
|
|
||||||
{
|
|
||||||
for (int id : InputDevice.getDeviceIds())
|
|
||||||
{
|
|
||||||
InputDevice device = InputDevice.getDevice(id);
|
|
||||||
if (deviceName.equals(device.getDescriptor()))
|
|
||||||
{
|
|
||||||
Vibrator vib = device.getVibrator();
|
|
||||||
if (vib != null && vib.hasVibrator())
|
|
||||||
emuVibrators.put(i, vib);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setPhoneVibrator(boolean set, EmulationActivity activity)
|
|
||||||
{
|
|
||||||
if (set)
|
|
||||||
{
|
|
||||||
Vibrator vib = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
|
|
||||||
if (vib != null && vib.hasVibrator())
|
|
||||||
phoneVibrator = vib;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
phoneVibrator = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void clear()
|
|
||||||
{
|
|
||||||
phoneVibrator = null;
|
|
||||||
emuVibrators.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void checkRumble(int padId, double state)
|
|
||||||
{
|
|
||||||
if (phoneVibrator != null)
|
|
||||||
doRumble(phoneVibrator);
|
|
||||||
|
|
||||||
if (emuVibrators.get(padId) != null)
|
|
||||||
doRumble(emuVibrators.get(padId));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void doRumble(Vibrator vib)
|
|
||||||
{
|
|
||||||
// Check again that it exists and can vibrate
|
|
||||||
if (vib != null && vib.hasVibrator())
|
|
||||||
{
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
|
||||||
{
|
|
||||||
vib.vibrate(VibrationEffect.createOneShot(100, VibrationEffect.DEFAULT_AMPLITUDE));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vib.vibrate(100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,11 +19,6 @@
|
|||||||
android:checkable="true"
|
android:checkable="true"
|
||||||
android:title="@string/emulation_control_joystick_rel_center"/>
|
android:title="@string/emulation_control_joystick_rel_center"/>
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_emulation_rumble"
|
|
||||||
android:checkable="true"
|
|
||||||
android:title="@string/emulation_control_rumble"/>
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_emulation_reset_overlay"
|
android:id="@+id/menu_emulation_reset_overlay"
|
||||||
android:title="@string/emulation_touch_overlay_reset"/>
|
android:title="@string/emulation_touch_overlay_reset"/>
|
||||||
|
@ -19,11 +19,6 @@
|
|||||||
android:id="@+id/menu_emulation_joystick_rel_center"
|
android:id="@+id/menu_emulation_joystick_rel_center"
|
||||||
android:checkable="true"
|
android:checkable="true"
|
||||||
android:title="@string/emulation_control_joystick_rel_center"/>
|
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>
|
</group>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
|
@ -13,7 +13,6 @@ static jclass s_string_class;
|
|||||||
|
|
||||||
static jclass s_native_library_class;
|
static jclass s_native_library_class;
|
||||||
static jmethodID s_display_alert_msg;
|
static jmethodID s_display_alert_msg;
|
||||||
static jmethodID s_do_rumble;
|
|
||||||
static jmethodID s_update_touch_pointer;
|
static jmethodID s_update_touch_pointer;
|
||||||
static jmethodID s_on_title_changed;
|
static jmethodID s_on_title_changed;
|
||||||
static jmethodID s_finish_emulation_activity;
|
static jmethodID s_finish_emulation_activity;
|
||||||
@ -124,11 +123,6 @@ jmethodID GetDisplayAlertMsg()
|
|||||||
return s_display_alert_msg;
|
return s_display_alert_msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID GetDoRumble()
|
|
||||||
{
|
|
||||||
return s_do_rumble;
|
|
||||||
}
|
|
||||||
|
|
||||||
jmethodID GetUpdateTouchPointer()
|
jmethodID GetUpdateTouchPointer()
|
||||||
{
|
{
|
||||||
return s_update_touch_pointer;
|
return s_update_touch_pointer;
|
||||||
@ -408,7 +402,6 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
|
|||||||
s_native_library_class = reinterpret_cast<jclass>(env->NewGlobalRef(native_library_class));
|
s_native_library_class = reinterpret_cast<jclass>(env->NewGlobalRef(native_library_class));
|
||||||
s_display_alert_msg = env->GetStaticMethodID(s_native_library_class, "displayAlertMsg",
|
s_display_alert_msg = env->GetStaticMethodID(s_native_library_class, "displayAlertMsg",
|
||||||
"(Ljava/lang/String;Ljava/lang/String;ZZZ)Z");
|
"(Ljava/lang/String;Ljava/lang/String;ZZZ)Z");
|
||||||
s_do_rumble = env->GetStaticMethodID(s_native_library_class, "rumble", "(ID)V");
|
|
||||||
s_update_touch_pointer =
|
s_update_touch_pointer =
|
||||||
env->GetStaticMethodID(s_native_library_class, "updateTouchPointer", "()V");
|
env->GetStaticMethodID(s_native_library_class, "updateTouchPointer", "()V");
|
||||||
s_on_title_changed = env->GetStaticMethodID(s_native_library_class, "onTitleChanged", "()V");
|
s_on_title_changed = env->GetStaticMethodID(s_native_library_class, "onTitleChanged", "()V");
|
||||||
|
@ -13,7 +13,6 @@ jclass GetStringClass();
|
|||||||
|
|
||||||
jclass GetNativeLibraryClass();
|
jclass GetNativeLibraryClass();
|
||||||
jmethodID GetDisplayAlertMsg();
|
jmethodID GetDisplayAlertMsg();
|
||||||
jmethodID GetDoRumble();
|
|
||||||
jmethodID GetUpdateTouchPointer();
|
jmethodID GetUpdateTouchPointer();
|
||||||
jmethodID GetOnTitleChanged();
|
jmethodID GetOnTitleChanged();
|
||||||
jmethodID GetFinishEmulationActivity();
|
jmethodID GetFinishEmulationActivity();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user