diff --git a/shell/android/res/layout/input_fragment.xml b/shell/android/res/layout/input_fragment.xml
index 3c1814a94..bc7714171 100644
--- a/shell/android/res/layout/input_fragment.xml
+++ b/shell/android/res/layout/input_fragment.xml
@@ -67,6 +67,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/shell/android/res/values/strings.xml b/shell/android/res/values/strings.xml
index 705a57b96..d2d027818 100644
--- a/shell/android/res/values/strings.xml
+++ b/shell/android/res/values/strings.xml
@@ -55,6 +55,7 @@
Customize Touch Controls
Launch Editor
Haptic Feedback
+ Duration of Haptic Feedback
Controller A
Controller B
Controller C
diff --git a/shell/android/src/com/reicast/emulator/config/Config.java b/shell/android/src/com/reicast/emulator/config/Config.java
index 4f71ea8e6..44a35db83 100644
--- a/shell/android/src/com/reicast/emulator/config/Config.java
+++ b/shell/android/src/com/reicast/emulator/config/Config.java
@@ -37,6 +37,7 @@ public class Config {
public static final String pref_renderdepth = "depth_render";
public static final String pref_touchvibe = "touch_vibration_enabled";
+ public static final String pref_vibrationDuration = "vibration_duration";
public static final String pref_mic = "mic_plugged_in";
public static final String pref_vmu = "vmu_floating";
@@ -56,6 +57,7 @@ public class Config {
public static boolean pvrrender = false;
public static String cheatdisk = "null";
public static boolean nativeact = false;
+ public static int vibrationDuration = 20;
private SharedPreferences mPrefs;
diff --git a/shell/android/src/com/reicast/emulator/config/InputFragment.java b/shell/android/src/com/reicast/emulator/config/InputFragment.java
index 5875ed689..f2340963f 100644
--- a/shell/android/src/com/reicast/emulator/config/InputFragment.java
+++ b/shell/android/src/com/reicast/emulator/config/InputFragment.java
@@ -3,6 +3,7 @@ package com.reicast.emulator.config;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -10,6 +11,7 @@ import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
+import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.util.Log;
@@ -22,6 +24,8 @@ import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.SeekBar;
import android.widget.TableLayout;
import android.widget.TextView;
import android.widget.Toast;
@@ -48,6 +52,7 @@ public class InputFragment extends Fragment {
private Gamepad pad = new Gamepad();
public MOGAInput moga = new MOGAInput();
+ Vibrator vib;
// Container Activity must implement this interface
public interface OnClickListener {
@@ -70,6 +75,9 @@ public class InputFragment extends Fragment {
sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(parentActivity);
+ Config.vibrationDuration = sharedPreferences.getInt(Config.pref_vibrationDuration, 20);
+ vib = (Vibrator) parentActivity.getSystemService(Context.VIBRATOR_SERVICE);
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
ImageView icon_a = (ImageView) getView().findViewById(
R.id.controller_icon_a);
@@ -97,11 +105,42 @@ public class InputFragment extends Fragment {
if (!MainActivity.isBiosExisting() || !MainActivity.isFlashExisting())
buttonLaunchEditor.setEnabled(false);
+ final TextView duration = (TextView) getView().findViewById(R.id.vibDuration_current);
+ final LinearLayout vibLay = (LinearLayout) getView().findViewById(R.id.vibDuration_layout);
+ final SeekBar vibSeek = (SeekBar) getView().findViewById(R.id.vib_seekBar);
+
+ if (sharedPreferences.getBoolean(Config.pref_touchvibe, true)) {
+ vibLay.setVisibility(View.VISIBLE);
+ } else {
+ vibLay.setVisibility(View.GONE);
+ }
+
+ duration.setText(String.valueOf(Config.vibrationDuration + " ms"));
+ vibSeek.setProgress(Config.vibrationDuration);
+
+ vibSeek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ duration.setText(String.valueOf(progress + 5 + " ms"));
+ }
+
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ // TODO Auto-generated method stub
+ }
+
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ int progress = seekBar.getProgress() + 5;
+ sharedPreferences.edit().putInt(Config.pref_vibrationDuration, progress).commit();
+ Config.vibrationDuration = progress;
+ vib.vibrate(progress);
+ }
+ });
+
OnCheckedChangeListener touch_vibration = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
sharedPreferences.edit()
.putBoolean(Config.pref_touchvibe, isChecked).commit();
+ vibLay.setVisibility( isChecked ? View.VISIBLE : View.GONE );
}
};
switchTouchVibrationEnabled = (Switch) getView().findViewById(
diff --git a/shell/android/src/com/reicast/emulator/emu/GL2JNIView.java b/shell/android/src/com/reicast/emulator/emu/GL2JNIView.java
index 4af792679..ae64512ad 100644
--- a/shell/android/src/com/reicast/emulator/emu/GL2JNIView.java
+++ b/shell/android/src/com/reicast/emulator/emu/GL2JNIView.java
@@ -83,6 +83,7 @@ public class GL2JNIView extends GLSurfaceView
Renderer rend;
private boolean touchVibrationEnabled;
+ private int vibrationDuration;
Context context;
public void restoreCustomVjoyValues(float[][] vjoy_d_cached) {
@@ -150,6 +151,7 @@ public class GL2JNIView extends GLSurfaceView
ethd = new EmuThread(!Config.nosound);
touchVibrationEnabled = prefs.getBoolean(Config.pref_touchvibe, true);
+ vibrationDuration = prefs.getInt(Config.pref_vibrationDuration, 20);
int renderType = prefs.getInt(Config.pref_rendertype, LAYER_TYPE_HARDWARE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
@@ -389,7 +391,7 @@ public class GL2JNIView extends GLSurfaceView
{
if (vjoy[j][5]==0)
if (!editVjoyMode && touchVibrationEnabled)
- vib.vibrate(50);
+ vib.vibrate(vibrationDuration);
vjoy[j][5]=2;
}