SDL3 update
Rename most functions to their SDL3 equivelants first Signed-off-by: Zach Bacon <zachbacon@vba-m.com>
This commit is contained in:
parent
68adb14b07
commit
bf30d0aa98
|
@ -15,7 +15,7 @@ if(TAG_RELEASE)
|
||||||
include(MakeReleaseCommitAndTag)
|
include(MakeReleaseCommitAndTag)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(VCPKG_DEPS pkgconf zlib pthreads "sdl2[samplerate]" gettext wxwidgets)
|
set(VCPKG_DEPS pkgconf zlib pthreads "sdl3[samplerate]" gettext wxwidgets)
|
||||||
|
|
||||||
set(VCPKG_DEPS_OPTIONAL
|
set(VCPKG_DEPS_OPTIONAL
|
||||||
sfml ENABLE_LINK
|
sfml ENABLE_LINK
|
||||||
|
@ -194,10 +194,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
find_package(SDL2 REQUIRED)
|
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3)
|
||||||
|
|
||||||
# Add libsamplerate to SDL2 with vcpkg
|
# Add libsamplerate to SDL2 with vcpkg
|
||||||
unset(SDL2_LIBRARY_TEMP)
|
#unset(SDL2_LIBRARY_TEMP)
|
||||||
if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
|
if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
unset(arch_suffix)
|
unset(arch_suffix)
|
||||||
|
@ -210,13 +210,13 @@ if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
|
||||||
endif()
|
endif()
|
||||||
set(installed_prefix ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows${arch_suffix}/${path_prefix})
|
set(installed_prefix ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows${arch_suffix}/${path_prefix})
|
||||||
|
|
||||||
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${installed_prefix}/lib/samplerate.lib)
|
#SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${installed_prefix}/lib/samplerate.lib)
|
||||||
else()
|
#else()
|
||||||
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} -lsamplerate)
|
#SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} -lsamplerate)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(VBAM_SDL2_LIBS SDL2::SDL2 ${SDL2_LIBRARY_TEMP})
|
set(VBAM_SDL3_LIBS SDL3::SDL3)
|
||||||
|
|
||||||
set(VBAM_GENERATED_DIR ${CMAKE_BINARY_DIR}/generated)
|
set(VBAM_GENERATED_DIR ${CMAKE_BINARY_DIR}/generated)
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@ target_sources(vbam-components-audio-sdl
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(vbam-components-audio-sdl
|
target_include_directories(vbam-components-audio-sdl
|
||||||
PUBLIC ${SDL2_INCLUDE_DIRS}
|
PUBLIC ${SDL3_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(vbam-components-audio-sdl
|
target_link_libraries(vbam-components-audio-sdl
|
||||||
PUBLIC vbam-core-base ${VBAM_SDL2_LIBS}
|
PUBLIC vbam-core-base ${VBAM_SDL3_LIBS}
|
||||||
)
|
)
|
||||||
|
|
|
@ -37,10 +37,6 @@ SoundSDL::SoundSDL():
|
||||||
initialized(false)
|
initialized(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void SoundSDL::soundCallback(void* data, uint8_t* stream, int len) {
|
|
||||||
reinterpret_cast<SoundSDL*>(data)->read(reinterpret_cast<uint16_t*>(stream), len);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SoundSDL::should_wait() {
|
bool SoundSDL::should_wait() {
|
||||||
return emulating && !coreOptions.speedup && current_rate && !gba_joybus_active;
|
return emulating && !coreOptions.speedup && current_rate && !gba_joybus_active;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +61,7 @@ void SoundSDL::read(uint16_t* stream, int length) {
|
||||||
|
|
||||||
if (!buffer_size()) {
|
if (!buffer_size()) {
|
||||||
if (should_wait())
|
if (should_wait())
|
||||||
SDL_SemWait(data_available);
|
SDL_WaitSemaphore(data_available);
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +72,7 @@ void SoundSDL::read(uint16_t* stream, int length) {
|
||||||
|
|
||||||
SDL_UnlockMutex(mutex);
|
SDL_UnlockMutex(mutex);
|
||||||
|
|
||||||
SDL_SemPost(data_read);
|
SDL_PostSemaphore(data_read);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundSDL::write(uint16_t * finalWave, int length) {
|
void SoundSDL::write(uint16_t * finalWave, int length) {
|
||||||
|
@ -85,8 +81,7 @@ void SoundSDL::write(uint16_t * finalWave, int length) {
|
||||||
|
|
||||||
SDL_LockMutex(mutex);
|
SDL_LockMutex(mutex);
|
||||||
|
|
||||||
if (SDL_GetAudioDeviceStatus(sound_device) != SDL_AUDIO_PLAYING)
|
SDL_PauseAudioDevice(sound_device);
|
||||||
SDL_PauseAudioDevice(sound_device, 0);
|
|
||||||
|
|
||||||
std::size_t samples = length / 4;
|
std::size_t samples = length / 4;
|
||||||
std::size_t avail;
|
std::size_t avail;
|
||||||
|
@ -99,10 +94,10 @@ void SoundSDL::write(uint16_t * finalWave, int length) {
|
||||||
|
|
||||||
SDL_UnlockMutex(mutex);
|
SDL_UnlockMutex(mutex);
|
||||||
|
|
||||||
SDL_SemPost(data_available);
|
SDL_PostSemaphore(data_available);
|
||||||
|
|
||||||
if (should_wait())
|
if (should_wait())
|
||||||
SDL_SemWait(data_read);
|
SDL_WaitSemaphore(data_read);
|
||||||
else
|
else
|
||||||
// Drop the remainder of the audio data
|
// Drop the remainder of the audio data
|
||||||
return;
|
return;
|
||||||
|
@ -124,21 +119,18 @@ bool SoundSDL::init(long sampleRate) {
|
||||||
|
|
||||||
// for "no throttle" use regular rate, audio is just dropped
|
// for "no throttle" use regular rate, audio is just dropped
|
||||||
audio.freq = current_rate ? static_cast<int>(sampleRate * (current_rate / 100.0)) : sampleRate;
|
audio.freq = current_rate ? static_cast<int>(sampleRate * (current_rate / 100.0)) : sampleRate;
|
||||||
|
audio.format = SDL_AUDIO_S16;
|
||||||
audio.format = AUDIO_S16SYS;
|
|
||||||
audio.channels = 2;
|
audio.channels = 2;
|
||||||
audio.samples = 2048;
|
|
||||||
audio.callback = soundCallback;
|
|
||||||
audio.userdata = this;
|
|
||||||
|
|
||||||
if (!SDL_WasInit(SDL_INIT_AUDIO)) SDL_Init(SDL_INIT_AUDIO);
|
if (!SDL_WasInit(SDL_INIT_AUDIO)) SDL_Init(SDL_INIT_AUDIO);
|
||||||
|
|
||||||
sound_device = SDL_OpenAudioDevice(NULL, 0, &audio, NULL, 0);
|
//This needs to be better flushed out especially where callback and userdata since that's done differently now
|
||||||
|
//SDL_OpenAudioDevice(deviceID (which can be SDL_AUDIO_DEVICE_DEFAULT_OUTPUT), AudioSpec, callback, userdata) So I need to flesh this out properly.
|
||||||
|
//sound_device needs to be an SDL_AudioStream, but this most probably not the best way to go just yet
|
||||||
|
|
||||||
if(sound_device == 0) {
|
SDL_AudioStream *sound_device = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_OUTPUT, &audio, NULL, NULL);
|
||||||
std::cerr << "Failed to open audio: " << SDL_GetError() << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
samples_buf.reset(static_cast<size_t>(std::ceil(buftime * sampleRate * 2)));
|
samples_buf.reset(static_cast<size_t>(std::ceil(buftime * sampleRate * 2)));
|
||||||
|
|
||||||
|
@ -147,10 +139,10 @@ bool SoundSDL::init(long sampleRate) {
|
||||||
data_read = SDL_CreateSemaphore(1);
|
data_read = SDL_CreateSemaphore(1);
|
||||||
|
|
||||||
// turn off audio events because we are not processing them
|
// turn off audio events because we are not processing them
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 4)
|
//#if SDL_VERSION_ATLEAST(2, 0, 4)
|
||||||
SDL_EventState(SDL_AUDIODEVICEADDED, SDL_IGNORE);
|
// SDL_EventState(SDL_EVENT_AUDIO_DEVICE_ADDED);
|
||||||
SDL_EventState(SDL_AUDIODEVICEREMOVED, SDL_IGNORE);
|
// SDL_EventState(SDL_EVENT_AUDIO_DEVICE_REMOVED);
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
return initialized = true;
|
return initialized = true;
|
||||||
}
|
}
|
||||||
|
@ -164,8 +156,8 @@ void SoundSDL::deinit() {
|
||||||
SDL_LockMutex(mutex);
|
SDL_LockMutex(mutex);
|
||||||
int is_emulating = emulating;
|
int is_emulating = emulating;
|
||||||
emulating = 0;
|
emulating = 0;
|
||||||
SDL_SemPost(data_available);
|
SDL_PostSemaphore(data_available);
|
||||||
SDL_SemPost(data_read);
|
SDL_PostSemaphore(data_read);
|
||||||
SDL_UnlockMutex(mutex);
|
SDL_UnlockMutex(mutex);
|
||||||
|
|
||||||
SDL_Delay(100);
|
SDL_Delay(100);
|
||||||
|
|
|
@ -47,9 +47,9 @@ private:
|
||||||
|
|
||||||
SDL_AudioDeviceID sound_device = 0;
|
SDL_AudioDeviceID sound_device = 0;
|
||||||
|
|
||||||
SDL_mutex* mutex;
|
SDL_Mutex* mutex;
|
||||||
SDL_sem* data_available;
|
SDL_Semaphore* data_available;
|
||||||
SDL_sem* data_read;
|
SDL_Semaphore* data_read;
|
||||||
SDL_AudioSpec audio_spec;
|
SDL_AudioSpec audio_spec;
|
||||||
|
|
||||||
unsigned short current_rate;
|
unsigned short current_rate;
|
||||||
|
|
|
@ -50,7 +50,7 @@ target_link_libraries(vbam
|
||||||
)
|
)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_link_libraries(vbam ${SDL2_LIBRARY} ${SDL2MAIN_LIBRARY})
|
target_link_libraries(vbam SDL3::SDL3)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_LIRC)
|
if(ENABLE_LIRC)
|
||||||
|
@ -59,7 +59,7 @@ if(ENABLE_LIRC)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_link_libraries(vbam wsock32 ws2_32 winmm version imm32 ${SDL2MAIN_LIBRARY})
|
target_link_libraries(vbam wsock32 ws2_32 winmm version imm32)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Installation scripts.
|
# Installation scripts.
|
||||||
|
|
|
@ -809,7 +809,7 @@ void sdlReadDesktopVideoMode()
|
||||||
{
|
{
|
||||||
if (window) {
|
if (window) {
|
||||||
SDL_DisplayMode dm;
|
SDL_DisplayMode dm;
|
||||||
SDL_GetDesktopDisplayMode(SDL_GetWindowDisplayIndex(window), &dm);
|
SDL_GetDesktopDisplayMode(SDL_GetDisplayForWindow(window), &dm);
|
||||||
desktopWidth = dm.w;
|
desktopWidth = dm.w;
|
||||||
desktopHeight = dm.h;
|
desktopHeight = dm.h;
|
||||||
}
|
}
|
||||||
|
@ -829,7 +829,7 @@ static void sdlResizeVideo()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (surface)
|
if (surface)
|
||||||
SDL_FreeSurface(surface);
|
SDL_DestroySurface(surface);
|
||||||
if (texture)
|
if (texture)
|
||||||
SDL_DestroyTexture(texture);
|
SDL_DestroyTexture(texture);
|
||||||
|
|
||||||
|
@ -924,13 +924,13 @@ void sdlInitVideo()
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef KMOD_META
|
#ifndef KMOD_META
|
||||||
#define KMOD_META KMOD_GUI
|
#define KMOD_META SDL_KMOD_GUI
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MOD_KEYS (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META)
|
#define MOD_KEYS (SDL_KMOD_CTRL | SDL_KMOD_SHIFT | SDL_KMOD_ALT | KMOD_META)
|
||||||
#define MOD_NOCTRL (KMOD_SHIFT | KMOD_ALT | KMOD_META)
|
#define MOD_NOCTRL (SDL_KMOD_SHIFT | SDL_KMOD_ALT | KMOD_META)
|
||||||
#define MOD_NOALT (KMOD_CTRL | KMOD_SHIFT | KMOD_META)
|
#define MOD_NOALT (SDL_KMOD_CTRL | SDL_KMOD_SHIFT | KMOD_META)
|
||||||
#define MOD_NOSHIFT (KMOD_CTRL | KMOD_ALT | KMOD_META)
|
#define MOD_NOSHIFT (SDL_KMOD_CTRL | SDL_KMOD_ALT | KMOD_META)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 04.02.2008 (xKiv): factored out from sdlPollEvents
|
* 04.02.2008 (xKiv): factored out from sdlPollEvents
|
||||||
|
@ -1052,12 +1052,12 @@ void sdlPollEvents()
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_QUIT:
|
case SDL_EVENT_QUIT:
|
||||||
emulating = 0;
|
emulating = 0;
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
switch (event.window.event) {
|
switch (event.window.event) {
|
||||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
case SDL_EVENT_WINDOW_FOCUS_GAINED:
|
||||||
if (pauseWhenInactive)
|
if (pauseWhenInactive)
|
||||||
if (paused) {
|
if (paused) {
|
||||||
if (emulating) {
|
if (emulating) {
|
||||||
|
@ -1066,7 +1066,7 @@ void sdlPollEvents()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
case SDL_EVENT_WINDOW_FOCUS_LOST:
|
||||||
if (pauseWhenInactive) {
|
if (pauseWhenInactive) {
|
||||||
wasPaused = true;
|
wasPaused = true;
|
||||||
if (emulating) {
|
if (emulating) {
|
||||||
|
@ -1077,31 +1077,31 @@ void sdlPollEvents()
|
||||||
memset(delta, 255, delta_size);
|
memset(delta, 255, delta_size);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_RESIZED:
|
case SDL_EVENT_WINDOW_RESIZED:
|
||||||
if (openGL)
|
if (openGL)
|
||||||
sdlOpenGLScaleWithAspect(event.window.data1, event.window.data2);
|
sdlOpenGLScaleWithAspect(event.window.data1, event.window.data2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_EVENT_MOUSE_MOTION:
|
||||||
case SDL_MOUSEBUTTONUP:
|
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||||
if (fullScreen) {
|
if (fullScreen) {
|
||||||
SDL_ShowCursor(SDL_ENABLE);
|
SDL_ShowCursor(SDL_ENABLE);
|
||||||
mouseCounter = 120;
|
mouseCounter = 120;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_JOYHATMOTION:
|
case SDL_EVENT_JOYSTICK_HAT_MOTION:
|
||||||
case SDL_JOYBUTTONDOWN:
|
case SDL_EVENT_JOYSTICK_BUTTON_DOWN:
|
||||||
case SDL_JOYBUTTONUP:
|
case SDL_EVENT_JOYSTICK_BUTTON_UP:
|
||||||
case SDL_JOYAXISMOTION:
|
case SDL_EVENT_JOYSTICK_AXIS_MOTION:
|
||||||
case SDL_KEYDOWN:
|
case SDL_EVENT_KEY_DOWN:
|
||||||
inputProcessSDLEvent(event);
|
inputProcessSDLEvent(event);
|
||||||
break;
|
break;
|
||||||
case SDL_KEYUP:
|
case SDL_EVENT_KEY_UP:
|
||||||
switch (event.key.keysym.sym) {
|
switch (event.key.keysym.sym) {
|
||||||
case SDLK_r:
|
case SDLK_r:
|
||||||
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) {
|
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & SDL_KMOD_CTRL)) {
|
||||||
if (emulating) {
|
if (emulating) {
|
||||||
emulator.emuReset();
|
emulator.emuReset();
|
||||||
|
|
||||||
|
@ -1110,30 +1110,30 @@ void sdlPollEvents()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDLK_b:
|
case SDLK_b:
|
||||||
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL))
|
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & SDL_KMOD_CTRL))
|
||||||
change_rewind(-1);
|
change_rewind(-1);
|
||||||
break;
|
break;
|
||||||
case SDLK_v:
|
case SDLK_v:
|
||||||
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL))
|
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & SDL_KMOD_CTRL))
|
||||||
change_rewind(+1);
|
change_rewind(+1);
|
||||||
break;
|
break;
|
||||||
case SDLK_h:
|
case SDLK_h:
|
||||||
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL))
|
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & SDL_KMOD_CTRL))
|
||||||
change_rewind(0);
|
change_rewind(0);
|
||||||
break;
|
break;
|
||||||
case SDLK_j:
|
case SDLK_j:
|
||||||
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL))
|
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & SDL_KMOD_CTRL))
|
||||||
change_rewind((rewindTopPos - rewindPos) * ((rewindTopPos > rewindPos) ? +1 : -1));
|
change_rewind((rewindTopPos - rewindPos) * ((rewindTopPos > rewindPos) ? +1 : -1));
|
||||||
break;
|
break;
|
||||||
case SDLK_e:
|
case SDLK_e:
|
||||||
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) {
|
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & SDL_KMOD_CTRL)) {
|
||||||
coreOptions.cheatsEnabled = !coreOptions.cheatsEnabled;
|
coreOptions.cheatsEnabled = !coreOptions.cheatsEnabled;
|
||||||
systemConsoleMessage(coreOptions.cheatsEnabled ? "Cheats on" : "Cheats off");
|
systemConsoleMessage(coreOptions.cheatsEnabled ? "Cheats on" : "Cheats off");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_s:
|
case SDLK_s:
|
||||||
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) {
|
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & SDL_KMOD_CTRL)) {
|
||||||
if (sdlSoundToggledOff) { // was off
|
if (sdlSoundToggledOff) { // was off
|
||||||
// restore saved state
|
// restore saved state
|
||||||
soundSetEnable(sdlSoundToggledOff);
|
soundSetEnable(sdlSoundToggledOff);
|
||||||
|
@ -1196,7 +1196,7 @@ void sdlPollEvents()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_p:
|
case SDLK_p:
|
||||||
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) {
|
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & SDL_KMOD_CTRL)) {
|
||||||
paused = !paused;
|
paused = !paused;
|
||||||
if (paused)
|
if (paused)
|
||||||
soundPause();
|
soundPause();
|
||||||
|
@ -1211,7 +1211,7 @@ void sdlPollEvents()
|
||||||
emulating = 0;
|
emulating = 0;
|
||||||
break;
|
break;
|
||||||
case SDLK_f:
|
case SDLK_f:
|
||||||
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) {
|
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & SDL_KMOD_CTRL)) {
|
||||||
fullScreen = !fullScreen;
|
fullScreen = !fullScreen;
|
||||||
SDL_SetWindowFullscreen(window, fullScreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
SDL_SetWindowFullscreen(window, fullScreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||||
if (openGL) {
|
if (openGL) {
|
||||||
|
@ -1224,7 +1224,7 @@ void sdlPollEvents()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDLK_g:
|
case SDLK_g:
|
||||||
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) {
|
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & SDL_KMOD_CTRL)) {
|
||||||
filterFunction = 0;
|
filterFunction = 0;
|
||||||
while (!filterFunction) {
|
while (!filterFunction) {
|
||||||
filter = (Filter)((filter + 1) % kInvalidFilter);
|
filter = (Filter)((filter + 1) % kInvalidFilter);
|
||||||
|
@ -1256,7 +1256,7 @@ void sdlPollEvents()
|
||||||
case SDLK_F6:
|
case SDLK_F6:
|
||||||
case SDLK_F7:
|
case SDLK_F7:
|
||||||
case SDLK_F8:
|
case SDLK_F8:
|
||||||
if (!(event.key.keysym.mod & MOD_NOSHIFT) && (event.key.keysym.mod & KMOD_SHIFT)) {
|
if (!(event.key.keysym.mod & MOD_NOSHIFT) && (event.key.keysym.mod & SDL_KMOD_SHIFT)) {
|
||||||
sdlHandleSavestateKey(event.key.keysym.sym - SDLK_F1, 1); // with SHIFT
|
sdlHandleSavestateKey(event.key.keysym.sym - SDLK_F1, 1); // with SHIFT
|
||||||
} else if (!(event.key.keysym.mod & MOD_KEYS)) {
|
} else if (!(event.key.keysym.mod & MOD_KEYS)) {
|
||||||
sdlHandleSavestateKey(event.key.keysym.sym - SDLK_F1, 0); // without SHIFT
|
sdlHandleSavestateKey(event.key.keysym.sym - SDLK_F1, 0); // without SHIFT
|
||||||
|
@ -1281,7 +1281,7 @@ void sdlPollEvents()
|
||||||
case SDLK_2:
|
case SDLK_2:
|
||||||
case SDLK_3:
|
case SDLK_3:
|
||||||
case SDLK_4:
|
case SDLK_4:
|
||||||
if (!(event.key.keysym.mod & MOD_NOALT) && (event.key.keysym.mod & KMOD_ALT)) {
|
if (!(event.key.keysym.mod & MOD_NOALT) && (event.key.keysym.mod & SDL_KMOD_ALT)) {
|
||||||
const char* disableMessages[4] = { "autofire A disabled",
|
const char* disableMessages[4] = { "autofire A disabled",
|
||||||
"autofire B disabled",
|
"autofire B disabled",
|
||||||
"autofire R disabled",
|
"autofire R disabled",
|
||||||
|
@ -1306,7 +1306,7 @@ void sdlPollEvents()
|
||||||
} else {
|
} else {
|
||||||
systemScreenMessage(disableMessages[event.key.keysym.sym - SDLK_1]);
|
systemScreenMessage(disableMessages[event.key.keysym.sym - SDLK_1]);
|
||||||
}
|
}
|
||||||
} else if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) {
|
} else if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & SDL_KMOD_CTRL)) {
|
||||||
int mask = 0x0100 << (event.key.keysym.sym - SDLK_1);
|
int mask = 0x0100 << (event.key.keysym.sym - SDLK_1);
|
||||||
coreOptions.layerSettings ^= mask;
|
coreOptions.layerSettings ^= mask;
|
||||||
coreOptions.layerEnable = DISPCNT & coreOptions.layerSettings;
|
coreOptions.layerEnable = DISPCNT & coreOptions.layerSettings;
|
||||||
|
@ -1317,14 +1317,14 @@ void sdlPollEvents()
|
||||||
case SDLK_6:
|
case SDLK_6:
|
||||||
case SDLK_7:
|
case SDLK_7:
|
||||||
case SDLK_8:
|
case SDLK_8:
|
||||||
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) {
|
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & SDL_KMOD_CTRL)) {
|
||||||
int mask = 0x0100 << (event.key.keysym.sym - SDLK_1);
|
int mask = 0x0100 << (event.key.keysym.sym - SDLK_1);
|
||||||
coreOptions.layerSettings ^= mask;
|
coreOptions.layerSettings ^= mask;
|
||||||
coreOptions.layerEnable = DISPCNT & coreOptions.layerSettings;
|
coreOptions.layerEnable = DISPCNT & coreOptions.layerSettings;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDLK_n:
|
case SDLK_n:
|
||||||
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & KMOD_CTRL)) {
|
if (!(event.key.keysym.mod & MOD_NOCTRL) && (event.key.keysym.mod & SDL_KMOD_CTRL)) {
|
||||||
if (paused)
|
if (paused)
|
||||||
paused = false;
|
paused = false;
|
||||||
pauseNextFrame = true;
|
pauseNextFrame = true;
|
||||||
|
@ -2062,7 +2062,7 @@ void systemDrawScreen()
|
||||||
} else {
|
} else {
|
||||||
SDL_UnlockSurface(surface);
|
SDL_UnlockSurface(surface);
|
||||||
SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch);
|
SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch);
|
||||||
SDL_RenderCopy(renderer, texture, NULL, NULL);
|
SDL_RenderTexture(renderer, texture, NULL, NULL);
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,18 +106,18 @@ static uint32_t sdlGetAxisCode(const SDL_Event& event)
|
||||||
uint32_t inputGetEventCode(const SDL_Event& event)
|
uint32_t inputGetEventCode(const SDL_Event& event)
|
||||||
{
|
{
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_KEYDOWN:
|
case SDL_EVENT_KEY_DOWN:
|
||||||
case SDL_KEYUP:
|
case SDL_EVENT_KEY_UP:
|
||||||
return event.key.keysym.sym;
|
return event.key.keysym.sym;
|
||||||
break;
|
break;
|
||||||
case SDL_JOYHATMOTION:
|
case SDL_EVENT_JOYSTICK_HAT_MOTION:
|
||||||
return sdlGetHatCode(event);
|
return sdlGetHatCode(event);
|
||||||
break;
|
break;
|
||||||
case SDL_JOYBUTTONDOWN:
|
case SDL_EVENT_JOYSTICK_BUTTON_DOWN:
|
||||||
case SDL_JOYBUTTONUP:
|
case SDL_EVENT_JOYSTICK_BUTTON_UP:
|
||||||
return sdlGetButtonCode(event);
|
return sdlGetButtonCode(event);
|
||||||
break;
|
break;
|
||||||
case SDL_JOYAXISMOTION:
|
case SDL_EVENT_JOYSTICK_AXIS_MOTION:
|
||||||
return sdlGetAxisCode(event);
|
return sdlGetAxisCode(event);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -348,18 +348,18 @@ static bool sdlCheckJoyKey(int key)
|
||||||
// joystick button
|
// joystick button
|
||||||
int button = what - 128;
|
int button = what - 128;
|
||||||
|
|
||||||
if (button >= SDL_JoystickNumButtons(sdlDevices[dev]))
|
if (button >= SDL_GetNumJoystickButtons(sdlDevices[dev]))
|
||||||
return false;
|
return false;
|
||||||
} else if (what < 0x20) {
|
} else if (what < 0x20) {
|
||||||
// joystick axis
|
// joystick axis
|
||||||
what >>= 1;
|
what >>= 1;
|
||||||
if (what >= SDL_JoystickNumAxes(sdlDevices[dev]))
|
if (what >= SDL_GetNumJoystickAxes(sdlDevices[dev]))
|
||||||
return false;
|
return false;
|
||||||
} else if (what < 0x30) {
|
} else if (what < 0x30) {
|
||||||
// joystick hat
|
// joystick hat
|
||||||
what = (what & 15);
|
what = (what & 15);
|
||||||
what >>= 2;
|
what >>= 2;
|
||||||
if (what >= SDL_JoystickNumHats(sdlDevices[dev]))
|
if (what >= SDL_GetNumJoystickHats(sdlDevices[dev]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ void inputInitJoysticks()
|
||||||
if (sdlDevices) {
|
if (sdlDevices) {
|
||||||
if (dev < sdlNumDevices) {
|
if (dev < sdlNumDevices) {
|
||||||
if (sdlDevices[dev] == NULL) {
|
if (sdlDevices[dev] == NULL) {
|
||||||
sdlDevices[dev] = SDL_JoystickOpen(dev);
|
sdlDevices[dev] = SDL_OpenJoystick(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = sdlCheckJoyKey(joypad[j][i]);
|
ok = sdlCheckJoyKey(joypad[j][i]);
|
||||||
|
@ -416,7 +416,7 @@ void inputInitJoysticks()
|
||||||
if (sdlDevices) {
|
if (sdlDevices) {
|
||||||
if (dev < sdlNumDevices) {
|
if (dev < sdlNumDevices) {
|
||||||
if (sdlDevices[dev] == NULL) {
|
if (sdlDevices[dev] == NULL) {
|
||||||
sdlDevices[dev] = SDL_JoystickOpen(dev);
|
sdlDevices[dev] = SDL_OpenJoystick(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = sdlCheckJoyKey(motion[i]);
|
ok = sdlCheckJoyKey(motion[i]);
|
||||||
|
@ -440,26 +440,26 @@ void inputProcessSDLEvent(const SDL_Event& event)
|
||||||
// fprintf(stdout, "%x\n", inputGetEventCode(event));
|
// fprintf(stdout, "%x\n", inputGetEventCode(event));
|
||||||
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_KEYDOWN:
|
case SDL_EVENT_KEY_DOWN:
|
||||||
if (!event.key.keysym.mod)
|
if (!event.key.keysym.mod)
|
||||||
sdlUpdateKey(event.key.keysym.sym, true);
|
sdlUpdateKey(event.key.keysym.sym, true);
|
||||||
break;
|
break;
|
||||||
case SDL_KEYUP:
|
case SDL_EVENT_KEY_UP:
|
||||||
if (!event.key.keysym.mod)
|
if (!event.key.keysym.mod)
|
||||||
sdlUpdateKey(event.key.keysym.sym, false);
|
sdlUpdateKey(event.key.keysym.sym, false);
|
||||||
break;
|
break;
|
||||||
case SDL_JOYHATMOTION:
|
case SDL_EVENT_JOYSTICK_HAT_MOTION:
|
||||||
sdlUpdateJoyHat(event.jhat.which,
|
sdlUpdateJoyHat(event.jhat.which,
|
||||||
event.jhat.hat,
|
event.jhat.hat,
|
||||||
event.jhat.value);
|
event.jhat.value);
|
||||||
break;
|
break;
|
||||||
case SDL_JOYBUTTONDOWN:
|
case SDL_EVENT_JOYSTICK_BUTTON_DOWN:
|
||||||
case SDL_JOYBUTTONUP:
|
case SDL_EVENT_JOYSTICK_BUTTON_UP:
|
||||||
sdlUpdateJoyButton(event.jbutton.which,
|
sdlUpdateJoyButton(event.jbutton.which,
|
||||||
event.jbutton.button,
|
event.jbutton.button,
|
||||||
event.jbutton.state == SDL_PRESSED);
|
event.jbutton.state == SDL_PRESSED);
|
||||||
break;
|
break;
|
||||||
case SDL_JOYAXISMOTION:
|
case SDL_EVENT_JOYSTICK_AXIS_MOTION:
|
||||||
sdlUpdateJoyAxis(event.jaxis.which,
|
sdlUpdateJoyAxis(event.jaxis.which,
|
||||||
event.jaxis.axis,
|
event.jaxis.axis,
|
||||||
event.jaxis.value);
|
event.jaxis.value);
|
||||||
|
|
|
@ -55,7 +55,7 @@ wxJoyControl HatStatusToJoyControl(const uint8_t status) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// For testing a GameController as a Joystick:
|
// For testing a GameController as a Joystick:
|
||||||
//#define SDL_IsGameController(x) false
|
//#define SDL_IsGamepad(x) false
|
||||||
|
|
||||||
// static
|
// static
|
||||||
wxJoystick wxJoystick::Invalid() {
|
wxJoystick wxJoystick::Invalid() {
|
||||||
|
@ -148,7 +148,7 @@ private:
|
||||||
SDL_JoystickID joystick_id_;
|
SDL_JoystickID joystick_id_;
|
||||||
|
|
||||||
// The SDL GameController instance.
|
// The SDL GameController instance.
|
||||||
SDL_GameController* game_controller_ = nullptr;
|
SDL_Gamepad* game_controller_ = nullptr;
|
||||||
|
|
||||||
// The SDL Joystick instance.
|
// The SDL Joystick instance.
|
||||||
SDL_Joystick* sdl_joystick_ = nullptr;
|
SDL_Joystick* sdl_joystick_ = nullptr;
|
||||||
|
@ -171,21 +171,21 @@ wxSDLJoyState::wxSDLJoyState(int sdl_index)
|
||||||
|
|
||||||
wxSDLJoyState::wxSDLJoyState(wxJoystick joystick) : wx_joystick_(joystick) {
|
wxSDLJoyState::wxSDLJoyState(wxJoystick joystick) : wx_joystick_(joystick) {
|
||||||
int sdl_index = wx_joystick_.sdl_index_;
|
int sdl_index = wx_joystick_.sdl_index_;
|
||||||
if (SDL_IsGameController(sdl_index)) {
|
if (SDL_IsGamepad(sdl_index)) {
|
||||||
game_controller_ = SDL_GameControllerOpen(sdl_index);
|
game_controller_ = SDL_GamepadOpen(sdl_index);
|
||||||
if (game_controller_)
|
if (game_controller_)
|
||||||
sdl_joystick_ = SDL_GameControllerGetJoystick(game_controller_);
|
sdl_joystick_ = SDL_GamepadGetJoystick(game_controller_);
|
||||||
} else {
|
} else {
|
||||||
sdl_joystick_ = SDL_JoystickOpen(sdl_index);
|
sdl_joystick_ = SDL_OpenJoystick(sdl_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sdl_joystick_)
|
if (!sdl_joystick_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
joystick_id_ = SDL_JoystickInstanceID(sdl_joystick_);
|
joystick_id_ = SDL_GetJoystickInstanceID(sdl_joystick_);
|
||||||
systemScreenMessage(
|
systemScreenMessage(
|
||||||
wxString::Format(_("Connected %s: %s"),
|
wxString::Format(_("Connected %s: %s"),
|
||||||
wx_joystick_.ToString(), SDL_JoystickNameForIndex(sdl_index)));
|
wx_joystick_.ToString(), SDL_GetJoystickNameForIndex(sdl_index)));
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSDLJoyState::~wxSDLJoyState() {
|
wxSDLJoyState::~wxSDLJoyState() {
|
||||||
|
@ -194,9 +194,9 @@ wxSDLJoyState::~wxSDLJoyState() {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (game_controller_)
|
if (game_controller_)
|
||||||
SDL_GameControllerClose(game_controller_);
|
SDL_GamepadClose(game_controller_);
|
||||||
else
|
else
|
||||||
SDL_JoystickClose(sdl_joystick_);
|
SDL_CloseJoystick(sdl_joystick_);
|
||||||
|
|
||||||
systemScreenMessage(
|
systemScreenMessage(
|
||||||
wxString::Format(_("Disconnected %s"), wx_joystick_.ToString()));
|
wxString::Format(_("Disconnected %s"), wx_joystick_.ToString()));
|
||||||
|
@ -322,11 +322,11 @@ void wxSDLJoyState::SetRumble(bool activate_rumble) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (rumbling_) {
|
if (rumbling_) {
|
||||||
SDL_GameControllerRumble(game_controller_, 0xFFFF, 0xFFFF, 300);
|
SDL_GamepadRumble(game_controller_, 0xFFFF, 0xFFFF, 300);
|
||||||
if (!IsRunning())
|
if (!IsRunning())
|
||||||
Start(150);
|
Start(150);
|
||||||
} else {
|
} else {
|
||||||
SDL_GameControllerRumble(game_controller_, 0, 0, 0);
|
SDL_GamepadRumble(game_controller_, 0, 0, 0);
|
||||||
Stop();
|
Stop();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -339,8 +339,8 @@ void wxSDLJoyState::Notify() {
|
||||||
wxJoyPoller::wxJoyPoller() {
|
wxJoyPoller::wxJoyPoller() {
|
||||||
// Start up joystick if not already started
|
// Start up joystick if not already started
|
||||||
// FIXME: check for errors
|
// FIXME: check for errors
|
||||||
SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER);
|
SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD);
|
||||||
SDL_GameControllerEventState(SDL_ENABLE);
|
SDL_GamepadEventState(SDL_ENABLE);
|
||||||
SDL_JoystickEventState(SDL_ENABLE);
|
SDL_JoystickEventState(SDL_ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ wxJoyPoller::~wxJoyPoller() {
|
||||||
// It is necessary to free all SDL resources before quitting SDL.
|
// It is necessary to free all SDL resources before quitting SDL.
|
||||||
joystick_states_.clear();
|
joystick_states_.clear();
|
||||||
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
||||||
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
|
SDL_QuitSubSystem(SDL_INIT_GAMEPAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxJoyPoller::Poll() {
|
void wxJoyPoller::Poll() {
|
||||||
|
@ -357,8 +357,8 @@ void wxJoyPoller::Poll() {
|
||||||
|
|
||||||
while (SDL_PollEvent(&e)) {
|
while (SDL_PollEvent(&e)) {
|
||||||
switch (e.type) {
|
switch (e.type) {
|
||||||
case SDL_CONTROLLERBUTTONDOWN:
|
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
||||||
case SDL_CONTROLLERBUTTONUP:
|
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
||||||
joy_state = FindJoyState(e.cbutton.which);
|
joy_state = FindJoyState(e.cbutton.which);
|
||||||
if (joy_state) {
|
if (joy_state) {
|
||||||
joy_state->ProcessButtonEvent(
|
joy_state->ProcessButtonEvent(
|
||||||
|
@ -366,7 +366,7 @@ void wxJoyPoller::Poll() {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_CONTROLLERAXISMOTION:
|
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
||||||
joy_state = FindJoyState(e.caxis.which);
|
joy_state = FindJoyState(e.caxis.which);
|
||||||
if (joy_state) {
|
if (joy_state) {
|
||||||
joy_state->ProcessAxisEvent(
|
joy_state->ProcessAxisEvent(
|
||||||
|
@ -374,15 +374,15 @@ void wxJoyPoller::Poll() {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_CONTROLLERDEVICEADDED:
|
case SDL_EVENT_GAMEPAD_ADDED:
|
||||||
case SDL_CONTROLLERDEVICEREMOVED:
|
case SDL_EVENT_GAMEPAD_REMOVED:
|
||||||
// Do nothing. This will be handled with JOYDEVICEADDED and
|
// Do nothing. This will be handled with JOYDEVICEADDED and
|
||||||
// JOYDEVICEREMOVED events.
|
// JOYDEVICEREMOVED events.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Joystick events for non-GameControllers.
|
// Joystick events for non-GameControllers.
|
||||||
case SDL_JOYBUTTONDOWN:
|
case SDL_EVENT_JOYSTICK_BUTTON_DOWN:
|
||||||
case SDL_JOYBUTTONUP:
|
case SDL_EVENT_JOYSTICK_BUTTON_UP:
|
||||||
joy_state = FindJoyState(e.jbutton.which);
|
joy_state = FindJoyState(e.jbutton.which);
|
||||||
if (joy_state && !joy_state->is_game_controller()) {
|
if (joy_state && !joy_state->is_game_controller()) {
|
||||||
joy_state->ProcessButtonEvent(
|
joy_state->ProcessButtonEvent(
|
||||||
|
@ -390,7 +390,7 @@ void wxJoyPoller::Poll() {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_JOYAXISMOTION:
|
case SDL_EVENT_JOYSTICK_AXIS_MOTION:
|
||||||
joy_state = FindJoyState(e.jaxis.which);
|
joy_state = FindJoyState(e.jaxis.which);
|
||||||
if (joy_state && !joy_state->is_game_controller()) {
|
if (joy_state && !joy_state->is_game_controller()) {
|
||||||
joy_state->ProcessAxisEvent(
|
joy_state->ProcessAxisEvent(
|
||||||
|
@ -398,7 +398,7 @@ void wxJoyPoller::Poll() {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_JOYHATMOTION:
|
case SDL_EVENT_JOYSTICK_HAT_MOTION:
|
||||||
joy_state = FindJoyState(e.jhat.which);
|
joy_state = FindJoyState(e.jhat.which);
|
||||||
if (joy_state && !joy_state->is_game_controller()) {
|
if (joy_state && !joy_state->is_game_controller()) {
|
||||||
joy_state->ProcessHatEvent(
|
joy_state->ProcessHatEvent(
|
||||||
|
@ -406,12 +406,12 @@ void wxJoyPoller::Poll() {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_JOYDEVICEADDED:
|
case SDL_EVENT_JOYSTICK_ADDED:
|
||||||
// Always remap all controllers.
|
// Always remap all controllers.
|
||||||
RemapControllers();
|
RemapControllers();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_JOYDEVICEREMOVED:
|
case SDL_EVENT_JOYSTICK_REMOVED:
|
||||||
joystick_states_.erase(e.jdevice.which);
|
joystick_states_.erase(e.jdevice.which);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue