switch: open 4 controllers. android: java7 compatibility

This commit is contained in:
Flyinghead 2021-10-06 18:55:04 +02:00
parent 1072235b1a
commit bc238de5ce
2 changed files with 6 additions and 6 deletions

View File

@ -12,7 +12,7 @@
#include "wsi/context.h" #include "wsi/context.h"
#include "emulator.h" #include "emulator.h"
#include "stdclass.h" #include "stdclass.h"
#if !defined(_WIN32) && !defined(__APPLE__) #if !defined(_WIN32) && !defined(__APPLE__) && !defined(__SWITCH__)
#include "linux-dist/icon.h" #include "linux-dist/icon.h"
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
@ -185,12 +185,11 @@ void input_sdl_init()
#endif #endif
#ifdef __SWITCH__ #ifdef __SWITCH__
// open CONTROLLER_PLAYER_1 and CONTROLLER_PLAYER_2
// when railed, both joycons are mapped to joystick #0, // when railed, both joycons are mapped to joystick #0,
// else joycons are individually mapped to joystick #0, joystick #1, ... // 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 // https://github.com/devkitPro/SDL/blob/switch-sdl2/src/joystick/switch/SDL_sysjoystick.c#L45
sdl_open_joystick(0); for (int joy = 0; joy < 4; joy++)
sdl_open_joystick(1); sdl_open_joystick(joy);
#endif #endif
} }
@ -414,7 +413,7 @@ void sdl_window_set_text(const char* text)
static float hdpiScaling = 1.f; static float hdpiScaling = 1.f;
static void get_window_state() static inline void get_window_state()
{ {
u32 flags = SDL_GetWindowFlags(window); u32 flags = SDL_GetWindowFlags(window);
window_fullscreen = flags & SDL_WINDOW_FULLSCREEN_DESKTOP; window_fullscreen = flags & SDL_WINDOW_FULLSCREEN_DESKTOP;

View File

@ -9,6 +9,7 @@ import com.reicast.emulator.Emulator;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.ArrayUtils;
public final class InputDeviceManager implements InputManager.InputDeviceListener { public final class InputDeviceManager implements InputManager.InputDeviceListener {
public static final int VIRTUAL_GAMEPAD_ID = 0x12345678; public static final int VIRTUAL_GAMEPAD_ID = 0x12345678;
@ -62,7 +63,7 @@ public final class InputDeviceManager implements InputManager.InputDeviceListene
fullAxes.add(range.getAxis()); fullAxes.add(range.getAxis());
} }
joystickAdded(i, device.getName(), port, device.getDescriptor(), 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])));
} }
} }