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
|
2016-01-10 04:06:50 +01:00
|
|
|
* Copyright (C) 2011-2016 - 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>
|
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>
|
2015-09-15 04:49:10 +02:00
|
|
|
|
2016-03-22 03:13:33 +01:00
|
|
|
#include "../../defaults.h"
|
2015-09-15 04:49:10 +02:00
|
|
|
#include "../../general.h"
|
2014-10-22 23:39:36 -02:00
|
|
|
#include "../../content.h"
|
2015-04-14 22:01:41 +02:00
|
|
|
#include "../frontend.h"
|
2015-08-20 00:25:12 +02:00
|
|
|
#include "../../retroarch.h"
|
|
|
|
#include "../../runloop.h"
|
2015-04-07 22:21:08 +02:00
|
|
|
#include "../frontend_driver.h"
|
2016-05-09 20:30:47 +02:00
|
|
|
#include "../../command.h"
|
2013-07-17 20:26:01 -04:00
|
|
|
|
2013-12-28 21:08:30 +01:00
|
|
|
static void emscripten_mainloop(void)
|
2013-08-18 02:50:10 -04:00
|
|
|
{
|
2015-08-27 14:52:02 +02:00
|
|
|
unsigned sleep_ms = 0;
|
2015-12-07 15:22:36 +01:00
|
|
|
int ret = runloop_iterate(&sleep_ms);
|
2015-08-27 14:52:02 +02:00
|
|
|
if (ret == 1 && sleep_ms > 0)
|
2015-09-22 18:55:14 +02:00
|
|
|
retro_sleep(sleep_ms);
|
2016-05-16 17:29:02 +02:00
|
|
|
task_queue_ctl(TASK_QUEUE_CTL_CHECK, NULL);
|
2015-05-16 17:00:50 +02:00
|
|
|
if (ret != -1)
|
2015-01-11 06:57:35 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
main_exit(NULL);
|
|
|
|
exit(0);
|
2013-08-18 02:50:10 -04:00
|
|
|
}
|
|
|
|
|
2015-07-27 00:08:14 +02:00
|
|
|
void cmd_savefiles(void)
|
|
|
|
{
|
2016-05-09 20:51:53 +02:00
|
|
|
command_event(CMD_EVENT_SAVEFILES, 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
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-18 20:31:41 -04:00
|
|
|
int main(int argc, char *argv[])
|
2013-07-17 20:26:01 -04:00
|
|
|
{
|
2015-03-20 22:22:06 +01:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
2013-07-17 20:26:01 -04:00
|
|
|
emscripten_set_canvas_size(800, 600);
|
2015-04-20 21:31:25 +02:00
|
|
|
rarch_main(argc, argv, NULL);
|
2014-09-02 17:42:44 +02:00
|
|
|
emscripten_set_main_loop(emscripten_mainloop,
|
2015-03-20 22:22:06 +01:00
|
|
|
settings->video.vsync ? 0 : INT_MAX, 1);
|
2013-07-17 20:26:01 -04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|