|
FPLBase
An open source project by
FPL.
|
General utility functions, used by FPLBase. More...
General utility functions, used by FPLBase.
Classes | |
| struct | fplbase::HighPerformanceParams |
| HighPerformanceParams are used on Android to configure simulated key presses, in order to stop the CPU governor (see https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt) from reducing the CPU frequency when a user is not providing tactile input. More... | |
Typedefs | |
|
typedef std::function< bool(const char *filename, std::string *dest)> | fplbase::LoadFileFunction |
Called by LoadFile(). | |
| typedef void(* | fplbase::VsyncCallback )(void) |
| Used for Android to represent a Vsync callback function. | |
Enumerations | |
| enum | fplbase::LogCategory { kApplication = 0, kError = 1, kSystem = 3, kAudio = 4, kVideo = 5, kRender = 6, kInput = 7, kCustom = 19 } |
| Constants for use with LogInfo, LogError, etc. | |
| enum | fplbase::PerformanceMode { kNormalPerformance = 0, kHighPerformance } |
Enum for use with the Set/GetPerformanceMode() functions. | |
Functions | |
| bool | fplbase::LoadFileRaw (const char *filename, std::string *dest) |
| Loads a file and returns its contents via string pointer. More... | |
| bool | fplbase::LoadFile (const char *filename, std::string *dest) |
| Loads a file and returns its contents via string pointer. More... | |
| LoadFileFunction | fplbase::SetLoadFileFunction (LoadFileFunction load_file_function) |
Set the function called by LoadFile(). More... | |
| bool | fplbase::SaveFile (const char *filename, const std::string &data) |
| Save a string to a file, overwriting the existing contents. More... | |
| bool | fplbase::SaveFile (const char *filename, const void *data, size_t size) |
| Save a string to a file, overwriting the existing contents. More... | |
| bool | fplbase::LoadPreferences (const char *filename, std::string *dest) |
| Load preference settings. More... | |
| bool | fplbase::SavePreferences (const char *filename, const void *data, size_t size) |
| Save preference settings. More... | |
| int32_t | fplbase::LoadPreference (const char *key, int32_t initial_value) |
| Load a single integer value to a preference. More... | |
| bool | fplbase::SavePreference (const char *key, int32_t value) |
| Save a single integer value to a preference. More... | |
| const void * | fplbase::MapFile (const char *filename, int32_t offset, int32_t *size) |
| Map a file into memory and returns its contents via pointer. More... | |
| void | fplbase::UnmapFile (const void *file, int32_t size) |
| Unmap a pointer that is mapped via MapFile() API. More... | |
| bool | fplbase::ChangeToUpstreamDir (const char *const binary_dir, const char *const target_dir) |
| Search and change to a given directory. More... | |
| bool | fplbase::MipmapGeneration16bppSupported () |
| check if 16bpp MipMap is supported. More... | |
| int32_t | fplbase::GetSystemRamSize () |
| Get the system's RAM size. More... | |
| void | fplbase::LogInfo (const char *fmt, va_list args) |
Log a format string with Info priority to the console. More... | |
| void | fplbase::LogError (const char *fmt, va_list args) |
Log a format string with Error priority to the console. More... | |
| void | fplbase::LogInfo (LogCategory category, const char *fmt, va_list args) |
Log a format string with Info priority to the console. More... | |
| void | fplbase::LogError (LogCategory category, const char *fmt, va_list args) |
Log a format string with Error priority to the console. More... | |
| void | fplbase::LogInfo (const char *fmt,...) |
Log a format string with Info priority to the console. More... | |
| void | fplbase::LogError (const char *fmt,...) |
Log a format string with Error priority to the console. More... | |
| void | fplbase::LogInfo (LogCategory category, const char *fmt,...) |
Log a format string with Info priority to the console. More... | |
| void | fplbase::LogError (LogCategory category, const char *fmt,...) |
Log a format string with Error priority to the console. More... | |
| jobject | fplbase::AndroidGetActivity () |
| Get the Android activity class. More... | |
| JNIEnv * | fplbase::AndroidGetJNIEnv () |
| Get the Java native interface object (JNIEnv). More... | |
| VsyncCallback | fplbase::RegisterVsyncCallback (VsyncCallback callback) |
| Register for handling vsync callbacks on android. More... | |
| void | fplbase::WaitForVsync () |
| Blocks until the next time a VSync happens. | |
| int | fplbase::GetVsyncFrameId () |
| Get Vsync frame id. More... | |
| void | fplbase::SendKeypressEventToAndroid (int android_keycode) |
| Triggers a keypress event on an Android device. More... | |
| std::string | fplbase::AndroidGetActivityName () |
| Get the name of the current activity class. More... | |
| std::string | fplbase::AndroidGetViewIntentData () |
Determine whether the activity was started with Intent.ACTION_VIEW and, if so, return the data the user wants to "view" in the application. More... | |
| bool | fplbase::GetStoragePath (const char *app_name, std::string *path) |
| Retrieve a path where an app can store data files. More... | |
| bool | fplbase::SupportsHeadMountedDisplay () |
| Checks whether Head Mounted Displays, such as Cardboard, are supported by the system being run on. More... | |
| bool | fplbase::TouchScreenDevice () |
| Checks if the device has a touchscreen. More... | |
| bool | fplbase::IsTvDevice () |
| Checks whether the device we are running on is an Android TV device. More... | |
| void | fplbase::SetPerformanceMode (PerformanceMode new_mode) |
| Sets the performance mode. More... | |
| PerformanceMode | fplbase::GetPerformanceMode () |
| Get the current performance mode. More... | |
| void | fplbase::RelaunchApplication () |
| Relaunch the application. | |
| void | fplbase::SetHighPerformanceParameters (const HighPerformanceParams ¶ms) |
| Sets the specific parameters used by high-performance mode on Android. More... | |
| const HighPerformanceParams & | fplbase::GetHighPerformanceParameters () |
| Get the high performance parameters. More... | |
| std::string | fplbase::DeviceModel () |
| Get the Android device's model. More... | |
| int32_t | fplbase::AndroidGetApiLevel () |
| Get the Android device's API level. More... | |
Variables | |
| const int | fplbase::kDefaultAndroidKeycode = 115 |
Used for Android to simulate a keypress. Corresponds to F24, which is unavailable on most keyboards. | |
| const double | fplbase::kDefaultTimeBetweenPresses = 1.0 |
| Used for Android. Corresponds to the time, in seconds, between simulated keypresses. | |
| jobject fplbase::AndroidGetActivity | ( | ) |
Get the Android activity class.
| std::string fplbase::AndroidGetActivityName | ( | ) |
Get the name of the current activity class.
std::string containing the Android activity name. | int32_t fplbase::AndroidGetApiLevel | ( | ) |
Get the Android device's API level.
| JNIEnv* fplbase::AndroidGetJNIEnv | ( | ) |
Get the Java native interface object (JNIEnv).
| std::string fplbase::AndroidGetViewIntentData | ( | ) |
Determine whether the activity was started with Intent.ACTION_VIEW and, if so, return the data the user wants to "view" in the application.
std::string contianing the View intent data. | bool fplbase::ChangeToUpstreamDir | ( | const char *const | binary_dir, |
| const char *const | target_dir | ||
| ) |
Search and change to a given directory.
| binary_dir | A C-string corresponding to the current directory to start searching from. |
| target_dir | A C-string corresponding to the desired directory that should be changed to, if found. |
true if it's found, false otherwise. | std::string fplbase::DeviceModel | ( | ) |
Get the Android device's model.
| const HighPerformanceParams& fplbase::GetHighPerformanceParameters | ( | ) |
Get the high performance parameters.
| PerformanceMode fplbase::GetPerformanceMode | ( | ) |
Get the current performance mode.
PerformanceMode. | bool fplbase::GetStoragePath | ( | const char * | app_name, |
| std::string * | path | ||
| ) |
Retrieve a path where an app can store data files.
| [in] | app_name | A C-string corresponding to the name of the application. |
| [out] | path | A std::string to capture the storage path. Contains nullptr if the function returns false. |
true if a storage path was found. Otherwise it returns false. | int32_t fplbase::GetSystemRamSize | ( | ) |
Get the system's RAM size.
| int fplbase::GetVsyncFrameId | ( | ) |
Get Vsync frame id.
| bool fplbase::IsTvDevice | ( | ) |
Checks whether the device we are running on is an Android TV device.
true if the device is an Android TV device. false when not running on Android. | bool fplbase::LoadFile | ( | const char * | filename, |
| std::string * | dest | ||
| ) |
Loads a file and returns its contents via string pointer.
In contrast to LoadFileRaw(), this method simply calls the function set by SetLoadFileFunction() to read the specified file.
| [in] | filename | A UTF-8 C-string representing the file to load. |
| [out] | dest | A pointer to a std::string to capture the output of the file. |
false if the file couldn't be loaded (usually means it's not present, but can also mean there was a read error). | bool fplbase::LoadFileRaw | ( | const char * | filename, |
| std::string * | dest | ||
| ) |
Loads a file and returns its contents via string pointer.
| [in] | filename | A UTF-8 C-string representing the file to load. |
| [out] | dest | A pointer to a std::string to capture the output of the file. |
false if the file couldn't be loaded (usually means it's not present, but can also mean there was a read error). | int32_t fplbase::LoadPreference | ( | const char * | key, |
| int32_t | initial_value | ||
| ) |
Load a single integer value to a preference.
| [in] | key | The UTF-8 key for the preference. |
| [in] | initial_value | The default value to use if the preference is not found. |
| bool fplbase::LoadPreferences | ( | const char * | filename, |
| std::string * | dest | ||
| ) |
Load preference settings.
The API uses a dedicated API when an optimal API is available instead of regular file IO APIs.
| [in] | filename | A UTF-8 C-string representing the file to load preferences from. |
| [out] | dest | A pointer to a std::string to capture the preferences output. |
false if the file couldn't be loaded (usually means it's not present, but can also mean there was a read error). | void fplbase::LogError | ( | const char * | fmt, |
| va_list | args | ||
| ) |
Log a format string with Error priority to the console.
| [in] | fmt | A C-string format string. |
| [in] | args | A variable length argument list for the format string fmt. |
| void fplbase::LogError | ( | LogCategory | category, |
| const char * | fmt, | ||
| va_list | args | ||
| ) |
Log a format string with Error priority to the console.
| [in] | category | The LogCategory for the message. |
| [in] | fmt | A C-string format string. |
| [in] | args | A variable length argument list for the format string fmt. |
| void fplbase::LogError | ( | const char * | fmt, |
| ... | |||
| ) |
Log a format string with Error priority to the console.
| [in] | fmt | A C-string format string. |
| void fplbase::LogError | ( | LogCategory | category, |
| const char * | fmt, | ||
| ... | |||
| ) |
Log a format string with Error priority to the console.
| [in] | category | The LogCategory for the message. |
| [in] | fmt | A C-string format string. |
| void fplbase::LogInfo | ( | const char * | fmt, |
| va_list | args | ||
| ) |
Log a format string with Info priority to the console.
| [in] | fmt | A C-string format string. |
| [in] | args | A variable length argument list for the format string fmt. |
| void fplbase::LogInfo | ( | LogCategory | category, |
| const char * | fmt, | ||
| va_list | args | ||
| ) |
Log a format string with Info priority to the console.
| [in] | category | The LogCategory for the message. |
| [in] | fmt | A C-string format string. |
| [in] | args | A variable length argument list for the format string fmt. |
| void fplbase::LogInfo | ( | const char * | fmt, |
| ... | |||
| ) |
Log a format string with Info priority to the console.
| [in] | fmt | A C-string format string. |
| void fplbase::LogInfo | ( | LogCategory | category, |
| const char * | fmt, | ||
| ... | |||
| ) |
Log a format string with Info priority to the console.
| [in] | category | The LogCategory for the message. |
| [in] | fmt | A C-string format string. |
| const void* fplbase::MapFile | ( | const char * | filename, |
| int32_t | offset, | ||
| int32_t * | size | ||
| ) |
Map a file into memory and returns its contents via pointer.
In contrast to LoadFile(), this method calls mmap API to map the whole or a part of the file.
| [in] | filename | A UTF-8 C-string representing the file to load. |
| [in] | offset | An offset of the file contents to map. |
| in/out] | size A size to map. A size of 0 indicates to map whole file. returns a mapped size of the file. |
| bool fplbase::MipmapGeneration16bppSupported | ( | ) |
check if 16bpp MipMap is supported.
true if 16bpp MipMap generation is supported. | VsyncCallback fplbase::RegisterVsyncCallback | ( | VsyncCallback | callback | ) |
Register for handling vsync callbacks on android.
| callback | The VSync callback function to register. |
nullptr if there was none.) | bool fplbase::SaveFile | ( | const char * | filename, |
| const std::string & | data | ||
| ) |
Save a string to a file, overwriting the existing contents.
| [in] | filename | A UTF-8 C-string representing the file to save to. |
| [in] | data | A const reference to a std::string containing the data that should be written to the file specified by filename. |
false if the file could not be written. | bool fplbase::SaveFile | ( | const char * | filename, |
| const void * | data, | ||
| size_t | size | ||
| ) |
Save a string to a file, overwriting the existing contents.
| [in] | filename | A UTF-8 C-string representing the file to save to. |
| [in] | data | A const void pointer to the data that should be written to the file specified by filename. |
| [in] | size | The size of the data array to write to the file specified by filename. |
false if the file could not be written. | bool fplbase::SavePreference | ( | const char * | key, |
| int32_t | value | ||
| ) |
Save a single integer value to a preference.
| [in] | key | The UTF-8 key for the preference. |
| [in] | value | The value to save for the preference. |
| bool fplbase::SavePreferences | ( | const char * | filename, |
| const void * | data, | ||
| size_t | size | ||
| ) |
Save preference settings.
The API uses a dedicated API when an optimal API is available instead of regular file IO APIs.
| [in] | filename | A UTF-8 C-string representing the file to save preferences to. |
| [in] | data | A const void pointer to the data that should be written to the file specified by filename. |
| [in] | size | The size of the data array to write to the file specified by filename. |
false if the file couldn't be loaded (usually means it's not present, but can also mean there was a read error). | void fplbase::SendKeypressEventToAndroid | ( | int | android_keycode | ) |
Triggers a keypress event on an Android device.
| [in] | android_keycode | The key code corresponding to the keypress that should be triggered. |
| void fplbase::SetHighPerformanceParameters | ( | const HighPerformanceParams & | params | ) |
Sets the specific parameters used by high-performance mode on Android.
| [in] | params | A const reference to a HighPerformanceParams struct to set for use with high-performance mode. |
| LoadFileFunction fplbase::SetLoadFileFunction | ( | LoadFileFunction | load_file_function | ) |
Set the function called by LoadFile().
| [in] | load_file_function | The function to be used by LoadFile() to read files. |
LoadFileRaw() is set as the default function. LoadFileFunction(). | void fplbase::SetPerformanceMode | ( | PerformanceMode | new_mode | ) |
Sets the performance mode.
| [in] | new_mode | The PerformanceMode to set. |
| bool fplbase::SupportsHeadMountedDisplay | ( | ) |
Checks whether Head Mounted Displays, such as Cardboard, are supported by the system being run on.
true if Head Mounted Displays are supported. | bool fplbase::TouchScreenDevice | ( | ) |
Checks if the device has a touchscreen.
true if the device has a touchscreen. | void fplbase::UnmapFile | ( | const void * | file, |
| int32_t | size | ||
| ) |
Unmap a pointer that is mapped via MapFile() API.
| [in] | file | A pointer to the file, returned via MapFile API. |
| [in] | size | A size to unmap. |