Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,14 @@ gfx/common/wayland/single-pixel-buffer-v1.h
gfx/common/wayland/single-pixel-buffer-v1.c
gfx/common/wayland/xdg-toplevel-icon-v1.h
gfx/common/wayland/xdg-toplevel-icon-v1.c
gfx/common/wayland/webos-foreign.c
gfx/common/wayland/webos-foreign.h
gfx/common/wayland/webos-input-manager.c
gfx/common/wayland/webos-input-manager.h
gfx/common/wayland/webos-shell.c
gfx/common/wayland/webos-shell.h
gfx/common/wayland/webos-surface-group.c
gfx/common/wayland/webos-surface-group.h

# libretro-common samples
libretro-common/samples/streams/rzip/rzip
Expand Down
8 changes: 8 additions & 0 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,14 @@ ifeq ($(HAVE_WAYLAND), 1)
OBJ += gfx/drivers_context/wayland_vk_ctx.o
endif

ifeq ($(WEBOS), 1)
OBJ += input/common/wayland_common_webos.o
OBJ += gfx/common/wayland/webos-foreign.o
OBJ += gfx/common/wayland/webos-input-manager.o
OBJ += gfx/common/wayland/webos-shell.o
OBJ += gfx/common/wayland/webos-surface-group.o
endif

DEF_FLAGS += $(WAYLAND_CFLAGS) $(WAYLAND_CURSOR_CFLAGS)
LIBS += $(WAYLAND_LIBS) $(WAYLAND_CURSOR_LIBS)

Expand Down
43 changes: 34 additions & 9 deletions Makefile.webos
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ SDL2_PREBUILT_ARCHIVE ?= https://github.com/webosbrew/SDL-webOS/releases/downloa
APP_PACKAGE_NAME ?= com.retroarch.webos
IPK_VERSION := $(shell grep '#define PACKAGE_VERSION' version.all | sed -E 's/.*"([0-9]+\.[0-9]+\.[0-9]+)".*/\1/')

WEBOS = 1
DEBUG ?= 0

HAVE_CLOUDSYNC = 1
Expand Down Expand Up @@ -60,7 +61,7 @@ HAVE_CXX = 1
HAVE_DR_MP3 = 1
HAVE_DYNAMIC = 1
HAVE_DYLIB = 1
HAVE_EGL = 0
HAVE_EGL ?= 0
HAVE_FREETYPE = 1
HAVE_GDI = 0
HAVE_GETADDRINFO = 1
Expand All @@ -76,6 +77,7 @@ HAVE_GLSLANG_SPIRV_TOOLS_OPT = 0
HAVE_HID = 1
HAVE_IBXM = 1
HAVE_IMAGEVIEWER = 1
HAVE_XKBCOMMON ?= 0
HAVE_LANGEXTRA = 1
HAVE_LIBRETRODB = 1
HAVE_MENU = 1
Expand All @@ -94,9 +96,9 @@ HAVE_OPENGL = 0
HAVE_OPENGL1 = 0
HAVE_OPENGL_CORE = 0
HAVE_OPENGLES = 1
HAVE_OPENGLES3 = 0
HAVE_OPENGLES3_1 = 0
HAVE_OPENGLES3_2 = 0
HAVE_OPENGLES3 ?= 0
HAVE_OPENGLES3_1 ?= 0
HAVE_OPENGLES3_2 ?= 0
HAVE_OPENSSL = 0
HAVE_OVERLAY = 1
HAVE_PULSE = 1
Expand Down Expand Up @@ -129,7 +131,9 @@ HAVE_LIBSHAKE = 1
HAVE_UPDATE_ASSETS = 1
HAVE_UPDATE_CORES = 1
HAVE_UPDATE_CORE_INFO = 1
HAVE_USERLAND ?= 0
HAVE_CORE_INFO_CACHE = 1
HAVE_WAYLAND ?= 0

OS = Linux
TARGET = retroarch
Expand All @@ -147,6 +151,7 @@ else
HAVE_NEON = 1
endif
CFLAGS := $(ARCHFLAGS)
CFLAGS += -DWEBOS_APP_ID=\"$(APP_PACKAGE_NAME)\"
CXXFLAGS := $(ARCHFLAGS) -fno-exceptions -fno-rtti -std=c++11 -D__STDC_CONSTANT_MACROS
ASFLAGS := $(ARCHFLAGS)
LDFLAGS := -Wl,-rpath=\$$ORIGIN/lib,--gc-sections
Expand All @@ -162,21 +167,35 @@ DEFINES += -DHAVE_NETWORKING -DHAVE_IFINFO -DHAVE_ONLINE_UPDATER -DHAVE_UPDATE_A
DEFINES += -DHAVE_NETWORKGAMEPAD
DEFINES += -DHAVE_FREETYPE
DEFINES += -DHAVE_UPDATE_CORE_INFO
EGL_LIBS = -lEGL
OPENGLES_LIBS = -lGLESv2
XKBCOMMON_LIBS = -lxkbcommon
WAYLAND_PROTO_SCRIPT := ./gfx/common/wayland/generate_wayland_protos.sh
ifeq ($(HAVE_XKBCOMMON), 1)
DEFINES += -DHAVE_XKBCOMMON=1
endif
ifneq (,$(filter 1,$(HAVE_OPENGLES3) $(HAVE_OPENGLES3_1) $(HAVE_OPENGLES3_2)))
DEFINES += -DHAVE_OPENGLES3
endif
ifeq ($(HAVE_OPENGLES3_1),1)
DEFINES += -DHAVE_OPENGLES3_1
DEFINES += -DHAVE_OPENGLES3_1
endif
ifeq ($(HAVE_OPENGLES3_2),1)
DEFINES += -DHAVE_OPENGLES3_2
DEFINES += -DHAVE_OPENGLES3_2
endif
ifeq ($(HAVE_WAYLAND),1)
DEFINES += -DHAVE_WAYLAND=1
WAYLAND_LIBS = -lwayland-client -lwayland-cursor -lwayland-egl
endif
ifeq ($(HAVE_USERLAND),1)
DEFINES += -DHAVE_USERLAND
WAYLAND_LIBS += -lhelpers
endif

PKG_CONFIG=pkg-config

SDL2_CFLAGS := $(shell $(PKG_CONFIG) --cflags sdl2)
SDL2_LIBS := $(shell $(PKG_CONFIG) --libs sdl2)
OPENGLES_LIBS = -lGLESv2
PULSE_LIBS = $(shell $(PKG_CONFIG) --libs libpulse)
FREETYPE_CFLAGS := $(shell $(PKG_CONFIG) --cflags freetype2)
FREETYPE_LIBS := $(shell $(PKG_CONFIG) --libs freetype2)
Expand Down Expand Up @@ -260,6 +279,12 @@ endif

SYMBOL_MAP := -Wl,-Map=output.map

prebuild:
ifeq ($(HAVE_WAYLAND),1)
@echo "Generating Wayland protocols..."
@$(SHELL) $(WAYLAND_PROTO_SCRIPT)
endif

$(TARGET): $(RARCH_OBJ)
@$(if $(Q), $(shell echo echo LD $@),)
$(Q)$(LINK) -o $@ $(RARCH_OBJ) $(LIBS) $(LDFLAGS) $(LIBRARY_DIRS)
Expand Down Expand Up @@ -300,7 +325,7 @@ ifeq ($(ADD_SDL2_LIB), 1)
wget -qO - $(SDL2_PREBUILT_ARCHIVE) | tar -C SDL -zxvf -
endif

ipk: $(TARGET) sdl2
ipk: prebuild $(TARGET) sdl2
rm -rf webos/dist
mkdir -p webos/dist/lib
echo "$$APPINFO" > webos/dist/appinfo.json
Expand All @@ -321,7 +346,7 @@ install: ipk
launch: install
ares-launch $(APP_PACKAGE_NAME)

.PHONY: all clean ipk
.PHONY: all clean prebuild ipk

print-%:
@echo '$*=$($*)'
22 changes: 21 additions & 1 deletion gfx/common/wayland/generate_wayland_protos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,22 @@ while [ $# -gt 0 ]; do
done

WAYSCAN="$(exists wayland-scanner || :)"

if [ -n "${CROSS_COMPILE:-}" ] && echo "${CROSS_COMPILE:-}" | grep -q "webos"; then
if [ -z "${SDK_PATH:-}" ]; then
die 1 "Error: WEBOS=1 but SDK_PATH not set"
fi
WAYSCAN="$SDK_PATH/bin/wayland-scanner"
fi

PKGCONFIG="$(exists pkg-config || :)"

[ "${WAYSCAN}" ] || die 1 "Error: No wayscan in ($PATH)"

WAYLAND_PROTOS=''

if [ "$PROTOS" != 'no' -a "$PKGCONFIG" ]; then
WAYLAND_PROTOS="$($PKGCONFIG wayland-protocols --variable=pkgdatadir)"
WAYLAND_PROTOS="$($PKGCONFIG wayland-protocols --variable=pkgdatadir 2>/dev/null || true)"
fi

if [ -z "${WAYLAND_PROTOS}" ]; then
Expand Down Expand Up @@ -74,3 +82,15 @@ generate_source 'unstable/tablet' 'tablet-unstable-v2'
generate_source 'staging/content-type' 'content-type-v1'
generate_source 'staging/single-pixel-buffer' 'single-pixel-buffer-v1'
generate_source 'staging/xdg-toplevel-icon' 'xdg-toplevel-icon-v1'

if [ -n "${CROSS_COMPILE:-}" ] && echo "${CROSS_COMPILE:-}" | grep -q "webos"; then
if [ -z "${SDK_PATH:-}" ]; then
die 1 "Error: WEBOS=1 but SDK_PATH not set"
fi
WAYLAND_PROTOS="$SDK_PATH/arm-webos-linux-gnueabi/sysroot/usr/share"

generate_source 'wayland-webos' 'webos-shell'
generate_source 'wayland-webos' 'webos-foreign'
generate_source 'wayland-webos' 'webos-surface-group'
generate_source 'wayland-webos' 'webos-input-manager'
fi
20 changes: 20 additions & 0 deletions gfx/drivers_context/wayland_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@
#define EGL_PLATFORM_WAYLAND_KHR 0x31D8
#endif

#ifdef WEBOS
extern void gfx_ctx_wl_get_video_size_webos(void*, unsigned*, unsigned*);
extern void gfx_ctx_wl_destroy_resources_webos(gfx_ctx_wayland_data_t*);
extern void gfx_ctx_wl_update_title_webos(void*);
extern bool gfx_ctx_wl_init_webos(const toplevel_listener_t*, gfx_ctx_wayland_data_t**);
extern bool gfx_ctx_wl_set_video_mode_common_size_webos(gfx_ctx_wayland_data_t*, unsigned, unsigned, bool);
extern bool gfx_ctx_wl_set_video_mode_common_fullscreen_webos(gfx_ctx_wayland_data_t*, bool);
extern bool gfx_ctx_wl_suppress_screensaver_webos(void*, bool);
extern void gfx_ctx_wl_check_window_webos(gfx_ctx_wayland_data_t*, void (*)(void*, unsigned*, unsigned*), bool*, bool*, unsigned*, unsigned*);

#define gfx_ctx_wl_get_video_size_common gfx_ctx_wl_get_video_size_webos
#define gfx_ctx_wl_destroy_resources_common gfx_ctx_wl_destroy_resources_webos
#define gfx_ctx_wl_update_title_common gfx_ctx_wl_update_title_webos
#define gfx_ctx_wl_init_common gfx_ctx_wl_init_webos
#define gfx_ctx_wl_set_video_mode_common_size gfx_ctx_wl_set_video_mode_common_size_webos
#define gfx_ctx_wl_set_video_mode_common_fullscreen gfx_ctx_wl_set_video_mode_common_fullscreen_webos
#define gfx_ctx_wl_suppress_screensaver gfx_ctx_wl_suppress_screensaver_webos
#define gfx_ctx_wl_check_window_common gfx_ctx_wl_check_window_webos
#endif

static enum gfx_ctx_api wl_api = GFX_CTX_NONE;

/* Shell surface callbacks. */
Expand Down
4 changes: 4 additions & 0 deletions input/common/wayland_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,11 @@ const struct wl_keyboard_listener keyboard_listener = {
wl_keyboard_handle_keymap,
wl_keyboard_handle_enter,
wl_keyboard_handle_leave,
#ifdef WEBOS
wl_keyboard_handle_key_webos,
#else
wl_keyboard_handle_key,
#endif
wl_keyboard_handle_modifiers,
wl_keyboard_handle_repeat_info
};
Expand Down
25 changes: 24 additions & 1 deletion input/common/wayland_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
#include "../../gfx/common/wayland/xdg-shell.h"
#include "../../gfx/common/wayland/xdg-toplevel-icon-v1.h"

#ifdef WEBOS
#include "wayland_common_webos.h"
#endif

#define FRACTIONAL_SCALE_V1_DEN 120
#define FRACTIONAL_SCALE_MULT(v, scale_num) \
(((v) * (scale_num) + FRACTIONAL_SCALE_V1_DEN / 2) / FRACTIONAL_SCALE_V1_DEN)
Expand Down Expand Up @@ -171,6 +175,15 @@ typedef struct gfx_ctx_wayland_data
struct wl_shm *shm;
struct wl_data_device_manager *data_device_manager;
struct wl_data_device *data_device;
#ifdef WEBOS
struct wl_shell *shell;
struct wl_shell_surface *shell_surface;
struct wl_webos_shell *webos_shell;
struct wl_webos_shell_surface *webos_shell_surface;
struct wl_webos_foreign *webos_foreign;
struct wl_webos_surface_group_compositor *webos_surface_group_compositor;
struct wl_webos_input_manager *webos_input_manager;
#endif
data_offer_ctx *current_drag_offer;
#ifdef HAVE_LIBDECOR_H
struct libdecor *libdecor_context;
Expand Down Expand Up @@ -201,6 +214,9 @@ typedef struct gfx_ctx_wayland_data
struct wl_list all_outputs;
struct wl_list current_outputs;

#ifdef WEBOS
struct wl_list all_seats;
#endif
struct
{
struct wl_cursor *default_cursor;
Expand All @@ -225,7 +241,9 @@ typedef struct gfx_ctx_wayland_data
unsigned last_fractional_scale_num;
unsigned pending_fractional_scale_num;
unsigned fractional_scale_num;

#ifdef WEBOS
uint32_t webos_surface_state;
#endif
bool core_hw_context_enable;
bool fullscreen;
bool maximized;
Expand Down Expand Up @@ -280,4 +298,9 @@ extern const struct wl_data_device_listener data_device_listener;

extern const struct wl_data_offer_listener data_offer_listener;

#ifdef WEBOS
extern void wl_keyboard_handle_key_webos(void *data, struct wl_keyboard *keyboard, uint32_t serial,
uint32_t time, uint32_t key, uint32_t state);
#endif

#endif
Loading
Loading