Add vibration support and swap next/prev weapon

This commit is contained in:
a1batross 2015-12-06 13:06:26 +03:00
parent aa3e0b7416
commit 7dfb65760d
4 changed files with 22 additions and 5 deletions

View file

@ -24,10 +24,9 @@
android:hardwareAccelerated="true"> android:hardwareAccelerated="true">
<activity android:name="in.celest.xash3d.LauncherActivity" <activity android:name="in.celest.xash3d.LauncherActivity"
android:label="@string/launcher_name" android:label="@string/launcher_name"
android:windowSoftInputMode="adjustResize" android:windowSoftInputMode="adjustResize">
>
<intent-filter> <intent-filter>
<action android:name="in.celest.xash3d.LauncherActivity"/> <action android:name="in.celest.xash3d.LauncherActivity"/>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
@ -76,5 +75,6 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
</manifest> </manifest>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -32,6 +32,7 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.os.Vibrator;
import android.util.Log; import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.Display; import android.view.Display;
@ -77,6 +78,8 @@ public class SDLActivity extends Activity {
// If we want to separate mouse and touch events. // If we want to separate mouse and touch events.
// This is only toggled in native code when a hint is set! // This is only toggled in native code when a hint is set!
public static boolean mSeparateMouseAndTouch; public static boolean mSeparateMouseAndTouch;
private static Vibrator mVibrator;
// Main components // Main components
protected static SDLActivity mSingleton; protected static SDLActivity mSingleton;
@ -136,6 +139,7 @@ public class SDLActivity extends Activity {
// The static nature of the singleton and Android quirkyness force us to initialize everything here // The static nature of the singleton and Android quirkyness force us to initialize everything here
// Otherwise, when exiting the app and returning to it, these variables *keep* their pre exit values // Otherwise, when exiting the app and returning to it, these variables *keep* their pre exit values
mSingleton = null; mSingleton = null;
mVibrator = null;
mSurface = null; mSurface = null;
mTextEdit = null; mTextEdit = null;
mLayout = null; mLayout = null;
@ -174,7 +178,7 @@ public class SDLActivity extends Activity {
// So we can call stuff from static callbacks // So we can call stuff from static callbacks
mSingleton = this; mSingleton = this;
mPref = this.getSharedPreferences("engine", 0); mPref = this.getSharedPreferences("engine", 0);
mUseControls = mPref.getBoolean("controls", false); mUseControls = mPref.getBoolean("controls", true);
mUseVolume = mPref.getBoolean("usevolume", false); mUseVolume = mPref.getBoolean("usevolume", false);
// Load shared libraries // Load shared libraries
String errorMsgBrokenLib = ""; String errorMsgBrokenLib = "";
@ -261,6 +265,8 @@ public class SDLActivity extends Activity {
return; return;
} }
mVibrator.cancel();
SDLActivity.handlePause(); SDLActivity.handlePause();
} }
@ -308,6 +314,8 @@ public class SDLActivity extends Activity {
protected void onDestroy() { protected void onDestroy() {
Log.v("SDL", "onDestroy()"); Log.v("SDL", "onDestroy()");
mVibrator.cancel();
if (SDLActivity.mBrokenLibraries) { if (SDLActivity.mBrokenLibraries) {
super.onDestroy(); super.onDestroy();
// Reset everything in case the user re opens the app // Reset everything in case the user re opens the app
@ -499,7 +507,16 @@ public class SDLActivity extends Activity {
public static void flipBuffers() { public static void flipBuffers() {
SDLActivity.nativeFlipBuffers(); SDLActivity.nativeFlipBuffers();
} }
/**
* This method is called by Xash3D engine using JNI
*/
public void vibrate( short time ) {
mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
mVibrator.vibrate( time );
}
/** /**
* This method is called by SDL using JNI. * This method is called by SDL using JNI.
*/ */