switch: update for release-2.0.12

This commit is contained in:
cpasjuste 2020-04-09 17:05:20 +02:00 committed by Dave Murphy
parent 971b372465
commit bf7515613e
5 changed files with 26 additions and 15 deletions

4
configure vendored
View File

@ -25671,9 +25671,9 @@ $as_echo "#define SDL_JOYSTICK_SWITCH 1" >>confdefs.h
# Set up files for the timer library
if test x$enable_timers = xyes; then
$as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
$as_echo "#define SDL_TIMER_SWITCH 1" >>confdefs.h
SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
SOURCES="$SOURCES $srcdir/src/timer/switch/*.c"
have_timers=yes
fi
# Set up files for the thread library

View File

@ -4267,8 +4267,8 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
fi
# Set up files for the timer library
if test x$enable_timers = xyes; then
AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
AC_DEFINE(SDL_TIMER_SWITCH, 1, [ ])
SOURCES="$SOURCES $srcdir/src/timer/switch/*.c"
have_timers=yes
fi
# Set up files for the thread library

View File

@ -138,7 +138,7 @@ SWITCH_JoystickOpen(SDL_Joystick *joystick, int device_index)
}
static int
SWITCH_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
SWITCH_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
{
// TODO
return SDL_Unsupported();
@ -215,7 +215,7 @@ SDL_JoystickDriver SDL_SWITCH_JoystickDriver =
SWITCH_JoystickDetect,
SWITCH_JoystickGetDeviceName,
SWITCH_JoystickGetDevicePlayerIndex,
//SWITCH_JoystickSetDevicePlayerIndex,
SWITCH_JoystickSetDevicePlayerIndex,
SWITCH_JoystickGetDeviceGUID,
SWITCH_JoystickGetDeviceInstanceID,
SWITCH_JoystickOpen,

View File

@ -25,8 +25,8 @@
#include <switch.h>
#include "SDL_events.h"
#include "SDL_switchtouch.h"
#include "../../events/SDL_touch_c.h"
#include "../../video/SDL_sysvideo.h"
#define MAX_TOUCH 16
@ -61,6 +61,11 @@ SWITCH_QuitTouch(void)
void
SWITCH_PollTouch(void)
{
SDL_Window *window = SDL_GetFocusWindow();
if (window == NULL) {
return;
}
memcpy(&touchState_old, &touchState, sizeof(touchState));
touchState.count = hidTouchCount();
@ -75,12 +80,12 @@ SWITCH_PollTouch(void)
hidTouchRead(&touchState.touch[i].position, i);
// Send an initial touch
SDL_SendTouch(0, (SDL_FingerID) i, SDL_TRUE,
SDL_SendTouch(0, (SDL_FingerID) i, window, SDL_TRUE,
(float) touchState.touch[i].position.px / 1280.0f,
(float) touchState.touch[i].position.py / 720.0f, 1);
// Always send the motion
SDL_SendTouchMotion(0, (SDL_FingerID) i,
SDL_SendTouchMotion(0, (SDL_FingerID) i, window,
(float) touchState.touch[i].position.px / 1280.0f,
(float) touchState.touch[i].position.py / 720.0f, 1);
}
@ -102,7 +107,7 @@ SWITCH_PollTouch(void)
if (finger_up == 1) {
// Finger released from screen
SDL_SendTouch((SDL_TouchID) 0, (SDL_FingerID) touchState_old.touch[i].id, SDL_FALSE,
SDL_SendTouch((SDL_TouchID) 0, (SDL_FingerID) touchState_old.touch[i].id, window, SDL_FALSE,
(float) touchState_old.touch[i].position.px / 1280.0f,
(float) touchState_old.touch[i].position.py / 720.0f, 1);
}

View File

@ -47,8 +47,10 @@ SWITCH_Available(void)
static void
SWITCH_Destroy(SDL_VideoDevice *device)
{
if (device) {
SDL_free(device->driverdata);
if (device != NULL) {
if(device->driverdata != NULL) {
SDL_free(device->driverdata);
}
SDL_free(device);
}
}
@ -110,7 +112,7 @@ SWITCH_CreateDevice(int devindex)
VideoBootStrap SWITCH_bootstrap = {
"Switch",
"OpenGL ES2 video driver for Nintendo Switch",
"SDL2 video driver for Nintendo Switch",
SWITCH_Available,
SWITCH_CreateDevice
};
@ -129,10 +131,12 @@ SWITCH_VideoInit(_THIS)
current_mode.h = 1080;
current_mode.refresh_rate = 60;
current_mode.format = SDL_PIXELFORMAT_RGBA8888;
current_mode.driverdata = NULL;
SDL_zero(display);
display.desktop_mode = current_mode;
display.current_mode = current_mode;
display.driverdata = NULL;
SDL_AddVideoDisplay(&display);
// init touch
@ -244,8 +248,10 @@ SWITCH_DestroyWindow(_THIS, SDL_Window *window)
if (data->egl_surface != EGL_NO_SURFACE) {
SDL_EGL_DestroySurface(_this, data->egl_surface);
}
SDL_free(window->driverdata);
window->driverdata = NULL;
if(window->driverdata != NULL) {
SDL_free(window->driverdata);
window->driverdata = NULL;
}
}
switch_window = NULL;
}