diff --git a/android/app/libs/haptic_service.aar b/android/app/libs/haptic_service.aar index 9c2dfc7e..6197bf36 100644 Binary files a/android/app/libs/haptic_service.aar and b/android/app/libs/haptic_service.aar differ diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 5bd94c9d..390df5c7 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="55" + android:versionName="1.1.0"> diff --git a/android/app/src/main/cpp/code/cgame/cg_weapons.c b/android/app/src/main/cpp/code/cgame/cg_weapons.c index 414a18c3..11070704 100644 --- a/android/app/src/main/cpp/code/cgame/cg_weapons.c +++ b/android/app/src/main/cpp/code/cgame/cg_weapons.c @@ -1318,6 +1318,10 @@ static void CG_LightningBolt( centity_t *cent, vec3_t origin ) { vec3_t angle; CG_CalculateVRWeaponPosition(muzzlePoint, angle); AngleVectors(angle, forward, NULL, NULL ); + + //Handle this here so it is refreshed on every frame, not just when the lightning gun is first fired + int position = vr->weapon_stabilised ? 4 : (vr->right_handed ? 1 : 2); + trap_HapticEvent("RTCWQuest:fire_tesla", position, 0, 100, 0, 0); } else { // !CPMA AngleVectors( cent->lerpAngles, forward, NULL, NULL ); @@ -2529,7 +2533,7 @@ void CG_FireWeapon( centity_t *cent ) { trap_HapticEvent("rocket_fire", position, 0, 100, 0, 0); break; case WP_LIGHTNING: - trap_HapticEvent("RTCWQuest:fire_tesla", position, 0, 100, 0, 0); + //Haptics handled in the CG_LightningBolt code break; case WP_RAILGUN: trap_HapticEvent("RTCWQuest:fire_sniper", position, 0, 100, 0, 0); @@ -2543,7 +2547,7 @@ void CG_FireWeapon( centity_t *cent ) { trap_HapticEvent("bfg_fire", position, 0, 100, 0, 0); break; case WP_GRAPPLING_HOOK: - trap_HapticEvent("chainsaw_fire", position, 0, 100, 0, 0); + //No Haptics break; #ifdef MISSIONPACK case WP_NAILGUN: diff --git a/android/app/src/main/cpp/code/q3_ui/ui_credits.c b/android/app/src/main/cpp/code/q3_ui/ui_credits.c index 1153b886..f7b16c92 100644 --- a/android/app/src/main/cpp/code/q3_ui/ui_credits.c +++ b/android/app/src/main/cpp/code/q3_ui/ui_credits.c @@ -145,11 +145,11 @@ Special Thanks to the whole discord! y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE; UI_DrawProportionalString( 320, y, "Dedicated Beta Testers", UI_CENTER|UI_SMALLFONT, color_red ); y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE; - UI_DrawString( 320, y, "XQuader, Ceno, Cukier, Bummser, Retro1N, Benny91, April, Ikarus,", UI_CENTER|UI_SMALLFONT, color_white ); + UI_DrawString( 320, y, "f2hunter, XQuader, Ceno, Cukier, Bummser, Retro1N, Benny91, Ikarus,", UI_CENTER|UI_SMALLFONT, color_white ); y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE; UI_DrawString( 320, y, "Bim, Lubos, MasakaPete, Config2, Maniac, Ghostdog72, Slydog43,", UI_CENTER|UI_SMALLFONT, color_white ); y += PROP_HEIGHT * PROP_SMALL_SIZE_SCALE; - UI_DrawString( 320, y, "Cornelius, Ferret, RealityForge, PvtGenO, SatanSlayer", UI_CENTER|UI_SMALLFONT, color_white ); + UI_DrawString( 320, y, "April, Cornelius, Ferret, RealityForge, PvtGenO, SatanSlayer", UI_CENTER|UI_SMALLFONT, color_white ); y += 1.42 * PROP_HEIGHT * PROP_SMALL_SIZE_SCALE; UI_DrawProportionalString( 320, y, "Special Thanks to the whole Team Beef discord!", UI_CENTER|UI_SMALLFONT, color_red ); diff --git a/android/app/src/main/java/com/drbeef/ioq3quest/MainActivity.java b/android/app/src/main/java/com/drbeef/ioq3quest/MainActivity.java index 6aaa683a..c19966e4 100644 --- a/android/app/src/main/java/com/drbeef/ioq3quest/MainActivity.java +++ b/android/app/src/main/java/com/drbeef/ioq3quest/MainActivity.java @@ -1,16 +1,19 @@ package com.drbeef.ioq3quest; import android.Manifest; +import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.AssetManager; import android.os.Bundle; import android.os.RemoteException; import android.util.Log; +import android.util.Pair; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import com.drbeef.externalhapticsservice.HapticServiceClient; +import com.drbeef.externalhapticsservice.HapticsConstants; import org.libsdl.app.SDLActivity; @@ -24,6 +27,7 @@ import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.Vector; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -40,7 +44,11 @@ public class MainActivity extends SDLActivity // implements KeyEvent.Callback String commandLineParams; - private HapticServiceClient externalHapticsServiceClient = null; + private Vector externalHapticsServiceClients = new Vector<>(); + + //Use a vector of pairs, it is possible a given package _could_ in the future support more than one haptic service + //so a map here of Package -> Action would not work. + private static Vector> externalHapticsServiceDetails = new Vector<>(); @Override protected void onCreate(Bundle savedInstanceState) { @@ -53,6 +61,16 @@ public class MainActivity extends SDLActivity // implements KeyEvent.Callback } + @Override protected void onDestroy() + { + Log.i(TAG, "onDestroy called"); + + for (HapticServiceClient externalHapticsServiceClient : externalHapticsServiceClients) { + externalHapticsServiceClient.stopBinding(); + } + + super.onDestroy(); + } /** * Initializes the Activity only if the permission has been granted. @@ -141,11 +159,15 @@ public class MainActivity extends SDLActivity // implements KeyEvent.Callback } catch (Exception e) { } - externalHapticsServiceClient = new HapticServiceClient(this, (state, desc) -> { - Log.v(TAG, "ExternalHapticsService is:" + desc); - }); + for (Pair serviceDetail : externalHapticsServiceDetails) { + HapticServiceClient client = new HapticServiceClient(this, (state, desc) -> { + Log.v(TAG, "ExternalHapticsService " + serviceDetail.second + ": " + desc); + }, new Intent(serviceDetail.second) + .setPackage(serviceDetail.first)); - externalHapticsServiceClient.bindService(); + client.bindService(); + externalHapticsServiceClients.add(client); + } Log.d(TAG, "nativeCreate"); nativeCreate(this); @@ -202,39 +224,48 @@ public class MainActivity extends SDLActivity // implements KeyEvent.Callback static { System.loadLibrary("main"); + + //Add possible external haptic service details here + externalHapticsServiceDetails.add(Pair.create(HapticsConstants.BHAPTICS_PACKAGE, HapticsConstants.BHAPTICS_ACTION_FILTER)); + externalHapticsServiceDetails.add(Pair.create(HapticsConstants.FORCETUBE_PACKAGE, HapticsConstants.FORCETUBE_ACTION_FILTER)); } public void haptic_event(String event, int position, int flags, int intensity, float angle, float yHeight) { - if (externalHapticsServiceClient.hasService()) { - try { - if (!hapticsEnabled) - { - externalHapticsServiceClient.getHapticsService().hapticEnable(); - hapticsEnabled = true; - return; - } + boolean areHapticsEnabled = hapticsEnabled; + for (HapticServiceClient externalHapticsServiceClient : externalHapticsServiceClients) { - if (event.compareTo("frame_tick") == 0) - { - externalHapticsServiceClient.getHapticsService().hapticFrameTick(); - } + if (externalHapticsServiceClient.hasService()) { + try { + //Enabled all haptics services if required + if (!areHapticsEnabled) + { + externalHapticsServiceClient.getHapticsService().hapticEnable(); + hapticsEnabled = true; + continue; + } - //Use the Doom3Quest haptic patterns for now - String app = "Doom3Quest"; - if (event.contains(":")) - { - String[] items = event.split(":"); - app = items[0]; - event = items[1]; + if (event.compareTo("frame_tick") == 0) + { + externalHapticsServiceClient.getHapticsService().hapticFrameTick(); + } + + //Uses the Doom3Quest and RTCWQuest haptic patterns + String app = "Doom3Quest"; + String eventID = event; + if (event.contains(":")) + { + String[] items = event.split(":"); + app = items[0]; + eventID = items[1]; + } + externalHapticsServiceClient.getHapticsService().hapticEvent(app, eventID, position, flags, intensity, angle, yHeight); + } + catch (RemoteException r) + { + Log.v(TAG, r.toString()); } - externalHapticsServiceClient.getHapticsService().hapticEvent(app, event, position, flags, intensity, angle, yHeight); - } - catch (RemoteException r) - { - Log.v(TAG, r.toString()); } } } - } diff --git a/android/run.bat b/android/run.bat index d37d5876..3aec3a18 100644 --- a/android/run.bat +++ b/android/run.bat @@ -2,8 +2,8 @@ setlocal -set BUILD_TYPE=release -set VERSION=1.0.0-rc3 +set BUILD_TYPE=debug +set VERSION=1.1.0 @REM Define the following environment variables to sign a release build @REM set KEYSTORE=