mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
(platform_linux.c) Try to stay within 80-char width limit
This commit is contained in:
parent
6130f20d47
commit
6a64ab1137
@ -50,11 +50,13 @@
|
|||||||
#include "../../verbosity.h"
|
#include "../../verbosity.h"
|
||||||
#include "platform_linux.h"
|
#include "platform_linux.h"
|
||||||
|
|
||||||
/* This small data type is used to represent a CPU list / mask, as read
|
/* This small data type is used to represent a CPU list / mask,
|
||||||
* from sysfs on Linux. See http://www.kernel.org/doc/Documentation/cputopology.txt
|
* as read from sysfs on Linux.
|
||||||
*
|
*
|
||||||
* For now, we don't expect more than 32 cores on mobile devices, so keep
|
* See http://www.kernel.org/doc/Documentation/cputopology.txt
|
||||||
* everything simple.
|
*
|
||||||
|
* For now, we don't expect more than 32 cores on mobile devices,
|
||||||
|
* so keep everything simple.
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -89,14 +91,16 @@ void x86_cpuid(int func, int flags[4]);
|
|||||||
*
|
*
|
||||||
* Return NULL if not found
|
* Return NULL if not found
|
||||||
*/
|
*/
|
||||||
static char *extract_cpuinfo_field(char* buffer, ssize_t length, const char* field)
|
static char *extract_cpuinfo_field(char* buffer,
|
||||||
|
ssize_t length, const char* field)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
const char *q;
|
const char *q;
|
||||||
int fieldlen = strlen(field);
|
int fieldlen = strlen(field);
|
||||||
char* bufend = buffer + length;
|
char* bufend = buffer + length;
|
||||||
char* result = NULL;
|
char* result = NULL;
|
||||||
/* Look for first field occurrence, and ensures it starts the line. */
|
/* Look for first field occurrence,
|
||||||
|
* and ensures it starts the line. */
|
||||||
const char *p = buffer;
|
const char *p = buffer;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
@ -135,7 +139,8 @@ static char *extract_cpuinfo_field(char* buffer, ssize_t length, const char* fie
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Checks that a space-separated list of items contains one given 'item'.
|
/* Checks that a space-separated list of items
|
||||||
|
* contains one given 'item'.
|
||||||
* Returns 1 if found, 0 otherwise.
|
* Returns 1 if found, 0 otherwise.
|
||||||
*/
|
*/
|
||||||
static int has_list_item(const char* list, const char* item)
|
static int has_list_item(const char* list, const char* item)
|
||||||
@ -180,7 +185,8 @@ static int has_list_item(const char* list, const char* item)
|
|||||||
* position after the decimal number in case of success (which will always
|
* position after the decimal number in case of success (which will always
|
||||||
* be <= 'limit').
|
* be <= 'limit').
|
||||||
*/
|
*/
|
||||||
static const char *parse_decimal(const char* input, const char* limit, int* result)
|
static const char *parse_decimal(const char* input,
|
||||||
|
const char* limit, int* result)
|
||||||
{
|
{
|
||||||
const char* p = input;
|
const char* p = input;
|
||||||
int val = 0;
|
int val = 0;
|
||||||
@ -434,7 +440,8 @@ int linux_get_cpu_count(void)
|
|||||||
return g_cpuCount;
|
return g_cpuCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
int system_property_get(const char *command, const char *args, char *value)
|
int system_property_get(const char *command,
|
||||||
|
const char *args, char *value)
|
||||||
{
|
{
|
||||||
FILE *pipe;
|
FILE *pipe;
|
||||||
int length = 0;
|
int length = 0;
|
||||||
@ -503,7 +510,8 @@ void android_app_write_cmd(struct android_app *android_app, int8_t cmd)
|
|||||||
RARCH_ERR("Failure writing android_app cmd: %s\n", strerror(errno));
|
RARCH_ERR("Failure writing android_app cmd: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_app_set_input(struct android_app *android_app, AInputQueue* inputQueue)
|
static void android_app_set_input(struct android_app *android_app,
|
||||||
|
AInputQueue* inputQueue)
|
||||||
{
|
{
|
||||||
if (!android_app)
|
if (!android_app)
|
||||||
return;
|
return;
|
||||||
@ -518,7 +526,8 @@ static void android_app_set_input(struct android_app *android_app, AInputQueue*
|
|||||||
slock_unlock(android_app->mutex);
|
slock_unlock(android_app->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_app_set_window(struct android_app *android_app, ANativeWindow* window)
|
static void android_app_set_window(struct android_app *android_app,
|
||||||
|
ANativeWindow* window)
|
||||||
{
|
{
|
||||||
if (!android_app)
|
if (!android_app)
|
||||||
return;
|
return;
|
||||||
@ -538,7 +547,8 @@ static void android_app_set_window(struct android_app *android_app, ANativeWindo
|
|||||||
slock_unlock(android_app->mutex);
|
slock_unlock(android_app->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_app_set_activity_state(struct android_app *android_app, int8_t cmd)
|
static void android_app_set_activity_state(
|
||||||
|
struct android_app *android_app, int8_t cmd)
|
||||||
{
|
{
|
||||||
if (!android_app)
|
if (!android_app)
|
||||||
return;
|
return;
|
||||||
@ -587,10 +597,12 @@ static void onResume(ANativeActivity* activity)
|
|||||||
activity->instance, APP_CMD_RESUME);
|
activity->instance, APP_CMD_RESUME);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* onSaveInstanceState(ANativeActivity* activity, size_t* outLen)
|
static void* onSaveInstanceState(
|
||||||
|
ANativeActivity* activity, size_t* outLen)
|
||||||
{
|
{
|
||||||
void* savedState = NULL;
|
void* savedState = NULL;
|
||||||
struct android_app* android_app = (struct android_app*)activity->instance;
|
struct android_app* android_app = (struct android_app*)
|
||||||
|
activity->instance;
|
||||||
|
|
||||||
RARCH_LOG("SaveInstanceState: %p\n", activity);
|
RARCH_LOG("SaveInstanceState: %p\n", activity);
|
||||||
|
|
||||||
@ -632,13 +644,15 @@ static void onStop(ANativeActivity* activity)
|
|||||||
static void onConfigurationChanged(ANativeActivity *activity)
|
static void onConfigurationChanged(ANativeActivity *activity)
|
||||||
{
|
{
|
||||||
RARCH_LOG("ConfigurationChanged: %p\n", activity);
|
RARCH_LOG("ConfigurationChanged: %p\n", activity);
|
||||||
android_app_write_cmd((struct android_app*)activity->instance, APP_CMD_CONFIG_CHANGED);
|
android_app_write_cmd((struct android_app*)
|
||||||
|
activity->instance, APP_CMD_CONFIG_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void onLowMemory(ANativeActivity* activity)
|
static void onLowMemory(ANativeActivity* activity)
|
||||||
{
|
{
|
||||||
RARCH_LOG("LowMemory: %p\n", activity);
|
RARCH_LOG("LowMemory: %p\n", activity);
|
||||||
android_app_write_cmd((struct android_app*)activity->instance, APP_CMD_LOW_MEMORY);
|
android_app_write_cmd((struct android_app*)
|
||||||
|
activity->instance, APP_CMD_LOW_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void onWindowFocusChanged(ANativeActivity* activity, int focused)
|
static void onWindowFocusChanged(ANativeActivity* activity, int focused)
|
||||||
@ -810,7 +824,8 @@ void ANativeActivity_onCreate(ANativeActivity* activity,
|
|||||||
if (pthread_key_create(&thread_key, jni_thread_destruct))
|
if (pthread_key_create(&thread_key, jni_thread_destruct))
|
||||||
RARCH_ERR("Error initializing pthread_key\n");
|
RARCH_ERR("Error initializing pthread_key\n");
|
||||||
|
|
||||||
activity->instance = android_app_create(activity, savedState, savedStateSize);
|
activity->instance = android_app_create(activity,
|
||||||
|
savedState, savedStateSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void frontend_android_get_name(char *s, size_t len)
|
static void frontend_android_get_name(char *s, size_t len)
|
||||||
@ -822,7 +837,8 @@ static void frontend_android_get_version(int32_t *major,
|
|||||||
int32_t *minor, int32_t *rel)
|
int32_t *minor, int32_t *rel)
|
||||||
{
|
{
|
||||||
char os_version_str[PROP_VALUE_MAX] = {0};
|
char os_version_str[PROP_VALUE_MAX] = {0};
|
||||||
system_property_get("getprop", "ro.build.version.release", os_version_str);
|
system_property_get("getprop", "ro.build.version.release",
|
||||||
|
os_version_str);
|
||||||
|
|
||||||
*major = 0;
|
*major = 0;
|
||||||
*minor = 0;
|
*minor = 0;
|
||||||
@ -1090,8 +1106,9 @@ end:
|
|||||||
buf_info = NULL;
|
buf_info = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_proc_acpi_sysfs_battery(const char * node, bool * have_battery,
|
static void check_proc_acpi_sysfs_battery(const char *node,
|
||||||
bool * charging, int *seconds, int *percent)
|
bool *have_battery, bool *charging,
|
||||||
|
int *seconds, int *percent)
|
||||||
{
|
{
|
||||||
unsigned capacity;
|
unsigned capacity;
|
||||||
char path[1024], info[1024];
|
char path[1024], info[1024];
|
||||||
@ -1330,7 +1347,8 @@ static bool frontend_linux_powerstate_check_acpi(
|
|||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
while (retro_readdir(entry))
|
while (retro_readdir(entry))
|
||||||
check_proc_acpi_ac_adapter(retro_dirent_get_name(entry), &have_ac);
|
check_proc_acpi_ac_adapter(
|
||||||
|
retro_dirent_get_name(entry), &have_ac);
|
||||||
|
|
||||||
if (!have_battery)
|
if (!have_battery)
|
||||||
*state = FRONTEND_POWERSTATE_NO_SOURCE;
|
*state = FRONTEND_POWERSTATE_NO_SOURCE;
|
||||||
@ -1350,7 +1368,8 @@ end:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool frontend_linux_powerstate_check_acpi_sysfs(enum frontend_powerstate *state,
|
static bool frontend_linux_powerstate_check_acpi_sysfs(
|
||||||
|
enum frontend_powerstate *state,
|
||||||
int *seconds, int *percent)
|
int *seconds, int *percent)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
@ -1419,7 +1438,8 @@ static int frontend_linux_get_rating(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum frontend_powerstate frontend_linux_get_powerstate(int *seconds, int *percent)
|
static enum frontend_powerstate frontend_linux_get_powerstate(
|
||||||
|
int *seconds, int *percent)
|
||||||
{
|
{
|
||||||
enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE;
|
enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE;
|
||||||
|
|
||||||
@ -1490,7 +1510,8 @@ static enum frontend_architecture frontend_linux_get_architecture(void)
|
|||||||
return FRONTEND_ARCH_NONE;
|
return FRONTEND_ARCH_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void frontend_linux_get_os(char *s, size_t len, int *major, int *minor)
|
static void frontend_linux_get_os(char *s,
|
||||||
|
size_t len, int *major, int *minor)
|
||||||
{
|
{
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
int rel;
|
int rel;
|
||||||
@ -1934,49 +1955,52 @@ static void frontend_linux_get_env(int *argc,
|
|||||||
#if 0
|
#if 0
|
||||||
/* Explicitly disable input overlay by default
|
/* Explicitly disable input overlay by default
|
||||||
* for gamepad-like/console devices. */
|
* for gamepad-like/console devices. */
|
||||||
if (device_is_game_console(device_model))
|
|
||||||
g_defaults.settings.input_overlay_enable = false;
|
if (device_is_game_console(device_model))
|
||||||
|
g_defaults.settings.input_overlay_enable = false;
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
char base_path[PATH_MAX];
|
char base_path[PATH_MAX];
|
||||||
const char *xdg = getenv("XDG_CONFIG_HOME");
|
const char *xdg = getenv("XDG_CONFIG_HOME");
|
||||||
const char *home = getenv("HOME");
|
const char *home = getenv("HOME");
|
||||||
|
|
||||||
if (xdg)
|
if (xdg)
|
||||||
snprintf(base_path, sizeof(base_path), "%s/retroarch", xdg);
|
snprintf(base_path, sizeof(base_path),
|
||||||
else if (home)
|
"%s/retroarch", xdg);
|
||||||
snprintf(base_path, sizeof(base_path), "%s/.config/retroarch", home);
|
else if (home)
|
||||||
else
|
snprintf(base_path, sizeof(base_path),
|
||||||
snprintf(base_path, sizeof(base_path), "retroarch");
|
"%s/.config/retroarch", home);
|
||||||
|
else
|
||||||
|
snprintf(base_path, sizeof(base_path), "retroarch");
|
||||||
|
|
||||||
fill_pathname_join(g_defaults.dir.core, base_path,
|
fill_pathname_join(g_defaults.dir.core, base_path,
|
||||||
"cores", sizeof(g_defaults.dir.core));
|
"cores", sizeof(g_defaults.dir.core));
|
||||||
fill_pathname_join(g_defaults.dir.core_info, base_path,
|
fill_pathname_join(g_defaults.dir.core_info, base_path,
|
||||||
"cores", sizeof(g_defaults.dir.core_info));
|
"cores", sizeof(g_defaults.dir.core_info));
|
||||||
fill_pathname_join(g_defaults.dir.autoconfig, base_path,
|
fill_pathname_join(g_defaults.dir.autoconfig, base_path,
|
||||||
"autoconf", sizeof(g_defaults.dir.autoconfig));
|
"autoconf", sizeof(g_defaults.dir.autoconfig));
|
||||||
fill_pathname_join(g_defaults.dir.assets, base_path,
|
fill_pathname_join(g_defaults.dir.assets, base_path,
|
||||||
"assets", sizeof(g_defaults.dir.assets));
|
"assets", sizeof(g_defaults.dir.assets));
|
||||||
fill_pathname_join(g_defaults.dir.remap, base_path,
|
fill_pathname_join(g_defaults.dir.remap, base_path,
|
||||||
"remap", sizeof(g_defaults.dir.remap));
|
"remap", sizeof(g_defaults.dir.remap));
|
||||||
fill_pathname_join(g_defaults.dir.playlist, base_path,
|
fill_pathname_join(g_defaults.dir.playlist, base_path,
|
||||||
"playlists", sizeof(g_defaults.dir.playlist));
|
"playlists", sizeof(g_defaults.dir.playlist));
|
||||||
fill_pathname_join(g_defaults.dir.cursor, base_path,
|
fill_pathname_join(g_defaults.dir.cursor, base_path,
|
||||||
"database/cursors", sizeof(g_defaults.dir.cursor));
|
"database/cursors", sizeof(g_defaults.dir.cursor));
|
||||||
fill_pathname_join(g_defaults.dir.database, base_path,
|
fill_pathname_join(g_defaults.dir.database, base_path,
|
||||||
"database/rdb", sizeof(g_defaults.dir.database));
|
"database/rdb", sizeof(g_defaults.dir.database));
|
||||||
fill_pathname_join(g_defaults.dir.shader, base_path,
|
fill_pathname_join(g_defaults.dir.shader, base_path,
|
||||||
"shaders", sizeof(g_defaults.dir.shader));
|
"shaders", sizeof(g_defaults.dir.shader));
|
||||||
fill_pathname_join(g_defaults.dir.cheats, base_path,
|
fill_pathname_join(g_defaults.dir.cheats, base_path,
|
||||||
"cheats", sizeof(g_defaults.dir.cheats));
|
"cheats", sizeof(g_defaults.dir.cheats));
|
||||||
fill_pathname_join(g_defaults.dir.overlay, base_path,
|
fill_pathname_join(g_defaults.dir.overlay, base_path,
|
||||||
"overlay", sizeof(g_defaults.dir.overlay));
|
"overlay", sizeof(g_defaults.dir.overlay));
|
||||||
fill_pathname_join(g_defaults.dir.osk_overlay, base_path,
|
fill_pathname_join(g_defaults.dir.osk_overlay, base_path,
|
||||||
"overlay", sizeof(g_defaults.dir.osk_overlay));
|
"overlay", sizeof(g_defaults.dir.osk_overlay));
|
||||||
fill_pathname_join(g_defaults.dir.core_assets, base_path,
|
fill_pathname_join(g_defaults.dir.core_assets, base_path,
|
||||||
"downloads", sizeof(g_defaults.dir.core_assets));
|
"downloads", sizeof(g_defaults.dir.core_assets));
|
||||||
fill_pathname_join(g_defaults.dir.screenshot, base_path,
|
fill_pathname_join(g_defaults.dir.screenshot, base_path,
|
||||||
"screenshots", sizeof(g_defaults.dir.screenshot));
|
"screenshots", sizeof(g_defaults.dir.screenshot));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2046,7 +2070,8 @@ static void frontend_linux_init(void *data)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
android_app->config = AConfiguration_new();
|
android_app->config = AConfiguration_new();
|
||||||
AConfiguration_fromAssetManager(android_app->config, android_app->activity->assetManager);
|
AConfiguration_fromAssetManager(android_app->config,
|
||||||
|
android_app->activity->assetManager);
|
||||||
|
|
||||||
looper = (ALooper*)ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
|
looper = (ALooper*)ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
|
||||||
ALooper_addFd(looper, android_app->msgread, LOOPER_ID_MAIN,
|
ALooper_addFd(looper, android_app->msgread, LOOPER_ID_MAIN,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user