2013-07-17 20:26:01 -04:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 01:50:59 +01:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2017-01-22 13:40:32 +01:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2015-01-07 17:46:50 +01:00
|
|
|
* Copyright (C) 2012-2015 - Michael Lelli
|
2013-07-17 20:26:01 -04:00
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <emscripten/emscripten.h>
|
2018-01-14 02:33:22 -06:00
|
|
|
#include <emscripten/html5.h>
|
2016-09-07 20:16:30 -05:00
|
|
|
#include <string.h>
|
2015-09-15 04:49:10 +02:00
|
|
|
|
2014-10-23 03:54:18 +02:00
|
|
|
#include <file/config_file.h>
|
2016-05-16 17:29:02 +02:00
|
|
|
#include <queues/task_queue.h>
|
2016-09-11 14:54:34 +02:00
|
|
|
#include <file/file_path.h>
|
2017-05-23 20:45:14 +02:00
|
|
|
#include <string/stdstring.h>
|
2017-06-28 04:41:38 +02:00
|
|
|
#include <retro_timers.h>
|
2018-01-20 13:01:24 -06:00
|
|
|
#include <gfx/video_frame.h>
|
|
|
|
#include <glsym/glsym.h>
|
2016-09-11 14:54:34 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../../config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef IS_SALAMANDER
|
|
|
|
#include <lists/file_list.h>
|
|
|
|
#endif
|
2015-09-15 04:49:10 +02:00
|
|
|
|
2016-09-11 14:54:34 +02:00
|
|
|
#include "../frontend.h"
|
|
|
|
#include "../frontend_driver.h"
|
2016-09-06 00:41:43 +02:00
|
|
|
#include "../../configuration.h"
|
2016-03-22 03:13:33 +01:00
|
|
|
#include "../../defaults.h"
|
2014-10-22 23:39:36 -02:00
|
|
|
#include "../../content.h"
|
2015-08-20 00:25:12 +02:00
|
|
|
#include "../../retroarch.h"
|
2018-01-15 02:12:53 -06:00
|
|
|
#include "../../verbosity.h"
|
2016-05-09 20:30:47 +02:00
|
|
|
#include "../../command.h"
|
2016-09-19 04:09:27 +02:00
|
|
|
#include "../../tasks/tasks_internal.h"
|
2016-09-07 20:16:30 -05:00
|
|
|
#include "../../file_path_special.h"
|
2020-11-20 03:55:55 +01:00
|
|
|
#include "../../paths.h"
|
2016-08-28 22:54:00 -05:00
|
|
|
|
2019-08-07 22:07:09 -05:00
|
|
|
void dummyErrnoCodes(void);
|
2020-07-09 07:46:40 +02:00
|
|
|
void emscripten_mainloop(void);
|
2013-08-18 02:50:10 -04:00
|
|
|
|
2015-07-27 00:08:14 +02:00
|
|
|
void cmd_savefiles(void)
|
|
|
|
{
|
2020-02-01 03:27:58 +01:00
|
|
|
command_event(CMD_EVENT_SAVE_FILES, NULL);
|
2015-07-27 00:08:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmd_save_state(void)
|
|
|
|
{
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_SAVE_STATE, NULL);
|
2015-07-27 00:08:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmd_load_state(void)
|
|
|
|
{
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_LOAD_STATE, NULL);
|
2015-07-27 00:08:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmd_take_screenshot(void)
|
|
|
|
{
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_TAKE_SCREENSHOT, NULL);
|
2015-07-27 00:08:14 +02:00
|
|
|
}
|
|
|
|
|
2016-08-28 22:50:56 -05:00
|
|
|
static void frontend_emscripten_get_env(int *argc, char *argv[],
|
|
|
|
void *args, void *params_data)
|
|
|
|
{
|
|
|
|
(void)args;
|
|
|
|
|
2017-05-23 19:43:58 +02:00
|
|
|
unsigned i;
|
2016-08-28 22:50:56 -05:00
|
|
|
char base_path[PATH_MAX] = {0};
|
2016-09-07 20:09:06 -05:00
|
|
|
char user_path[PATH_MAX] = {0};
|
2016-08-28 22:50:56 -05:00
|
|
|
const char *home = getenv("HOME");
|
|
|
|
|
2016-09-07 20:19:51 -05:00
|
|
|
if (home)
|
2016-09-07 20:09:06 -05:00
|
|
|
{
|
2016-08-28 22:50:56 -05:00
|
|
|
snprintf(base_path, sizeof(base_path),
|
2016-09-07 20:09:06 -05:00
|
|
|
"%s/retroarch", home);
|
|
|
|
snprintf(user_path, sizeof(user_path),
|
2016-09-09 00:25:27 -05:00
|
|
|
"%s/retroarch/userdata", home);
|
2016-09-07 20:09:06 -05:00
|
|
|
}
|
2016-08-28 22:50:56 -05:00
|
|
|
else
|
2016-09-07 20:09:06 -05:00
|
|
|
{
|
2016-08-28 22:50:56 -05:00
|
|
|
snprintf(base_path, sizeof(base_path), "retroarch");
|
2016-09-09 00:25:27 -05:00
|
|
|
snprintf(user_path, sizeof(user_path), "retroarch/userdata");
|
2016-09-07 20:09:06 -05:00
|
|
|
}
|
2016-08-28 22:50:56 -05:00
|
|
|
|
2017-05-23 19:43:58 +02:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], base_path,
|
|
|
|
"cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE]));
|
2016-08-28 22:50:56 -05:00
|
|
|
|
2016-09-08 23:56:43 -05:00
|
|
|
/* bundle data */
|
2017-05-23 19:43:58 +02:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], base_path,
|
|
|
|
"bundle/assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], base_path,
|
|
|
|
"bundle/autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CURSOR], base_path,
|
|
|
|
"bundle/database/cursors", sizeof(g_defaults.dirs[DEFAULT_DIR_CURSOR]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], base_path,
|
|
|
|
"bundle/database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], base_path,
|
|
|
|
"bundle/info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], base_path,
|
|
|
|
"bundle/overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY]));
|
2019-04-16 17:41:06 +01:00
|
|
|
#ifdef HAVE_VIDEO_LAYOUT
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_LAYOUT], base_path,
|
|
|
|
"bundle/layouts", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_LAYOUT]));
|
|
|
|
#endif
|
2017-05-23 19:43:58 +02:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], base_path,
|
|
|
|
"bundle/shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER]));
|
2021-01-06 13:04:38 +00:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER], base_path,
|
|
|
|
"bundle/filters/audio", sizeof(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], base_path,
|
|
|
|
"bundle/filters/video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER]));
|
2016-09-07 20:09:06 -05:00
|
|
|
|
|
|
|
/* user data dirs */
|
2017-05-23 19:43:58 +02:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], user_path,
|
|
|
|
"cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], user_path,
|
|
|
|
"config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONTENT], user_path,
|
|
|
|
"content", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONTENT]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], user_path,
|
|
|
|
"content/downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], user_path,
|
|
|
|
"playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_REMAP], g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG],
|
|
|
|
"remaps", sizeof(g_defaults.dirs[DEFAULT_DIR_REMAP]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], user_path,
|
|
|
|
"saves", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], user_path,
|
|
|
|
"screenshots", sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], user_path,
|
|
|
|
"states", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], user_path,
|
|
|
|
"system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS], user_path,
|
|
|
|
"thumbnails", sizeof(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS]));
|
2019-03-25 17:22:59 +00:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_LOGS], user_path,
|
|
|
|
"logs", sizeof(g_defaults.dirs[DEFAULT_DIR_LOGS]));
|
2016-08-28 23:49:49 -05:00
|
|
|
|
2016-09-07 20:09:06 -05:00
|
|
|
/* cache dir */
|
2017-05-23 19:43:58 +02:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CACHE], "/tmp/",
|
|
|
|
"retroarch", sizeof(g_defaults.dirs[DEFAULT_DIR_CACHE]));
|
2016-09-07 20:09:06 -05:00
|
|
|
|
2016-09-08 23:56:43 -05:00
|
|
|
/* history and main config */
|
2017-05-23 19:43:58 +02:00
|
|
|
strlcpy(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY],
|
|
|
|
user_path, sizeof(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY]));
|
2020-08-16 04:38:02 +02:00
|
|
|
fill_pathname_join(g_defaults.path_config, user_path,
|
2020-08-22 01:06:10 +02:00
|
|
|
FILE_PATH_MAIN_CONFIG, sizeof(g_defaults.path_config));
|
2020-11-20 03:55:55 +01:00
|
|
|
|
2020-11-19 07:10:22 +01:00
|
|
|
#ifndef IS_SALAMANDER
|
2020-11-20 03:55:55 +01:00
|
|
|
dir_check_defaults("custom.ini");
|
2020-11-19 07:10:22 +01:00
|
|
|
#endif
|
2016-08-28 22:50:56 -05:00
|
|
|
}
|
2015-07-27 00:08:14 +02:00
|
|
|
|
2014-06-18 20:31:41 -04:00
|
|
|
int main(int argc, char *argv[])
|
2013-07-17 20:26:01 -04:00
|
|
|
{
|
2019-08-07 22:07:09 -05:00
|
|
|
dummyErrnoCodes();
|
|
|
|
|
2018-01-14 02:33:22 -06:00
|
|
|
emscripten_set_canvas_element_size("#canvas", 800, 600);
|
|
|
|
emscripten_set_element_css_size("#canvas", 800.0, 600.0);
|
2018-01-15 00:43:20 -06:00
|
|
|
emscripten_set_main_loop(emscripten_mainloop, 0, 0);
|
2015-04-20 21:31:25 +02:00
|
|
|
rarch_main(argc, argv, NULL);
|
2013-07-17 20:26:01 -04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2016-08-10 23:03:51 +02:00
|
|
|
|
|
|
|
frontend_ctx_driver_t frontend_ctx_emscripten = {
|
2016-08-28 22:50:56 -05:00
|
|
|
frontend_emscripten_get_env, /* environment_get */
|
2016-08-10 23:03:51 +02:00
|
|
|
NULL, /* init */
|
|
|
|
NULL, /* deinit */
|
|
|
|
NULL, /* exitspawn */
|
|
|
|
NULL, /* process_args */
|
|
|
|
NULL, /* exec */
|
|
|
|
NULL, /* set_fork */
|
|
|
|
NULL, /* shutdown */
|
|
|
|
NULL, /* get_name */
|
|
|
|
NULL, /* get_os */
|
|
|
|
NULL, /* get_rating */
|
|
|
|
NULL, /* load_content */
|
|
|
|
NULL, /* get_architecture */
|
|
|
|
NULL, /* get_powerstate */
|
|
|
|
NULL, /* parse_drive_list */
|
|
|
|
NULL, /* get_mem_total */
|
|
|
|
NULL, /* get_mem_used */
|
|
|
|
NULL, /* install_sighandlers */
|
|
|
|
NULL, /* get_signal_handler_state */
|
|
|
|
NULL, /* set_signal_handler_state */
|
|
|
|
NULL, /* destroy_signal_handler_state */
|
2016-10-09 17:15:50 +02:00
|
|
|
NULL, /* attach_console */
|
|
|
|
NULL, /* detach_console */
|
2020-11-23 18:44:24 +01:00
|
|
|
NULL, /* get_lakka_version */
|
2020-11-23 21:29:26 +01:00
|
|
|
NULL, /* set_screen_brightness */
|
2018-01-25 15:50:57 -05:00
|
|
|
NULL, /* watch_path_for_changes */
|
|
|
|
NULL, /* check_for_path_changes */
|
2018-06-19 02:50:33 -04:00
|
|
|
NULL, /* set_sustained_performance_mode */
|
2019-02-23 16:50:36 -05:00
|
|
|
NULL, /* get_cpu_model_name */
|
2019-04-15 23:14:49 -04:00
|
|
|
NULL, /* get_user_language */
|
2020-02-14 00:17:55 +01:00
|
|
|
NULL, /* is_narrator_running */
|
|
|
|
NULL, /* accessibility_speak */
|
2016-08-10 23:03:51 +02:00
|
|
|
"emscripten"
|
|
|
|
};
|