Skip to content

Commit

Permalink
SWITCH: Fix touch input for latest SDL2
Browse files Browse the repository at this point in the history
  • Loading branch information
rsn8887 committed Feb 15, 2024
1 parent b102e0c commit 945363f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
set(CMAKE_VERBOSE_MAKEFILE OFF)

set(VERSION_MAJOR 2)
set(VERSION_MINOR 10)
set(VERSION_MINOR 11)

if(BUILD_PSP2)
if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
Expand Down
14 changes: 11 additions & 3 deletions README.MD
Expand Up @@ -4,6 +4,10 @@ On the Switch, since v1.84, please use Application mode, not Applet mode, to sta

Recent Changes
======
2.11 (Switch only)

- fix touch input on Switch

2.10

- allow autostarting of config file via command line argument. On Switch, the same forwarder that works with RetroArch can be used. On Vita, a custom bubble builder is provided. It uses the same method as DaedalusX.
Expand Down Expand Up @@ -163,13 +167,13 @@ Pressing stick while moving it = change keyboard transparency/position, control
SR + SL + Stick directions = hotkey to quick-zoom image and center image vertically (player 1 only)

Physical Keyboard / Mouse controls
======
-----
On Vita (Bluetooth): Mouse + keyboard tested working with the "Jelly Comb Mini Bluetooth Keyboard With Mouse Touchpad, ASIN:B06Y56BBYP," and with the "Jelly Comb Bluetooth Wireless Mouse ASIN:B075HBDWCF." The Amiga keys are mapped to Windows (GUI) keys as well as Page Up/Down. The Vita doesn't pair with all Bluetooth keyboards and mice. As a rule, if the keyboard works to highlight bubbles with cursor keys, it should also work in UAE4All.

On Switch (USB): All keyboards seem to work. Not all mice seem to work. [Mouse compatibility sheet](https://docs.google.com/spreadsheets/d/1Drbo5-QuSX901MwtOytSMuqRGxeIkq2HELM806I9dj0/edit#gid=0)

Custom Bubble / Forwarder
------
======
To autostart a game config via a custom bubble (Vita) or forwarder (Switch), I used the following steps with the example game Superfrog:

Switch:
Expand All @@ -187,7 +191,7 @@ Vita:
- I inserted Superfrog disk 1
- I saved a config with name "superfrog" using the Config - Save As option in UAE4All2
- I checked that the config was saved to my SD card with the full name ux0:/data/uae4all/conf/superfrog.conf
- I then used the provided build.bat file on Windows with the following options
- I then used the provided build.bat file on Windows (unzip the provided file builder.zip) with the following options
- Bubble Name: Superfrog
- Conf Name: ux0:/data/uae4all/conf/superfrog.conf
- TitleID: SUPERFROG
Expand Down Expand Up @@ -342,6 +346,10 @@ Compiling

CHANGELOG
=====
2.11 (Switch only)

- fix touch input on Switch

2.10

- allow autostarting of config file via command line argument. On Switch, the same forwarder that works with RetroArch can be used. On Vita, a custom bubble builder is provided. It uses the same method as DaedalusX.
Expand Down
16 changes: 8 additions & 8 deletions src/switch/switch_touch.c
Expand Up @@ -8,7 +8,7 @@
#endif

#if defined(__SWITCH__)
#define SCE_TOUCH_PORT_MAX_NUM 1
#define SCE_TOUCH_PORT_MAX_NUM 2
#define displayWidth 1280.0
#define displayHeight 720.0
#endif
Expand Down Expand Up @@ -96,10 +96,10 @@ static void preprocessEvents(SDL_Event *event) {
// left button drag and drop: dual finger drag
// right button drag and drop: triple finger drag
if (event->type == SDL_FINGERDOWN || event->type == SDL_FINGERUP || event->type == SDL_FINGERMOTION) {
// front (0) or back (1) panel
// front port id is 1 on Switch
SDL_TouchID port = event->tfinger.touchId;
if (port < SCE_TOUCH_PORT_MAX_NUM && port >= 0) {
if (port == 0 || psp2RearTouch) {
if (port == 1) {
switch (event->type) {
case SDL_FINGERDOWN:
preprocessFingerDown(event);
Expand All @@ -117,13 +117,13 @@ static void preprocessEvents(SDL_Event *event) {
}

static void preprocessFingerDown(SDL_Event *event) {
// front (0) or back (1) panel
// front port id is 1 on Switch
SDL_TouchID port = event->tfinger.touchId;
// id (for multitouch)
SDL_FingerID id = event->tfinger.fingerId;

if (vkbd_mode) {
if (port == 0) {
if (port == 1) {
vkbd_touch_x = event->tfinger.x;
vkbd_touch_y = event->tfinger.y;
}
Expand Down Expand Up @@ -157,13 +157,13 @@ static void preprocessFingerDown(SDL_Event *event) {
}

static void preprocessFingerUp(SDL_Event *event) {
// front (0) or back (1) panel
//front port id is 1 on Switch
SDL_TouchID port = event->tfinger.touchId;
// id (for multitouch)
SDL_FingerID id = event->tfinger.fingerId;

if (vkbd_mode) {
if (port == 0) {
if (port == 1) {
vkbd_touch_x = -1;
vkbd_touch_y = -1;
vkbd_move &= ~VKBD_BUTTON;
Expand Down Expand Up @@ -236,7 +236,7 @@ static void preprocessFingerMotion(SDL_Event *event) {
if (vkbd_mode)
return;

// front (0) or back (1) panel
// front port id is 1 on Switch
SDL_TouchID port = event->tfinger.touchId;
// id (for multitouch)
SDL_FingerID id = event->tfinger.fingerId;
Expand Down

0 comments on commit 945363f

Please sign in to comment.