[Scummvm-git-logs] scummvm master -> 42dc7b31f4d30cc56a06d9b64d0f479d62e3ae2b
spleen1981
noreply at scummvm.org
Wed Apr 17 13:24:46 UTC 2024
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
42dc7b31f4 LIBRETRO: add OpenGL support
Commit: 42dc7b31f4d30cc56a06d9b64d0f479d62e3ae2b
https://github.com/scummvm/scummvm/commit/42dc7b31f4d30cc56a06d9b64d0f479d62e3ae2b
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2024-04-17T15:24:30+02:00
Commit Message:
LIBRETRO: add OpenGL support
Changed paths:
backends/platform/libretro/Makefile
backends/platform/libretro/Makefile.common
backends/platform/libretro/include/libretro-core-options-intl.h
backends/platform/libretro/include/libretro-core-options.h
backends/platform/libretro/include/libretro-core.h
backends/platform/libretro/include/libretro-defs.h
backends/platform/libretro/include/libretro-graphics.h
backends/platform/libretro/include/libretro-os.h
backends/platform/libretro/jni/Android.mk
backends/platform/libretro/src/libretro-core.cpp
backends/platform/libretro/src/libretro-graphics.cpp
backends/platform/libretro/src/libretro-os-base.cpp
backends/platform/libretro/src/libretro-os-events.cpp
backends/platform/libretro/src/libretro-os-inputs.cpp
diff --git a/backends/platform/libretro/Makefile b/backends/platform/libretro/Makefile
index 1953ebdb7ee..bb3b8ca94f9 100644
--- a/backends/platform/libretro/Makefile
+++ b/backends/platform/libretro/Makefile
@@ -45,6 +45,7 @@ ifeq ($(platform), rpi3_64)
LDFLAGS += -shared -Wl,--version-script=$(ROOT_PATH)/link.T -fPIC
CFLAGS += -fPIC -mcpu=cortex-a53 -mtune=cortex-a53 -fomit-frame-pointer -ffast-math
CXXFLAGS = $(CFLAGS) -frtti -std=c++11
+ HAVE_OPENGLES2 :=1
# Raspberry Pi 4 (64 bit)
else ifeq ($(platform), rpi4_64)
@@ -53,6 +54,7 @@ else ifeq ($(platform), rpi4_64)
LDFLAGS += -shared -Wl,--version-script=$(ROOT_PATH)/link.T -fPIC
CFLAGS += -fPIC -mcpu=cortex-a72 -mtune=cortex-a72 -fomit-frame-pointer -ffast-math
CXXFLAGS = $(CFLAGS) -frtti -std=c++11
+ HAVE_OPENGLES2 := 1
# iOS
else ifneq (,$(findstring ios,$(platform)))
@@ -60,6 +62,7 @@ else ifneq (,$(findstring ios,$(platform)))
DEFINES += -fPIC -DHAVE_POSIX_MEMALIGN=1 -DIOS
LDFLAGS += -dynamiclib -fPIC
MINVERSION :=
+ HAVE_OPENGLES2 := 1
ifeq ($(IOSSDK),)
IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
@@ -85,6 +88,7 @@ else ifeq ($(platform), tvos-arm64)
TARGET := $(TARGET_NAME)_libretro_tvos.$(EXT)
DEFINES += -fPIC -DHAVE_POSIX_MEMALIGN=1 -DIOS
LDFLAGS += -dynamiclib -fPIC
+ HAVE_OPENGLES2 := 1
ifeq ($(IOSSDK),)
IOSSDK := $(shell xcodebuild -version -sdk appletvos Path)
endif
@@ -101,23 +105,23 @@ else ifeq ($(platform), qnx)
LD = QCC -Vgcc_ntoarmv7le
AR = qcc -Vgcc_ntoarmv7le -A
RANLIB="${QNX_HOST}/usr/bin/ntoarmv7-ranlib"
+ HAVE_OPENGLES2 := 1
# Genode
else ifeq ($(platform), genode)
TARGET := libretro.so
- DEFINES += -fPIC -DSYSTEM_NOT_SUPPORTING_D_TYPE -DFRONTEND_SUPPORTS_RGB565 -DDEFAULT_PERF_TUNER
+ DEFINES += -fPIC -DSYSTEM_NOT_SUPPORTING_D_TYPE -DDEFAULT_PERF_TUNER
C_PKGS = libc
CXX_PKGS = stdcxx genode-base
CFLAGS += -D__GENODE__ $(shell pkg-config --cflags $(C_PKGS))
CXXFLAGS += -D__GENODE__ $(shell pkg-config --cflags $(CXX_PKGS))
-
LIBS += $(shell pkg-config --libs $(C_PKGS) $(CXX_PKGS) genode-lib)
-
CC = $(shell pkg-config genode-base --variable=cc)
CXX = $(shell pkg-config genode-base --variable=cxx)
LD = $(shell pkg-config genode-base --variable=ld)
AR = $(shell pkg-config genode-base --variable=ar) rcs
RANLIB = genode-x86-ranlib
+ HAVE_OPENGL := 1
# Lightweight PS3 Homebrew SDK
else ifneq (,$(filter $(platform), ps3 psl1ght))
@@ -128,6 +132,7 @@ else ifneq (,$(filter $(platform), ps3 psl1ght))
DEFINES := -DPLAYSTATION3 -D__PS3__ -DRETRO_IS_BIG_ENDIAN=1 -DRETRO_IS_LITTLE_ENDIAN=0 -DWORDS_BIGENDIAN=1 -mcpu=cell -mno-fp-in-toc -I$(PS3DEV)/ppu/include
ifeq ($(platform), psl1ght)
DEFINES += -D__PSL1GHT__
+ HAVE_OPENGL := 1
endif
STATIC_LINKING = 1
@@ -154,6 +159,7 @@ else ifeq ($(platform), libnx)
DEFINES += -D__SWITCH__ -DHAVE_LIBNX -march=armv8-a -mtune=cortex-a57 -mtp=soft
CXXFLAGS := $(ASFLAGS) -std=gnu++11 -fpermissive
STATIC_LINKING = 1
+ HAVE_OPENGL := 1
# Nintendo Wii U
else ifeq ($(platform), wiiu)
@@ -202,6 +208,7 @@ else ifeq ($(platform), vita)
USE_LIBCO = 0
LITE := 1
STATIC_LINKING = 1
+ HAVE_OPENGLES2 := 1
# GCW0
else ifeq ($(platform), gcw0)
@@ -216,6 +223,7 @@ else ifeq ($(platform), gcw0)
LDFLAGS += -shared -Wl,--gc-sections -Wl,--version-script=$(ROOT_PATH)/link.T -fPIC
CFLAGS += -std=gnu99
CXXFLAGS += -std=c++11
+ HAVE_OPENGLES2 := 1
USE_VORBIS = 0
USE_THEORADEC = 0
USE_TREMOR = 1
@@ -285,6 +293,7 @@ ifneq (,$(findstring softfloat,$(platform)))
else ifneq (,$(findstring hardfloat,$(platform)))
DEFINES += -mfloat-abi=hard
endif
+ HAVE_OPENGLES2 := 1
# ARM v8
else ifneq (,$(findstring armv8,$(platform)))
@@ -293,6 +302,7 @@ else ifneq (,$(findstring armv8,$(platform)))
LDFLAGS += -shared -Wl,--version-script=$(ROOT_PATH)/link.T -fPIC
CFLAGS += -fPIC
HAVE_NEON = 1
+ HAVE_OPENGLES2 := 1
# Odroid Go Advance
else ifneq (,$(findstring oga_a35_neon_hardfloat,$(platform)))
@@ -304,6 +314,7 @@ else ifneq (,$(findstring oga_a35_neon_hardfloat,$(platform)))
USE_TREMOR = 1
USE_MT32EMU = 0
HAVE_NEON = 1
+ HAVE_OPENGLES2 := 1
# Emscripten
else ifeq ($(platform), emscripten)
@@ -410,6 +421,7 @@ else ifneq (,$(findstring windows_msvc2017,$(platform)))
TARGET := $(TARGET_NAME)_libretro.dll
PSS_STYLE :=2
LDFLAGS += -DLL
+ HAVE_OPENGL := 1
else ifeq ($(platform), win)
# let out for next test block
@@ -456,6 +468,7 @@ ifeq ($(platform), unix)
LDFLAGS += -shared -Wl,--version-script=$(ROOT_PATH)/link.T -fPIC
CFLAGS += -fPIC
CXXFLAGS += $(CFLAGS) -std=c++11
+ HAVE_OPENGL := 1
# Win fallback
else ifeq ($(platform), win)
CC ?= gcc
@@ -466,14 +479,14 @@ else ifeq ($(platform), win)
ifneq ($(TARGET_64BIT),1)
DEFINES += -DRETRO_CALLCONV=__cdecl
endif
-
+ HAVE_OPENGL := 1
# OS X
else ifeq ($(platform), osx)
TARGET := $(TARGET_NAME)_libretro.dylib
DEFINES += -fPIC -Wno-undefined-var-template -Wno-pragma-pack -DHAVE_POSIX_MEMALIGN=1 -DUSE_CXX11
LDFLAGS += -dynamiclib -fPIC
CXXFLAGS := -std=c++11
-
+ HAVE_OPENGL := 1
ifeq ($(CROSS_COMPILE),1)
TARGET_RULE = -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
CFLAGS += $(TARGET_RULE)
diff --git a/backends/platform/libretro/Makefile.common b/backends/platform/libretro/Makefile.common
index 38323508f97..c03d83750f9 100644
--- a/backends/platform/libretro/Makefile.common
+++ b/backends/platform/libretro/Makefile.common
@@ -38,7 +38,7 @@ DEBUG ?= 0
DEBUG_ALLOW_DIRTY_SUBMODULES ?= 0
# Variable engines dependencies
-UNAVAILABLE_DEPS := opengl_game_shaders
+UNAVAILABLE_DEPS :=
check_deps_availability = $(shell [ $(1) = 0 ] && echo $(2))
USE_HIGHRES ?= 1
@@ -90,7 +90,7 @@ SCUMMVM_EXTRA_SUBDIR := extra
SCUMMVM_THEME_SUBDIR := theme
INCLUDES += -I$(SCUMMVM_PATH)
-DEFINES += -D__LIBRETRO__ -DNONSTANDARD_PORT -DUSE_RGB_COLOR -DUSE_OSD -DFRONTEND_SUPPORTS_RGB565 -DUSE_TRANSLATION -DDETECTION_STATIC -DHAVE_CONFIG_H -DUSE_BINK -DUSE_LUA -DUSE_TINYGL -DENABLE_VKEYBD
+DEFINES += -D__LIBRETRO__ -DNONSTANDARD_PORT -DUSE_RGB_COLOR -DUSE_OSD -DUSE_TRANSLATION -DDETECTION_STATIC -DHAVE_CONFIG_H -DUSE_BINK -DUSE_LUA -DUSE_TINYGL -DENABLE_VKEYBD
DEFINES += -DCORE_NAME=\"$(CORE_NAME)\" -DCORE_EXTENSIONS=\"$(CORE_EXTENSIONS)\" -DSCUMMVM_SYSTEM_SUBDIR=\"$(SCUMMVM_SYSTEM_SUBDIR)\" -DSCUMMVM_EXTRA_SUBDIR=\"$(SCUMMVM_EXTRA_SUBDIR)\" -DSCUMMVM_THEME_SUBDIR=\"$(SCUMMVM_THEME_SUBDIR)\"
CXXFLAGS += -Wno-long-long -Wno-multichar -Wno-unknown-pragmas -Wno-reorder -Wno-undefined-var-template
@@ -112,6 +112,23 @@ else
DEFINES += -DDISABLE_TEXT_CONSOLE -DRELEASE_BUILD
endif
+ifeq ($(or $(HAVE_OPENGL), $(HAVE_OPENGLES2)), 1)
+ USE_OPENGL := 1
+ USE_OPENGL_GAME := 1
+ USE_OPENGL_SHADERS := 1
+ DEFINES += -DUSE_OPENGL -DUSE_GLAD -DUSE_OPENGL_GAME -DUSE_OPENGL_SHADERS
+ifeq ($(HAVE_OPENGL), 1)
+ DEFINES += -DHAVE_OPENGL
+ $(info Support for OpenGL requested)
+else
+ DEFINES += -DHAVE_OPENGLES2
+ $(info Support for OpenGLES2 requested)
+endif
+else
+ UNAVAILABLE_DEPS += opengl_game_shaders
+ $(info No support for OpenGL/OpenGLES2 requested)
+endif
+
######################################################################
# Libretro settings
######################################################################
diff --git a/backends/platform/libretro/include/libretro-core-options-intl.h b/backends/platform/libretro/include/libretro-core-options-intl.h
index fc552cf80f3..dd1da6f27f5 100644
--- a/backends/platform/libretro/include/libretro-core-options-intl.h
+++ b/backends/platform/libretro/include/libretro-core-options-intl.h
@@ -70,6 +70,11 @@ extern "C" {
/* RETRO_LANGUAGE_ITALIAN */
struct retro_core_option_v2_category option_cats_it[] = {
+ {
+ "video",
+ NULL,
+ "Configura le impostazioni video"
+ },
{
"cursor",
"Cursore",
@@ -556,6 +561,18 @@ struct retro_core_option_v2_definition option_defs_it[] = {
},
NULL,
},
+ {
+ "scummvm_video_hw_acceleration",
+ "Video > Accelerazione hardware",
+ "Accelerazione hardware",
+ "Richiede accelerazione hardware (OpenGL or OpenGLES2) al frontend, se supportata. Ã necessario ricaricare il core per rendere effettiva questa opzione",
+ NULL,
+ NULL,
+ {
+ { NULL, NULL }
+ },
+ NULL,
+ },
{ NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL },
};
struct retro_core_options_v2 options_it = {
diff --git a/backends/platform/libretro/include/libretro-core-options.h b/backends/platform/libretro/include/libretro-core-options.h
index f7f2e920598..c65dfb8f8c7 100644
--- a/backends/platform/libretro/include/libretro-core-options.h
+++ b/backends/platform/libretro/include/libretro-core-options.h
@@ -72,6 +72,11 @@ extern "C" {
struct retro_core_option_v2_category option_cats_us[] = {
+ {
+ "video",
+ "Video settings",
+ "Configure video settings"
+ },
{
"cursor",
"Cursor Movement",
@@ -632,6 +637,25 @@ struct retro_core_option_v2_definition option_defs_us[] = {
},
"RETROK_RIGHT"
},
+ {
+ "scummvm_video_hw_acceleration",
+ "Video > Hardware acceleration",
+ "Hardware acceleration",
+ "Request video hardware acceleration (OpenGL or OpenGLES2) to the frontend if supported. It is needed to reload the core to apply this setting.",
+ NULL,
+ "video",
+ {
+ {"disabled", NULL},
+#ifdef USE_OPENGL
+ {"enabled", NULL},
+#endif
+ {NULL, NULL}, },
+#ifdef USE_OPENGL
+ "enabled"
+#else
+ "disabled"
+#endif
+ },
{ NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL },
};
diff --git a/backends/platform/libretro/include/libretro-core.h b/backends/platform/libretro/include/libretro-core.h
index a2af6e2bee9..ece0aa3c6da 100644
--- a/backends/platform/libretro/include/libretro-core.h
+++ b/backends/platform/libretro/include/libretro-core.h
@@ -43,4 +43,9 @@ bool retro_setting_get_gamepad_cursor_only(void);
float retro_setting_get_gamepad_cursor_speed(void);
float retro_setting_get_gamepad_acceleration_time(void);
+uint8 retro_get_video_hw_mode(void);
+#ifdef USE_OPENGL
+uintptr_t retro_get_hw_fb(void);
+void * retro_get_proc_address(const char * name);
+#endif
#endif // LIBRETRO_CORE_H
diff --git a/backends/platform/libretro/include/libretro-defs.h b/backends/platform/libretro/include/libretro-defs.h
index 392a8150429..605cc4af71b 100644
--- a/backends/platform/libretro/include/libretro-defs.h
+++ b/backends/platform/libretro/include/libretro-defs.h
@@ -43,7 +43,14 @@ will be updated to include it */
#define AUDIO_STATUS_BUFFER_ACTIVE (1 << 2)
#define AUDIO_STATUS_BUFFER_UNDERRUN (1 << 3)
#define AUDIO_STATUS_UPDATE_LATENCY (1 << 4)
-#define AUDIO_STATUS_UPDATE_AV_INFO (1 << 5)
+#define AUDIO_STATUS_UPDATE_AV_INFO (1 << 5)
+
+// Video status
+#define VIDEO_GRAPHIC_MODE_REQUEST_SW (1 << 0)
+#define VIDEO_GRAPHIC_MODE_REQUEST_HW (1 << 1)
+#define VIDEO_GRAPHIC_MODE_HAVE_OPENGL (1 << 2)
+#define VIDEO_GRAPHIC_MODE_HAVE_OPENGLES2 (1 << 3)
+#define VIDEO_GRAPHIC_MODE_RESET_PENDING (1 << 4)
// Preliminary scan results
#define TEST_GAME_OK_TARGET_FOUND 0
diff --git a/backends/platform/libretro/include/libretro-graphics.h b/backends/platform/libretro/include/libretro-graphics.h
index 884f9f62ea3..b37466d4b2f 100644
--- a/backends/platform/libretro/include/libretro-graphics.h
+++ b/backends/platform/libretro/include/libretro-graphics.h
@@ -22,6 +22,10 @@
#include "graphics/surface.h"
#include "backends/graphics/graphics.h"
+#ifdef USE_OPENGL
+#include "backends/graphics/opengl/opengl-graphics.h"
+#endif
+
class LibretroPalette {
public:
const byte *_prevColorsSource;
@@ -76,7 +80,7 @@ public:
int16 getOverlayHeight(void) const override;
int16 getOverlayWidth(void) const override;
Graphics::PixelFormat getOverlayFormat() const override;
- const Graphics::Surface &getScreen(void);
+ const Graphics::Surface *getScreen(void);
bool showMouse(bool visible) override;
void warpMouse(int x, int y) override;
void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 255, bool dontScale = false, const Graphics::PixelFormat *format = NULL, const byte *mask = nullptr) override;
@@ -124,4 +128,22 @@ protected:
void grabPalette(byte *colors, uint start, uint num) const override;
};
+#ifdef USE_OPENGL
+class LibretroOpenGLGraphics : public OpenGL::OpenGLGraphicsManager {
+public:
+ LibretroOpenGLGraphics(OpenGL::ContextType contextType);
+ bool loadVideoMode(uint requestedWidth, uint requestedHeight, const Graphics::PixelFormat &format) override { return true; };
+ void refreshScreen() override;
+ void setSystemMousePosition(const int x, const int y) override {};
+
+ bool isOverlayInGUI(void){ return _overlayInGUI; }
+ void setMousePosition(int x, int y);
+};
+
+class LibretroHWFramebuffer : public OpenGL::Backbuffer {
+
+protected:
+ void activateInternal() override;
+};
#endif
+#endif //BACKENDS_LIBRETRO_GRAPHICS_H
diff --git a/backends/platform/libretro/include/libretro-os.h b/backends/platform/libretro/include/libretro-os.h
index 1f5bf2666cd..033bfe5df34 100644
--- a/backends/platform/libretro/include/libretro-os.h
+++ b/backends/platform/libretro/include/libretro-os.h
@@ -34,7 +34,6 @@
#define CURSOR_STATUS_DOING_SLOWER (1 << 4)
#define LIBRETRO_G_SYSTEM dynamic_cast<OSystem_libretro *>(g_system)
-#define LIBRETRO_GRAPHICS_MANAGER dynamic_cast<LibretroGraphics *>(_graphicsManager)
/**
* Dummy mutex implementation
@@ -43,12 +42,15 @@ class LibretroMutexInternal final : public Common::MutexInternal {
public:
LibretroMutexInternal() {};
~LibretroMutexInternal() override {};
- bool lock() override { return 0; }
- bool unlock() override { return 0; };
+ bool lock() override {
+ return 0;
+ }
+ bool unlock() override {
+ return 0;
+ };
};
-
-class OSystem_libretro : public EventsBaseBackend, ModularGraphicsBackend {
+class OSystem_libretro : public EventsBaseBackend, public ModularGraphicsBackend {
private:
int _relMouseX;
int _relMouseY;
@@ -84,9 +86,19 @@ public:
void destroy(void);
void quit() override {}
+ void resetGraphicsManager(void);
+ void getScreen(const Graphics::Surface *&screen);
+ int16 getScreenWidth(void);
+ int16 getScreenHeight(void);
+ bool isOverlayInGUI(void);
+
+#ifdef USE_OPENGL
+ void *getOpenGLProcAddress(const char *name) const override;
+#endif
+
private:
bool checkPathSetting(const char *setting, Common::String const &defaultPath, bool isDirectory = true);
- void setLibretroDir(const char * path, Common::String &var);
+ void setLibretroDir(const char *path, Common::String &var);
/* Events */
public:
@@ -97,6 +109,8 @@ public:
void requestQuit(void);
void resetQuit(void);
+ void setMousePosition(int x, int y);
+
/* Utils */
void getTimeAndDate(TimeDate &t, bool skipRecord) const override;
Audio::Mixer *getMixer(void) override;
@@ -104,11 +118,10 @@ public:
void logMessage(LogMessageType::Type type, const char *message) override;
int testGame(const char *filedata, bool autodetect);
void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) override;
- const char * const *buildHelpDialogData() override;
+ const char *const *buildHelpDialogData() override;
Common::String getSaveDir(void);
GUI::OptionsContainerWidget *buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
void applyBackendSettings() override;
- const Graphics::Surface &getScreen(void);
private:
bool parseGameName(const Common::String &gameName, Common::String &engineId, Common::String &gameId);
@@ -117,7 +130,7 @@ public:
void processInputs(void);
void processKeyEvent(bool down, unsigned keycode, uint32 character, uint16 key_modifiers);
private:
- void updateMouseXY(float deltaAcc, float * cumulativeXYAcc, int doing_x);
+ void updateMouseXY(float deltaAcc, float *cumulativeXYAcc, int doing_x);
void getMouseXYFromAnalog(bool is_x, int16 coor);
void getMouseXYFromButton(bool is_x, int16 sign);
};
diff --git a/backends/platform/libretro/jni/Android.mk b/backends/platform/libretro/jni/Android.mk
index e9c22045982..9d63b87bef0 100644
--- a/backends/platform/libretro/jni/Android.mk
+++ b/backends/platform/libretro/jni/Android.mk
@@ -1,8 +1,9 @@
LOCAL_PATH := $(call my-dir)
ROOT_PATH := $(LOCAL_PATH)/..
TARGET_NAME := scummvm
+HAVE_OPENGLES2 := 1
-# Reset flags not reset to Makefile.common
+# Reset flags not reset to Makefile.common
DEFINES :=
# All current 64-bit archs have 64 in the abi name
diff --git a/backends/platform/libretro/src/libretro-core.cpp b/backends/platform/libretro/src/libretro-core.cpp
index 0342e4317ad..da21dbcec51 100644
--- a/backends/platform/libretro/src/libretro-core.cpp
+++ b/backends/platform/libretro/src/libretro-core.cpp
@@ -79,8 +79,7 @@ static bool timing_inaccuracies_enabled = false;
char cmd_params[20][200];
char cmd_params_num;
-int adjusted_RES_W = 0;
-int adjusted_RES_H = 0;
+static uint8 video_hw_mode = 0;
static uint32 current_frame = 0;
static uint8 frameskip_no;
@@ -106,6 +105,62 @@ static bool updating_variables = false;
static int opt_frameskip_threshold_display = 0;
static int opt_frameskip_no_display = 0;
+#ifdef USE_OPENGL
+static struct retro_hw_render_callback hw_render;
+
+static void context_reset(void) {
+ retro_log_cb(RETRO_LOG_DEBUG, "HW context reset\n");
+}
+
+static void context_destroy(void) {
+ retro_log_cb(RETRO_LOG_DEBUG, "HW context destroy\n");
+}
+
+uintptr_t retro_get_hw_fb(void) {
+ return hw_render.get_current_framebuffer();
+}
+
+void *retro_get_proc_address(const char *name) {
+ return (void *)(hw_render.get_proc_address(name));
+}
+#endif
+
+static void setup_hw_rendering(void) {
+
+ enum retro_pixel_format pixel_fmt;
+#ifdef USE_OPENGL
+ if (video_hw_mode & VIDEO_GRAPHIC_MODE_REQUEST_HW) {
+ pixel_fmt = RETRO_PIXEL_FORMAT_XRGB8888;
+ if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &pixel_fmt) && retro_log_cb)
+ retro_log_cb(RETRO_LOG_WARN, "RETRO_PIXEL_FORMAT_XRGB8888 not supported.\n");
+ hw_render.context_reset = context_reset;
+ hw_render.context_destroy = context_destroy;
+ hw_render.cache_context = true;
+ hw_render.bottom_left_origin = true;
+#if defined(HAVE_OPENGL)
+ hw_render.context_type = RETRO_HW_CONTEXT_OPENGL;
+ video_hw_mode |= VIDEO_GRAPHIC_MODE_HAVE_OPENGL;
+#elif defined(HAVE_OPENGLES2)
+ hw_render.context_type = RETRO_HW_CONTEXT_OPENGLES2;
+ video_hw_mode |= VIDEO_GRAPHIC_MODE_HAVE_OPENGLES2;
+#endif
+ if (!environ_cb(RETRO_ENVIRONMENT_SET_HW_RENDER, &hw_render)) {
+ retro_log_cb(RETRO_LOG_WARN, "Failed to set up hardware rendering, falling back to software.\n");
+ retro_osd_notification("Failed to set up HW rendering.");
+ video_hw_mode = VIDEO_GRAPHIC_MODE_REQUEST_SW;
+ }
+ }
+#endif
+ if ((video_hw_mode & VIDEO_GRAPHIC_MODE_REQUEST_SW) || !video_hw_mode) {
+ pixel_fmt = RETRO_PIXEL_FORMAT_RGB565;
+ if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &pixel_fmt) && retro_log_cb)
+ retro_log_cb(RETRO_LOG_WARN, "RETRO_PIXEL_FORMAT_RGB565 not supported.\n");
+ }
+}
+
+uint8 retro_get_video_hw_mode(void) {
+ return video_hw_mode;
+}
void process_key_event_wrapper(bool down, unsigned keycode, uint32_t character, uint16_t key_modifiers) {
LIBRETRO_G_SYSTEM->processKeyEvent(down, keycode, character, key_modifiers);
@@ -468,6 +523,24 @@ static void update_variables(void) {
mapper_set_device_keys(RETRO_DEVICE_ID_JOYPAD_RR, var.value);
}
+ var.key = "scummvm_video_hw_acceleration";
+ var.value = NULL;
+ if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
+ if (strcmp(var.value, "enabled") == 0) {
+ if (video_hw_mode & VIDEO_GRAPHIC_MODE_REQUEST_SW) {
+ // video_hw_mode = VIDEO_GRAPHIC_MODE_REQUEST_HW;
+ video_hw_mode |= VIDEO_GRAPHIC_MODE_RESET_PENDING;
+ } else if (!video_hw_mode)
+ video_hw_mode = VIDEO_GRAPHIC_MODE_REQUEST_HW;
+ } else {
+ if (video_hw_mode & VIDEO_GRAPHIC_MODE_REQUEST_HW) {
+ // video_hw_mode = VIDEO_GRAPHIC_MODE_REQUEST_SW;
+ video_hw_mode |= VIDEO_GRAPHIC_MODE_RESET_PENDING;
+ } else if (!video_hw_mode)
+ video_hw_mode = VIDEO_GRAPHIC_MODE_REQUEST_SW;
+ }
+ }
+
if (!(audio_status & AUDIO_STATUS_BUFFER_SUPPORT)) {
if (frameskip_type > 1) {
retro_log_cb(RETRO_LOG_WARN, "Selected frameskip mode not available.\n");
@@ -484,6 +557,16 @@ static void update_variables(void) {
audio_status |= AUDIO_STATUS_UPDATE_AV_INFO;
}
}
+
+ if (video_hw_mode & VIDEO_GRAPHIC_MODE_RESET_PENDING) {
+ /* TODO: evaluate if setting can be applied on the fly
+ setup_hw_rendering();
+ LIBRETRO_G_SYSTEM->resetGraphicsManager();
+ retro_reset(); */
+ retro_osd_notification("Core reload is needed to apply HW acceleration setting change.");
+ video_hw_mode &= ~VIDEO_GRAPHIC_MODE_RESET_PENDING;
+ }
+
updating_variables = false;
}
@@ -792,26 +875,12 @@ void retro_init(void) {
init_command_params();
+ setup_hw_rendering();
+
environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, retro_input_desc);
environ_cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void *)retro_controller_lists);
- /* Get color mode: 32 first as VGA has 6 bits per pixel */
-#if 0
- RDOSGFXcolorMode = RETRO_PIXEL_FORMAT_XRGB8888;
- if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &RDOSGFXcolorMode)) {
- RDOSGFXcolorMode = RETRO_PIXEL_FORMAT_RGB565;
- if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &RDOSGFXcolorMode))
- RDOSGFXcolorMode = RETRO_PIXEL_FORMAT_0RGB1555;
- }
-#endif
-
-#ifdef FRONTEND_SUPPORTS_RGB565
- enum retro_pixel_format rgb565 = RETRO_PIXEL_FORMAT_RGB565;
- if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &rgb565) && retro_log_cb)
- retro_log_cb(RETRO_LOG_INFO, "Frontend supports RGB565 -will use that instead of XRGB1555.\n");
-#endif
-
retro_keyboard_callback cb = {process_key_event_wrapper};
environ_cb(RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK, &cb);
@@ -858,7 +927,7 @@ void retro_set_controller_port_device(unsigned port, unsigned device) {
bool retro_load_game(const struct retro_game_info *game) {
if (!g_system) {
if (retro_log_cb)
- retro_log_cb(RETRO_LOG_ERROR, "[scummvm] Failed to initialize platform driver.\n");
+ retro_log_cb(RETRO_LOG_ERROR, "[scummvm] Failed to initialize ScummVM.\n");
return false;
}
@@ -994,7 +1063,6 @@ void retro_run(void) {
return;
}
-
/* Setting RA's video or audio driver to null will disable video/audio bits */
int audio_video_enable = 0;
environ_cb(RETRO_ENVIRONMENT_GET_AUDIO_VIDEO_ENABLE, &audio_video_enable);
@@ -1038,10 +1106,16 @@ void retro_run(void) {
audio_run();
/* Retrieve video */
- if ((audio_video_enable & 1) && !skip_frame) {
- const Graphics::Surface &screen = LIBRETRO_G_SYSTEM->getScreen();
- video_cb(screen.getPixels(), screen.w, screen.h, screen.pitch);
+ if (!skip_frame && (audio_video_enable & 1)) {
+ if (video_hw_mode & VIDEO_GRAPHIC_MODE_REQUEST_SW) {
+ const Graphics::Surface *screen;
+ LIBRETRO_G_SYSTEM->getScreen(screen);
+ video_cb(screen->getPixels(), screen->w, screen->h, screen->pitch);
+ } else
+ video_cb(RETRO_HW_FRAME_BUFFER_VALID, LIBRETRO_G_SYSTEM->getScreenWidth(), LIBRETRO_G_SYSTEM->getScreenHeight(), 0);
+
}
+
current_frame++;
poll_cb();
diff --git a/backends/platform/libretro/src/libretro-graphics.cpp b/backends/platform/libretro/src/libretro-graphics.cpp
index 32596740ff3..255719d0d88 100644
--- a/backends/platform/libretro/src/libretro-graphics.cpp
+++ b/backends/platform/libretro/src/libretro-graphics.cpp
@@ -27,6 +27,12 @@
#include "backends/platform/libretro/include/libretro-timer.h"
#include "backends/platform/libretro/include/libretro-graphics.h"
+#ifdef USE_OPENGL
+#include "backends/graphics/opengl/opengl-graphics.h"
+#include "backends/graphics/opengl/framebuffer.h"
+#include "graphics/opengl/debug.h"
+#endif
+
static INLINE void blit_uint8_uint16_fast(Graphics::Surface &aOut, const Graphics::Surface &aIn, const LibretroPalette &aColors) {
for (int i = 0; i < aIn.h; i++) {
if (i >= aOut.h)
@@ -230,11 +236,7 @@ unsigned char *LibretroPalette::getColor(uint aIndex) const {
}
LibretroGraphics::LibretroGraphics() : _mousePaletteEnabled(false), _mouseVisible(false), _mouseKeyColor(0), _mouseDontScale(false), _screenUpdatePending(false) {
-#ifdef FRONTEND_SUPPORTS_RGB565
_overlay.create(RES_W_OVERLAY, RES_H_OVERLAY, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
-#else
- _overlay.create(RES_W_OVERLAY, RES_H_OVERLAY, Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15));
-#endif
}
LibretroGraphics::~LibretroGraphics() {
@@ -254,10 +256,9 @@ Common::List<Graphics::PixelFormat> LibretroGraphics::getSupportedFormats() cons
/* ABGR8888 */
result.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
#endif
-#ifdef FRONTEND_SUPPORTS_RGB565
/* RGB565 - overlay */
result.push_back(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
-#endif
+
/* RGB555 - fmtowns */
result.push_back(Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15));
@@ -419,18 +420,13 @@ bool LibretroGraphics::isOverlayInGUI(void) {
return _overlayInGUI;
}
-const Graphics::Surface &LibretroGraphics::getScreen() {
+const Graphics::Surface *LibretroGraphics::getScreen() {
const Graphics::Surface &srcSurface = (_overlayInGUI) ? _overlay : _gameScreen;
- if (srcSurface.w != _screen.w || srcSurface.h != _screen.h) {
-#ifdef FRONTEND_SUPPORTS_RGB565
+ if (srcSurface.w != _screen.w || srcSurface.h != _screen.h)
_screen.create(srcSurface.w, srcSurface.h, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
-#else
- _screen.create(srcSurface.w, srcSurface.h, Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15));
-#endif
- }
- return _screen;
+ return &_screen;
}
void LibretroGraphics::setPalette(const byte *colors, uint start, uint num) {
@@ -454,3 +450,27 @@ bool LibretroGraphics::getFeatureState(OSystem::Feature f) const {
return (f == OSystem::kFeatureCursorPalette) ? _mousePaletteEnabled : false;
}
+#ifdef USE_OPENGL
+LibretroOpenGLGraphics::LibretroOpenGLGraphics(OpenGL::ContextType contextType) {
+ const Graphics::PixelFormat rgba8888 =
+#ifdef SCUMM_LITTLE_ENDIAN
+ Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
+#else
+ Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
+#endif
+ notifyContextCreate(contextType, new LibretroHWFramebuffer(), rgba8888, rgba8888);
+ handleResize(RES_W_OVERLAY, RES_H_OVERLAY);
+}
+
+void LibretroOpenGLGraphics::refreshScreen(){
+ dynamic_cast<LibretroTimerManager *>(LIBRETRO_G_SYSTEM->getTimerManager())->checkThread(THREAD_SWITCH_UPDATE);
+}
+
+void LibretroOpenGLGraphics::setMousePosition(int x, int y){
+ OpenGL::OpenGLGraphicsManager::setMousePosition(x,y);
+}
+
+void LibretroHWFramebuffer::activateInternal(){
+ GL_CALL(glBindFramebuffer(GL_FRAMEBUFFER, retro_get_hw_fb()));
+}
+#endif
diff --git a/backends/platform/libretro/src/libretro-os-base.cpp b/backends/platform/libretro/src/libretro-os-base.cpp
index 8a4f7bb10e9..6c3fd1bf25b 100644
--- a/backends/platform/libretro/src/libretro-os-base.cpp
+++ b/backends/platform/libretro/src/libretro-os-base.cpp
@@ -111,10 +111,9 @@ void OSystem_libretro::initBackend() {
_mixer->setReady(true);
- _graphicsManager = new LibretroGraphics();
+ resetGraphicsManager();
EventsBaseBackend::initBackend();
-
refreshRetroSettings();
}
@@ -124,8 +123,12 @@ void OSystem_libretro::engineInit() {
ConfMan.setBool("original_gui", false);
retro_log_cb(RETRO_LOG_INFO, "\"original_gui\" setting forced to false\n");
}
- LIBRETRO_GRAPHICS_MANAGER->_mousePalette.reset();
- LIBRETRO_GRAPHICS_MANAGER->_gamePalette.reset();
+
+ /* See LibretroPalette::set workaround */
+ if (retro_get_video_hw_mode() & VIDEO_GRAPHIC_MODE_REQUEST_SW){
+ dynamic_cast<LibretroGraphics *>(_graphicsManager)->_mousePalette.reset();
+ dynamic_cast<LibretroGraphics *>(_graphicsManager)->_gamePalette.reset();
+ }
}
Audio::Mixer *OSystem_libretro::getMixer() {
@@ -133,7 +136,7 @@ Audio::Mixer *OSystem_libretro::getMixer() {
}
void OSystem_libretro::refreshRetroSettings() {
- _adjusted_cursor_speed = (float)BASE_CURSOR_SPEED * retro_setting_get_gamepad_cursor_speed() * (float)(LIBRETRO_GRAPHICS_MANAGER->isOverlayInGUI() ? LIBRETRO_GRAPHICS_MANAGER->getOverlayWidth() : LIBRETRO_GRAPHICS_MANAGER->getWidth()) / 320.0f; // Dpad cursor speed should always be based off a 320 wide screen, to keep speeds consistent;
+ _adjusted_cursor_speed = (float)BASE_CURSOR_SPEED * retro_setting_get_gamepad_cursor_speed() * (float)getScreenWidth() / 320.0f; // Dpad cursor speed should always be based off a 320 wide screen, to keep speeds consistent;
_inverse_acceleration_time = (retro_setting_get_gamepad_acceleration_time() > 0.0) ? (1.0f / (float)retro_setting_get_frame_rate()) * (1.0f / retro_setting_get_gamepad_acceleration_time()) : 1.0f;
}
@@ -164,10 +167,66 @@ void OSystem_libretro::setLibretroDir(const char * path, Common::String &var) {
return;
}
-const Graphics::Surface &OSystem_libretro::getScreen() {
- return LIBRETRO_GRAPHICS_MANAGER->getScreen();
+void OSystem_libretro::getScreen(const Graphics::Surface *&screen) {
+ if (retro_get_video_hw_mode() & VIDEO_GRAPHIC_MODE_REQUEST_SW)
+ screen = dynamic_cast<LibretroGraphics *>(_graphicsManager)->getScreen();
}
void OSystem_libretro::refreshScreen(void) {
- LIBRETRO_GRAPHICS_MANAGER->realUpdateScreen();
+ if (retro_get_video_hw_mode() & VIDEO_GRAPHIC_MODE_REQUEST_SW)
+ dynamic_cast<LibretroGraphics *>(_graphicsManager)->realUpdateScreen();
+}
+
+#ifdef USE_OPENGL
+void *OSystem_libretro::getOpenGLProcAddress(const char *name) const {
+ return retro_get_proc_address(name);
+}
+#endif
+
+int16 OSystem_libretro::getScreenWidth(void){
+#ifdef USE_OPENGL
+ if (retro_get_video_hw_mode() & VIDEO_GRAPHIC_MODE_REQUEST_HW)
+ return dynamic_cast<LibretroOpenGLGraphics *>(_graphicsManager)->getWindowWidth();
+#endif
+ if (dynamic_cast<LibretroGraphics *>(_graphicsManager)->isOverlayInGUI())
+ return dynamic_cast<LibretroGraphics *>(_graphicsManager)->getOverlayWidth();
+ else
+ return dynamic_cast<LibretroGraphics *>(_graphicsManager)->getWidth();
+}
+
+int16 OSystem_libretro::getScreenHeight(void){
+#ifdef USE_OPENGL
+ if (retro_get_video_hw_mode() & VIDEO_GRAPHIC_MODE_REQUEST_HW)
+ return dynamic_cast<LibretroOpenGLGraphics *>(_graphicsManager)->getWindowHeight();
+#endif
+ if (dynamic_cast<LibretroGraphics *>(_graphicsManager)->isOverlayInGUI())
+ return dynamic_cast<LibretroGraphics *>(_graphicsManager)->getOverlayHeight();
+ else
+ return dynamic_cast<LibretroGraphics *>(_graphicsManager)->getHeight();
+}
+
+bool OSystem_libretro::isOverlayInGUI(void) {
+#ifdef USE_OPENGL
+ if (retro_get_video_hw_mode() & VIDEO_GRAPHIC_MODE_REQUEST_HW)
+ return dynamic_cast<LibretroOpenGLGraphics *>(_graphicsManager)->isOverlayInGUI();
+ else
+#endif
+ return dynamic_cast<LibretroGraphics *>(_graphicsManager)->isOverlayInGUI();
+}
+
+void OSystem_libretro::resetGraphicsManager(void) {
+
+ if (_graphicsManager) {
+ delete _graphicsManager;
+ _graphicsManager = nullptr;
+ }
+
+#ifdef USE_OPENGL
+ if ((retro_get_video_hw_mode() & VIDEO_GRAPHIC_MODE_REQUEST_HW) && (retro_get_video_hw_mode() & VIDEO_GRAPHIC_MODE_HAVE_OPENGL))
+ _graphicsManager = new LibretroOpenGLGraphics(OpenGL::kContextGL);
+ else if ((retro_get_video_hw_mode() & VIDEO_GRAPHIC_MODE_REQUEST_HW) && (retro_get_video_hw_mode() & VIDEO_GRAPHIC_MODE_HAVE_OPENGLES2))
+ _graphicsManager = new LibretroOpenGLGraphics(OpenGL::kContextGLES2);
+ else
+#endif
+ _graphicsManager = new LibretroGraphics();
}
diff --git a/backends/platform/libretro/src/libretro-os-events.cpp b/backends/platform/libretro/src/libretro-os-events.cpp
index 7ca1ada6519..3f04edc8212 100644
--- a/backends/platform/libretro/src/libretro-os-events.cpp
+++ b/backends/platform/libretro/src/libretro-os-events.cpp
@@ -50,7 +50,7 @@ void OSystem_libretro::delayMillis(uint msecs) {
while (elapsed_time < msecs) {
/* When remaining delay would take us past the next thread switch time, we switch immediately
in order to burn as much as possible delay time in the main RetroArch thread as soon as possible. */
- if (msecs - elapsed_time >= ((LibretroTimerManager *)_timerManager)->timeToNextSwitch() && !LIBRETRO_GRAPHICS_MANAGER->isOverlayInGUI())
+ if (msecs - elapsed_time >= ((LibretroTimerManager *)_timerManager)->timeToNextSwitch() && !isOverlayInGUI())
((LibretroTimerManager *)_timerManager)->checkThread(THREAD_SWITCH_DELAY);
else
usleep(1000);
@@ -63,7 +63,7 @@ void OSystem_libretro::delayMillis(uint msecs) {
while (elapsed_time < msecs) {
/* if remaining delay is lower than last amount of time spent on main thread, burn it in emu thread
to avoid exceeding requested delay */
- if (msecs - elapsed_time >= ((LibretroTimerManager *)_timerManager)->spentOnMainThread() && !((LibretroTimerManager *)_timerManager)->timeToNextSwitch() && !LIBRETRO_GRAPHICS_MANAGER->isOverlayInGUI())
+ if (msecs - elapsed_time >= ((LibretroTimerManager *)_timerManager)->spentOnMainThread() && !((LibretroTimerManager *)_timerManager)->timeToNextSwitch() && !isOverlayInGUI())
((LibretroTimerManager *)_timerManager)->checkThread(THREAD_SWITCH_DELAY);
else
usleep(1000);
@@ -85,3 +85,10 @@ void OSystem_libretro::requestQuit() {
void OSystem_libretro::resetQuit() {
LIBRETRO_G_SYSTEM->getEventManager()->resetQuit();
}
+
+void OSystem_libretro::setMousePosition(int x, int y) {
+#ifdef USE_OPENGL
+ if (retro_get_video_hw_mode() & VIDEO_GRAPHIC_MODE_REQUEST_HW)
+ dynamic_cast<LibretroOpenGLGraphics *>(_graphicsManager)->setMousePosition(x, y);
+#endif
+}
diff --git a/backends/platform/libretro/src/libretro-os-inputs.cpp b/backends/platform/libretro/src/libretro-os-inputs.cpp
index ff6441e5f67..412bbca8e70 100644
--- a/backends/platform/libretro/src/libretro-os-inputs.cpp
+++ b/backends/platform/libretro/src/libretro-os-inputs.cpp
@@ -26,7 +26,7 @@
void OSystem_libretro::updateMouseXY(float deltaAcc, float *cumulativeXYAcc, int doing_x) {
int *mouseXY;
- const int16 *screen_wh;
+ int16 screen_wh;
int *relMouseXY;
int cumulativeXYAcc_int;
@@ -39,12 +39,12 @@ void OSystem_libretro::updateMouseXY(float deltaAcc, float *cumulativeXYAcc, int
if (doing_x) {
_cursorStatus |= CURSOR_STATUS_DOING_X;
mouseXY = &_mouseX;
- screen_wh = &(LIBRETRO_GRAPHICS_MANAGER->getScreen().w);
+ screen_wh = getScreenWidth();
relMouseXY = &_relMouseX;
} else {
_cursorStatus |= CURSOR_STATUS_DOING_Y;
mouseXY = &_mouseY;
- screen_wh = &(LIBRETRO_GRAPHICS_MANAGER->getScreen().h);
+ screen_wh = getScreenHeight();
relMouseXY = &_relMouseY;
}
*cumulativeXYAcc += deltaAcc;
@@ -53,7 +53,7 @@ void OSystem_libretro::updateMouseXY(float deltaAcc, float *cumulativeXYAcc, int
// Set mouse position
*mouseXY += cumulativeXYAcc_int;
*mouseXY = (*mouseXY < 0) ? 0 : *mouseXY;
- *mouseXY = (*mouseXY >= *screen_wh) ? *screen_wh : *mouseXY;
+ *mouseXY = (*mouseXY >= screen_wh) ? screen_wh : *mouseXY;
// Update accumulator
*cumulativeXYAcc -= (float)cumulativeXYAcc_int;
}
@@ -156,6 +156,7 @@ void OSystem_libretro::processInputs(void) {
ev.relMouse.x = _cursorStatus & CURSOR_STATUS_DOING_X ? _relMouseX : 0;
ev.relMouse.y = _cursorStatus & CURSOR_STATUS_DOING_Y ? _relMouseY : 0;
_events.push_back(ev);
+ setMousePosition(_mouseX,_mouseY);
}
// Handle special functions
@@ -214,8 +215,8 @@ void OSystem_libretro::processInputs(void) {
int p_x = retro_input_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X);
int p_y = retro_input_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y);
int p_press = retro_input_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED);
- int px = (int)((p_x + 0x7fff) * LIBRETRO_GRAPHICS_MANAGER->getScreen().w / 0xffff);
- int py = (int)((p_y + 0x7fff) * LIBRETRO_GRAPHICS_MANAGER->getScreen().h / 0xffff);
+ int px = (int)((p_x + 0x7fff) * getScreenWidth() / 0xffff);
+ int py = (int)((p_y + 0x7fff) * getScreenHeight() / 0xffff);
// printf("(%d,%d) p:%d\n",px,py,pp);
static int ptrhold = 0;
@@ -234,6 +235,7 @@ void OSystem_libretro::processInputs(void) {
ev.mouse.x = _mouseX;
ev.mouse.y = _mouseY;
_events.push_back(ev);
+ setMousePosition(_mouseX,_mouseY);
}
if (ptrhold > 10 && _ptrmouseButton == 0) {
@@ -295,6 +297,7 @@ void OSystem_libretro::processInputs(void) {
ev.relMouse.x = _cursorStatus & CURSOR_STATUS_DOING_X ? _relMouseX : 0;
ev.relMouse.y = _cursorStatus & CURSOR_STATUS_DOING_Y ? _relMouseY : 0;
_events.push_back(ev);
+ setMousePosition(_mouseX,_mouseY);
}
for (int i = 0; i < 2; i++) {
@@ -302,7 +305,6 @@ void OSystem_libretro::processInputs(void) {
bool down = retro_input_cb(0, RETRO_DEVICE_MOUSE, 0, retroButtons[i]);
if (down != _mouseButtons[i]) {
_mouseButtons[i] = down;
-
ev.type = eventID[i][down ? 0 : 1];
ev.mouse.x = _mouseX;
ev.mouse.y = _mouseY;
More information about the Scummvm-git-logs
mailing list