Added adjustable vibration duration
This commit is contained in:
parent
1095ffbcf1
commit
e0e25d0668
|
@ -67,6 +67,59 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:id="@+id/vibDuration_layout" >
|
||||||
|
|
||||||
|
<TableRow
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/vibDuration_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/vibration_duration" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="right"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/vibDuration_current"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:ems="5"
|
||||||
|
android:gravity="center_vertical|right"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:layout_marginRight="10dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<SeekBar
|
||||||
|
android:id="@+id/vib_seekBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:ems="10"
|
||||||
|
android:max="60"
|
||||||
|
android:progress="0"
|
||||||
|
android:layout_weight="0.50"
|
||||||
|
android:layout_marginLeft="30dip"
|
||||||
|
android:layout_marginRight="30dip"
|
||||||
|
android:layout_marginTop="10dip" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
android:layout_marginTop="25dp"
|
android:layout_marginTop="25dp"
|
||||||
android:gravity="center_vertical" >
|
android:gravity="center_vertical" >
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
<string name="customize_touch_controls">Customize Touch Controls</string>
|
<string name="customize_touch_controls">Customize Touch Controls</string>
|
||||||
<string name="launch_editor">Launch Editor</string>
|
<string name="launch_editor">Launch Editor</string>
|
||||||
<string name="touch_vibration">Haptic Feedback</string>
|
<string name="touch_vibration">Haptic Feedback</string>
|
||||||
|
<string name="vibration_duration">Duration of Haptic Feedback</string>
|
||||||
<string name="controller_a">Controller A</string>
|
<string name="controller_a">Controller A</string>
|
||||||
<string name="controller_b">Controller B</string>
|
<string name="controller_b">Controller B</string>
|
||||||
<string name="controller_c">Controller C</string>
|
<string name="controller_c">Controller C</string>
|
||||||
|
|
|
@ -37,6 +37,7 @@ public class Config {
|
||||||
public static final String pref_renderdepth = "depth_render";
|
public static final String pref_renderdepth = "depth_render";
|
||||||
|
|
||||||
public static final String pref_touchvibe = "touch_vibration_enabled";
|
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_mic = "mic_plugged_in";
|
||||||
public static final String pref_vmu = "vmu_floating";
|
public static final String pref_vmu = "vmu_floating";
|
||||||
|
|
||||||
|
@ -56,6 +57,7 @@ public class Config {
|
||||||
public static boolean pvrrender = false;
|
public static boolean pvrrender = false;
|
||||||
public static String cheatdisk = "null";
|
public static String cheatdisk = "null";
|
||||||
public static boolean nativeact = false;
|
public static boolean nativeact = false;
|
||||||
|
public static int vibrationDuration = 20;
|
||||||
|
|
||||||
private SharedPreferences mPrefs;
|
private SharedPreferences mPrefs;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.reicast.emulator.config;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
@ -10,6 +11,7 @@ import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.Vibrator;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -22,6 +24,8 @@ import android.widget.Button;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.SeekBar;
|
||||||
import android.widget.TableLayout;
|
import android.widget.TableLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -48,6 +52,7 @@ public class InputFragment extends Fragment {
|
||||||
|
|
||||||
private Gamepad pad = new Gamepad();
|
private Gamepad pad = new Gamepad();
|
||||||
public MOGAInput moga = new MOGAInput();
|
public MOGAInput moga = new MOGAInput();
|
||||||
|
Vibrator vib;
|
||||||
|
|
||||||
// Container Activity must implement this interface
|
// Container Activity must implement this interface
|
||||||
public interface OnClickListener {
|
public interface OnClickListener {
|
||||||
|
@ -70,6 +75,9 @@ public class InputFragment extends Fragment {
|
||||||
sharedPreferences = PreferenceManager
|
sharedPreferences = PreferenceManager
|
||||||
.getDefaultSharedPreferences(parentActivity);
|
.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) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||||
ImageView icon_a = (ImageView) getView().findViewById(
|
ImageView icon_a = (ImageView) getView().findViewById(
|
||||||
R.id.controller_icon_a);
|
R.id.controller_icon_a);
|
||||||
|
@ -97,11 +105,42 @@ public class InputFragment extends Fragment {
|
||||||
if (!MainActivity.isBiosExisting() || !MainActivity.isFlashExisting())
|
if (!MainActivity.isBiosExisting() || !MainActivity.isFlashExisting())
|
||||||
buttonLaunchEditor.setEnabled(false);
|
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() {
|
OnCheckedChangeListener touch_vibration = new OnCheckedChangeListener() {
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView,
|
||||||
boolean isChecked) {
|
boolean isChecked) {
|
||||||
sharedPreferences.edit()
|
sharedPreferences.edit()
|
||||||
.putBoolean(Config.pref_touchvibe, isChecked).commit();
|
.putBoolean(Config.pref_touchvibe, isChecked).commit();
|
||||||
|
vibLay.setVisibility( isChecked ? View.VISIBLE : View.GONE );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
switchTouchVibrationEnabled = (Switch) getView().findViewById(
|
switchTouchVibrationEnabled = (Switch) getView().findViewById(
|
||||||
|
|
|
@ -83,6 +83,7 @@ public class GL2JNIView extends GLSurfaceView
|
||||||
Renderer rend;
|
Renderer rend;
|
||||||
|
|
||||||
private boolean touchVibrationEnabled;
|
private boolean touchVibrationEnabled;
|
||||||
|
private int vibrationDuration;
|
||||||
Context context;
|
Context context;
|
||||||
|
|
||||||
public void restoreCustomVjoyValues(float[][] vjoy_d_cached) {
|
public void restoreCustomVjoyValues(float[][] vjoy_d_cached) {
|
||||||
|
@ -150,6 +151,7 @@ public class GL2JNIView extends GLSurfaceView
|
||||||
ethd = new EmuThread(!Config.nosound);
|
ethd = new EmuThread(!Config.nosound);
|
||||||
|
|
||||||
touchVibrationEnabled = prefs.getBoolean(Config.pref_touchvibe, true);
|
touchVibrationEnabled = prefs.getBoolean(Config.pref_touchvibe, true);
|
||||||
|
vibrationDuration = prefs.getInt(Config.pref_vibrationDuration, 20);
|
||||||
|
|
||||||
int renderType = prefs.getInt(Config.pref_rendertype, LAYER_TYPE_HARDWARE);
|
int renderType = prefs.getInt(Config.pref_rendertype, LAYER_TYPE_HARDWARE);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||||
|
@ -389,7 +391,7 @@ public class GL2JNIView extends GLSurfaceView
|
||||||
{
|
{
|
||||||
if (vjoy[j][5]==0)
|
if (vjoy[j][5]==0)
|
||||||
if (!editVjoyMode && touchVibrationEnabled)
|
if (!editVjoyMode && touchVibrationEnabled)
|
||||||
vib.vibrate(50);
|
vib.vibrate(vibrationDuration);
|
||||||
vjoy[j][5]=2;
|
vjoy[j][5]=2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue