Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BACK/EXIT key support in webOS #1

Merged
merged 2 commits into from
Apr 29, 2021
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
41 changes: 40 additions & 1 deletion input/drivers/sdl_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
#include "../../gfx/common/sdl2_common.h"
#endif

#ifdef WEBOS
#include <SDL_webOS.h>
#endif

/* TODO/FIXME -
* fix game focus toggle */

Expand All @@ -55,6 +59,15 @@ typedef struct sdl_input
int mouse_wr;
} sdl_input_t;

#ifdef WEBOS
enum sdl_webos_special_key {
sdl_webos_spkey_back,
sdl_webos_spkey_size,
};

static uint8_t sdl_webos_special_keymap[sdl_webos_spkey_size] = {0};
#endif

static void *sdl_input_init(const char *joypad_driver)
{
sdl_input_t *sdl = (sdl_input_t*)calloc(1, sizeof(*sdl));
Expand All @@ -77,6 +90,17 @@ static bool sdl_key_pressed(int key)
unsigned sym = rarch_keysym_lut[(enum retro_key)key];
#endif

#ifdef WEBOS
if (key == RETROK_BACKSPACE && sdl_webos_special_keymap[sdl_webos_spkey_back])
{
// Reset to unpressed state
sdl_webos_special_keymap[sdl_webos_spkey_back] = 0;
return true;
}
if (key == RETROK_ESCAPE && keymap[SDL_WEBOS_SCANCODE_EXIT])
return true;
#endif

if (sym >= (unsigned)num_keys)
return false;

Expand Down Expand Up @@ -352,7 +376,22 @@ static void sdl_input_poll(void *data)
{
uint16_t mod = 0;
unsigned code = input_keymaps_translate_keysym_to_rk(
event.key.keysym.sym);
event.key.keysym.sym);
#ifdef WEBOS
switch ((int) event.key.keysym.scancode)
{
case SDL_WEBOS_SCANCODE_BACK:
// Because webOS is sending DOWN/UP at the same time, we save this flag for later
sdl_webos_special_keymap[sdl_webos_spkey_back] |= event.type == SDL_KEYDOWN;
code = RETROK_BACKSPACE;
break;
case SDL_WEBOS_SCANCODE_EXIT:
code = RETROK_ESCAPE;
break;
default:
break;
}
#endif

if (event.key.keysym.mod & KMOD_SHIFT)
mod |= RETROKMOD_SHIFT;
Expand Down
3 changes: 3 additions & 0 deletions webos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
prefix/
*.ipk
32 changes: 32 additions & 0 deletions webos/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
all: package

RETROARCH_PREFIX = ${PWD}/prefix

configure:
cd ../; \
./configure --build=x86_64-linux-gnu --host=arm-webos-linux-gnueabi --prefix=$(RETROARCH_PREFIX) --enable-opengles \
--enable-egl --disable-udev --disable-videocore --disable-ffmpeg --disable-kms --enable-neon --enable-sdl2 ;\

retroarch:
cd ../; \
make HAVE_WEBOS=1 -j$(nproc) install

package: retroarch
rm -rf dist *.ipk; \
mkdir -p dist/lib; \
cp -vf -t dist/lib /opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi/usr/lib/libstdc++.so.6; \
cp -vf -t dist/ appinfo.json icon160.png prefix/bin/retroarch; \
arm-webos-linux-gnueabi-strip dist/retroarch; \
ares-package dist

install: package
ares-install com.retroarch_*.ipk

launch: install
ares-launch com.retroarch

clean:
rm -rf dist; \
rm -rf prefix; \
cd ..; \
make clean
2 changes: 1 addition & 1 deletion webos/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```sh
./configure --build=x86_64-linux-gnu --host=arm-webos-linux-gnueabi --enable-opengles --enable-egl --disable-udev --disable-videocore --disable-ffmpeg --enable-neon --enable-sdl2
./configure --build=x86_64-linux-gnu --host=arm-webos-linux-gnueabi --enable-opengles --enable-egl --disable-udev --disable-videocore --disable-ffmpeg --disable-kms --enable-neon --enable-sdl2
make HAVE_WEBOS=1 -j5
webos/package.sh

Expand Down