15 #ifndef FPLBASE_UTILITIES_H
16 #define FPLBASE_UTILITIES_H
20 #include "fplbase/config.h"
22 #include "mathfu/utilities.h"
24 #if defined(__ANDROID__)
26 #if defined(FPLBASE_BACKEND_STDLIB)
27 #include <android/asset_manager.h>
28 #include <android/asset_manager_jni.h>
29 #endif // defined(FPLBASE_BACKEND_STDLIB)
41 #ifdef FPLBASE_BACKEND_SDL
66 typedef std::function<bool(const char *filename, std::string *dest)>
72 kNormalPerformance = 0,
108 double time_between_presses;
118 bool LoadFileRaw(
const char *filename, std::string *dest);
128 bool LoadFile(
const char *filename, std::string *dest);
143 bool SaveFile(
const char *filename,
const std::string &data);
152 bool SaveFile(
const char *filename,
const void *data,
size_t size);
178 bool SavePreferences(
const char *filename,
const void *data,
size_t size);
200 const void *
MapFile(
const char *filename, int32_t offset, int32_t *size);
205 void UnmapFile(
const void *file, int32_t size);
214 const char *
const target_dir);
229 void LogInfo(
const char *fmt, va_list args);
235 void LogError(
const char *fmt, va_list args);
253 void LogInfo(
const char *fmt, ...);
257 void LogError(
const char *fmt, ...);
269 #if defined(__ANDROID__)
313 #endif // __ANDROID__
315 #if defined(__ANDROID__) && defined(FPLBASE_BACKEND_STDLIB)
320 void SetAAssetManager(AAssetManager *manager);
323 void AndroidSetJavaVM(JavaVM* vm, jint jni_version);
384 #endif // FPLBASE_UTILITIES_H
bool LoadPreferences(const char *filename, std::string *dest)
Load preference settings.
std::string DeviceModel()
Get the Android device's model.
int32_t AndroidGetApiLevel()
Get the Android device's API level.
void WaitForVsync()
Blocks until the next time a VSync happens.
bool MipmapGeneration16bppSupported()
check if 16bpp MipMap is supported.
void SetHighPerformanceParameters(const HighPerformanceParams ¶ms)
Sets the specific parameters used by high-performance mode on Android.
void SetPerformanceMode(PerformanceMode new_mode)
Sets the performance mode.
void RelaunchApplication()
Relaunch the application.
bool SupportsHeadMountedDisplay()
Checks whether Head Mounted Displays, such as Cardboard, are supported by the system being run on...
const HighPerformanceParams & GetHighPerformanceParameters()
Get the high performance parameters.
void LogError(const char *fmt, va_list args)
Log a format string with Error priority to the console.
PerformanceMode GetPerformanceMode()
Get the current performance mode.
const void * MapFile(const char *filename, int32_t offset, int32_t *size)
Map a file into memory and returns its contents via pointer.
int32_t LoadPreference(const char *key, int32_t initial_value)
Load a single integer value to a preference.
bool SaveFile(const char *filename, const std::string &data)
Save a string to a file, overwriting the existing contents.
bool LoadFileRaw(const char *filename, std::string *dest)
Loads a file and returns its contents via string pointer.
bool LoadFile(const char *filename, std::string *dest)
Loads a file and returns its contents via string pointer.
PerformanceMode
Enum for use with the Set/GetPerformanceMode() functions.
Definition: utilities.h:70
const int kDefaultAndroidKeycode
Used for Android to simulate a keypress. Corresponds to F24, which is unavailable on most keyboards...
Definition: utilities.h:84
bool SavePreference(const char *key, int32_t value)
Save a single integer value to a preference.
LogCategory
Constants for use with LogInfo, LogError, etc.
Definition: utilities.h:42
void UnmapFile(const void *file, int32_t size)
Unmap a pointer that is mapped via MapFile() API.
JNIEnv * AndroidGetJNIEnv()
Get the Java native interface object (JNIEnv).
bool IsTvDevice()
Checks whether the device we are running on is an Android TV device.
bool TouchScreenDevice()
Checks if the device has a touchscreen.
bool ChangeToUpstreamDir(const char *const binary_dir, const char *const target_dir)
Search and change to a given directory.
std::function< bool(const char *filename, std::string *dest)> LoadFileFunction
Called by LoadFile().
Definition: utilities.h:67
void LogInfo(const char *fmt, va_list args)
Log a format string with Info priority to the console.
LoadFileFunction SetLoadFileFunction(LoadFileFunction load_file_function)
Set the function called by LoadFile().
const double kDefaultTimeBetweenPresses
Used for Android. Corresponds to the time, in seconds, between simulated keypresses.
Definition: utilities.h:88
int32_t GetSystemRamSize()
Get the system's RAM size.
std::string AndroidGetViewIntentData()
Determine whether the activity was started with Intent.ACTION_VIEW and, if so, return the data the us...
jobject AndroidGetActivity()
Get the Android activity class.
bool GetStoragePath(const char *app_name, std::string *path)
Retrieve a path where an app can store data files.
VsyncCallback RegisterVsyncCallback(VsyncCallback callback)
Register for handling vsync callbacks on android.
void(* VsyncCallback)(void)
Used for Android to represent a Vsync callback function.
Definition: utilities.h:80
int GetVsyncFrameId()
Get Vsync frame id.
std::string AndroidGetActivityName()
Get the name of the current activity class.
void SendKeypressEventToAndroid(int android_keycode)
Triggers a keypress event on an Android device.
bool SavePreferences(const char *filename, const void *data, size_t size)
Save preference settings.