From bc238de5cec734db5ac7f2236946d2cd41a3d1e2 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Wed, 6 Oct 2021 18:55:04 +0200 Subject: [PATCH] switch: open 4 controllers. android: java7 compatibility --- core/sdl/sdl.cpp | 9 ++++----- .../com/reicast/emulator/periph/InputDeviceManager.java | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/sdl/sdl.cpp b/core/sdl/sdl.cpp index 85791db22..f9441a219 100644 --- a/core/sdl/sdl.cpp +++ b/core/sdl/sdl.cpp @@ -12,7 +12,7 @@ #include "wsi/context.h" #include "emulator.h" #include "stdclass.h" -#if !defined(_WIN32) && !defined(__APPLE__) +#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__SWITCH__) #include "linux-dist/icon.h" #endif #ifdef _WIN32 @@ -185,12 +185,11 @@ void input_sdl_init() #endif #ifdef __SWITCH__ - // open CONTROLLER_PLAYER_1 and CONTROLLER_PLAYER_2 // when railed, both joycons are mapped to joystick #0, // else joycons are individually mapped to joystick #0, joystick #1, ... // https://github.com/devkitPro/SDL/blob/switch-sdl2/src/joystick/switch/SDL_sysjoystick.c#L45 - sdl_open_joystick(0); - sdl_open_joystick(1); + for (int joy = 0; joy < 4; joy++) + sdl_open_joystick(joy); #endif } @@ -414,7 +413,7 @@ void sdl_window_set_text(const char* text) static float hdpiScaling = 1.f; -static void get_window_state() +static inline void get_window_state() { u32 flags = SDL_GetWindowFlags(window); window_fullscreen = flags & SDL_WINDOW_FULLSCREEN_DESKTOP; diff --git a/shell/android-studio/flycast/src/main/java/com/reicast/emulator/periph/InputDeviceManager.java b/shell/android-studio/flycast/src/main/java/com/reicast/emulator/periph/InputDeviceManager.java index e06a436b4..abbfd6a99 100644 --- a/shell/android-studio/flycast/src/main/java/com/reicast/emulator/periph/InputDeviceManager.java +++ b/shell/android-studio/flycast/src/main/java/com/reicast/emulator/periph/InputDeviceManager.java @@ -9,6 +9,7 @@ import com.reicast.emulator.Emulator; import java.util.ArrayList; import java.util.List; +import org.apache.commons.lang3.ArrayUtils; public final class InputDeviceManager implements InputManager.InputDeviceListener { public static final int VIRTUAL_GAMEPAD_ID = 0x12345678; @@ -62,7 +63,7 @@ public final class InputDeviceManager implements InputManager.InputDeviceListene fullAxes.add(range.getAxis()); } joystickAdded(i, device.getName(), port, device.getDescriptor(), - fullAxes.stream().mapToInt(n->n).toArray(), halfAxes.stream().mapToInt(n->n).toArray()); + ArrayUtils.toPrimitive(fullAxes.toArray(new Integer[0])), ArrayUtils.toPrimitive(halfAxes.toArray(new Integer[0]))); } }