mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-14 06:09:17 +00:00
start on bringing the emscripten video code up to speed with latest emscripten
fix rwebinput
This commit is contained in:
parent
728f77b2bc
commit
a77f9c37c6
@ -18,7 +18,7 @@ HAVE_RPNG = 1
|
||||
HAVE_EMSCRIPTEN = 1
|
||||
HAVE_RGUI = 1
|
||||
HAVE_SDL = 0
|
||||
HAVE_SDL2 = 1
|
||||
HAVE_SDL2 = 0
|
||||
HAVE_ZLIB = 1
|
||||
WANT_ZLIB = 1
|
||||
HAVE_STATIC_VIDEO_FILTERS = 1
|
||||
@ -50,7 +50,7 @@ endif
|
||||
|
||||
ifeq ($(ASYNC), 1)
|
||||
LDFLAGS += -s ASYNCIFY=$(ASYNC)
|
||||
endif
|
||||
endif
|
||||
|
||||
include Makefile.common
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <emscripten/emscripten.h>
|
||||
#include <emscripten/html5.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../../config.h"
|
||||
@ -51,23 +52,71 @@ static void gfx_ctx_emscripten_swap_interval(void *data, unsigned interval)
|
||||
(void)interval;
|
||||
}
|
||||
|
||||
static void gfx_ctx_emscripten_get_canvas_size(int *width, int *height)
|
||||
{
|
||||
EMSCRIPTEN_RESULT r;
|
||||
EmscriptenFullscreenChangeEvent fullscreen_status;
|
||||
bool is_fullscreen = false;
|
||||
|
||||
r = emscripten_get_fullscreen_status(&fullscreen_status);
|
||||
|
||||
if (r == EMSCRIPTEN_RESULT_SUCCESS)
|
||||
{
|
||||
if (fullscreen_status.isFullscreen)
|
||||
{
|
||||
is_fullscreen = true;
|
||||
*width = fullscreen_status.screenWidth;
|
||||
*height = fullscreen_status.screenHeight;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_fullscreen)
|
||||
{
|
||||
r = emscripten_get_canvas_element_size("#canvas", width, height);
|
||||
|
||||
if (r != EMSCRIPTEN_RESULT_SUCCESS)
|
||||
{
|
||||
RARCH_ERR("[EMSCRIPTEN/EGL]: Could not get screen dimensions: %d\n", r);
|
||||
*width = 800;
|
||||
*height = 600;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void gfx_ctx_emscripten_check_window(void *data, bool *quit,
|
||||
bool *resize, unsigned *width, unsigned *height, bool is_shutdown)
|
||||
{
|
||||
EMSCRIPTEN_RESULT r;
|
||||
int input_width;
|
||||
int input_height;
|
||||
int is_fullscreen;
|
||||
emscripten_ctx_data_t *emscripten = (emscripten_ctx_data_t*)data;
|
||||
|
||||
(void)data;
|
||||
gfx_ctx_emscripten_get_canvas_size(&input_width, &input_height);
|
||||
|
||||
emscripten_get_canvas_size(&input_width, &input_height, &is_fullscreen);
|
||||
*width = (unsigned)input_width;
|
||||
*height = (unsigned)input_height;
|
||||
*resize = false;
|
||||
|
||||
if (*width != emscripten->fb_width || *height != emscripten->fb_height)
|
||||
{
|
||||
printf("RESIZE: %dx%d\n", input_width, input_height);
|
||||
r = emscripten_set_canvas_element_size("#canvas", input_width, input_height);
|
||||
|
||||
if (r != EMSCRIPTEN_RESULT_SUCCESS)
|
||||
{
|
||||
RARCH_ERR("[EMSCRIPTEN/EGL]: error resizing canvas: %d\n", r);
|
||||
}
|
||||
|
||||
/* fix Module.requestFullscreen messing with the canvas size */
|
||||
r = emscripten_set_element_css_size("#canvas", (double)input_width, (double)input_height);
|
||||
|
||||
if (r != EMSCRIPTEN_RESULT_SUCCESS)
|
||||
{
|
||||
RARCH_ERR("[EMSCRIPTEN/EGL]: error resizing canvas css: %d\n", r);
|
||||
}
|
||||
|
||||
*resize = true;
|
||||
}
|
||||
|
||||
emscripten->fb_width = (unsigned)input_width;
|
||||
emscripten->fb_height = (unsigned)input_height;
|
||||
@ -202,20 +251,10 @@ static void gfx_ctx_emscripten_input_driver(void *data,
|
||||
const char *name,
|
||||
const input_driver_t **input, void **input_data)
|
||||
{
|
||||
void *rwebinput = NULL;
|
||||
void *rwebinput = input_rwebinput.init(name);
|
||||
|
||||
*input = NULL;
|
||||
*input_data = NULL;
|
||||
|
||||
#ifndef HAVE_SDL2
|
||||
rwebinput = input_rwebinput.init();
|
||||
|
||||
if (!rwebinput)
|
||||
return;
|
||||
|
||||
*input = &input_rwebinput;
|
||||
*input = rwebinput ? &input_rwebinput : NULL;
|
||||
*input_data = rwebinput;
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool gfx_ctx_emscripten_has_focus(void *data)
|
||||
|
@ -66,7 +66,7 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool rwebinput_key_pressed_internal(void *data, int key)
|
||||
static bool rwebinput_key_pressed(void *data, int key)
|
||||
{
|
||||
unsigned sym;
|
||||
bool ret;
|
||||
@ -89,18 +89,12 @@ static bool rwebinput_is_pressed(rwebinput_input_t *rwebinput,
|
||||
const struct retro_keybind *bind = &binds[id];
|
||||
int key = binds[id].key;
|
||||
return bind->valid && (key < RETROK_LAST)
|
||||
&& rwebinput_key_pressed_internal(rwebinput, key);
|
||||
&& rwebinput_key_pressed(rwebinput, key);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool rwebinput_key_pressed(void *data, int key)
|
||||
{
|
||||
rwebinput_input_t *rwebinput = (rwebinput_input_t*)data;
|
||||
return rwebinput_is_pressed(rwebinput, input_config_binds[0], key);
|
||||
}
|
||||
|
||||
static int16_t rwebinput_mouse_state(rwebinput_input_t *rwebinput, unsigned id)
|
||||
{
|
||||
switch (id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user