17 #ifndef ANDROIDACTIVITY_H
18 #define ANDROIDACTIVITY_H
22 #if defined(Q_OS_ANDROID)
24 #include <GameInput/JoystickAxisCodes.h>
25 #include <GameInput/KeyCodes.h>
26 #include <GameInput/TriggerAxisCodes.h>
31 #include "SelfDetachingJNIEnv.h"
91 static void onCreate(JNIEnv* jni, jobject activity);
118 static void onDestroy(JNIEnv* jni, jobject activity);
187 static void onCloudDataLoaded(JNIEnv* jni, jobject,
int statusCode, jstring javaData);
337 const QString& label,
long value);
347 static bool onKeyEvent(JNIEnv* jni, jobject keyEvent,
ControllerEvent* controllerEvent);
348 static jclass getSoundManagerClass(JNIEnv* jni, jobject soundManager =
nullptr);
349 static jclass getMotionEventClass(JNIEnv* jni, jobject motionEvent =
nullptr);
350 static jclass getKeyEventClass(JNIEnv* jni, jobject keyEvent =
nullptr);
351 static jclass getInputDeviceClass(JNIEnv* jni, jobject inputDevice =
nullptr);
352 static jclass getMotionRangeClass(JNIEnv* jni, jobject motionRange =
nullptr);
353 static jclass getDebugClass(JNIEnv* jni);
355 static int getMotionEventDeviceId(JNIEnv* jni, jobject motionEvent);
356 static KeyCode getKeyCode(JNIEnv* jni, jobject keyEvent);
357 static int getKeyAction(JNIEnv* jni, jobject keyEvent);
358 static int getKeyEventDeviceId(JNIEnv* jni, jobject keyEvent);
359 static jobject getInputDevice(JNIEnv* jni, jobject motionEvent);
360 static jobject getMotionRange(JNIEnv* jni, jobject motionEvent,
int axis);
365 static float getAxisValue(JNIEnv* jni, jobject motionEvent,
int axis,
float* flatOut =
nullptr,
366 float* minOut =
nullptr,
float* rangeOut =
nullptr);
370 static float getNormalizedJoystickAxisValue(JNIEnv* jni, jobject motionEvent,
int axis);
375 static bool shouldConsumeTranslatedEvents();
377 static jobject getSoundManager();
386 static jobject sActivity;
388 static jclass sActivityClass;
389 static jclass sSoundManagerClass;
390 static jclass sMotionEventClass;
391 static jclass sKeyEventClass;
392 static jclass sInputDeviceClass;
393 static jclass sMotionRangeClass;
394 static jclass sDebugClass;
396 static JavaVM* sJavaVM;
399 #endif // Q_OS_ANDROID
400 #endif // ANDROIDACTIVITY_H
static void onDestroy(JNIEnv *jni, jobject activity)
Android activity onDestroy lifecycle callback.
static void onStart()
Android activity onStart lifecycle callback.
static bool isStarted()
Returns whether or not the Android activity has been started previously, meaning all future JNI calls...
Definition: AndroidActivity.h:83
static void onControllerDisconnect(JNIEnv *, jobject, int deviceId)
Android activity onControllerDisconnect callback indicating that a device identified by deviceId has ...
static void onResume()
Android activity onResume lifecycle callback.
static bool isBGMMuted()
Returns whether or not the Android SoundManager's background music is muted.
static SelfDetachingJNIEnv getEnv(JavaVM *vm=nullptr)
Returns the current JNI environment.
static void onStop()
Android activity onStop lifecycle callback.
static void signIntoCloud()
Begins asynchronous cloud (i.e. GPGS) sign in.
static void setBGMTrack(int priority, const QString &track)
Sets the Android SoundManager's BGM track at the specified priority level to track.
static bool unlockAchievement(const QString &name)
Unlocks a GPGS achievement.
static void setTrackerScreenName(const QString &screenName, bool sendScreenView=true)
Sets the Google Analytics screen name and optionally sends a screen view hit.
static jclass getActivityClass(JNIEnv *env, jobject activity=nullptr)
Returns a cached global reference to the Android activity class.
static bool incrementAchievement(const QString &name, int numSteps)
Increments a GPGS incremental achievement.
static bool onTouchNavigationKeyEvent(JNIEnv *jni, jobject, jobject keyEvent)
Android activity onTouchNavigationKeyEvent callback for an Android KeyEvent that originated from a to...
static jstring onCloudDataConflict(JNIEnv *jni, jobject, jstring local, jstring cloud)
Android activity onCloudDataConflict callback indicating a conflict of cloud (i.e. GPGS) save data has been detected while loading.
static void sendTrackerEvent(const QString &category, const QString &action)
Sends an event hit to Google Analytics.
static void setBGMPaused(bool value)
Sets the Android SoundManager's paused state.
Smart wrapper around JNIEnv which retains information of how the environment was loaded.
Definition: SelfDetachingJNIEnv.h:33
static QString getVersionName()
Returns the version string of the Android application.
static void signOutOfCloud()
Signs out of cloud (i.e. GPGS).
static bool onTouchNavigationMotionEvent(JNIEnv *jni, jobject, jobject motionEvent)
Android activity onTouchNavigationMotionEvent callback for an Android MotionEvent that originated fro...
static bool cloudSignInFailed()
Returns true if the most recent cloud (i.e. GPGS) sign in attempt failed.
JNI interface for the main Android activity.
Definition: AndroidActivity.h:52
A platform independent event generated by controller device.
Definition: ControllerEvent.h:34
static void onCreate(JNIEnv *jni, jobject activity)
Android activity onCreate lifecycle callback.
static bool ensureCloudSync()
Starts a cloud (i.e. GPGS) save game data sync.
static void setBGMMuted(bool value)
Sets the Android SoundManager's muted state.
static JavaVM * getJavaVM()
Returns the currently cached reference to the JVM.
Definition: AndroidActivity.h:63
static void saveToCloud(const QString &data)
Saves p data to the cloud (i.e. GPGS).
static void onPause()
Android activity onPause lifecycle callback.
static void onSignedIntoCloudChanged(JNIEnv *, jobject, bool signedIntoCloud)
Android activity onSignedIntoCloudChanged callback indicating that cloud (i.e. GPGS) sign-in status h...
static int getTouchScreenDeviceId()
Returns the hardware deviceId of the touch screen input device, or -1 if none.
static long getMemoryUsed()
Returns the number of bytes allocated for the native heap.
static void clearBGMTrack(int priority)
Clears the Android SoundManager's BGM track at the specified priority level.
static bool setAchievementSteps(const QString &name, int minSteps)
Sets a GPGS incremental achievement to have a minimum number of steps.
static jobject getActivity()
Returns the currently cached reference to the Android activity.
Definition: AndroidActivity.h:68
static bool onKeyboardKeyEvent(JNIEnv *jni, jobject, jobject keyEvent)
Android activity onKeyboardKeyEvent callback for an Android KeyEvent that originated from a keyboard ...
static void clearCloudData()
Resets any cloud (i.e. GPGS) save game data.
static void onCloudDataLoaded(JNIEnv *jni, jobject, int statusCode, jstring javaData)
Android activity onCloudDataLoaded callback when cloud (i.e. GPGS) save data has been loaded...
static bool onGamepadMotionEvent(JNIEnv *jni, jobject, jobject motionEvent)
Android activity onGamepadMotionEvent callback for an Android MotionEvent that originated from a game...
static void showAchievementsRequested()
Launch an intent to show the GPGS achievements activity screen.
static bool isSignedIntoCloud()
Returns true if currently signed into the cloud (i.e. GPGS).
static bool revealAchievement(const QString &name)
Reveals a GPGS achievement.
static void resetAchievementsRequested()
Resets all GPGS achievement progress for the currently signed in user account.
static bool onGamepadKeyEvent(JNIEnv *jni, jobject, jobject keyEvent)
Android activity onGamepadKeyEvent callback for an Android KeyEvent that originated from a gamepad de...