mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-24 12:41:05 +00:00
Have SDL2 as a project dependency
Initial SDL2 port Delete one last file.
This commit is contained in:
parent
bd5c943c65
commit
c0b672fc98
@ -69,6 +69,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/externals/cmake-modules")
|
|||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
include_directories(${OPENGL_INCLUDE_DIR})
|
include_directories(${OPENGL_INCLUDE_DIR})
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
option(ENABLE_GLFW "Enable the GLFW frontend" ON)
|
option(ENABLE_GLFW "Enable the GLFW frontend" ON)
|
||||||
if (ENABLE_GLFW)
|
if (ENABLE_GLFW)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
@ -145,6 +146,15 @@ ELSE()
|
|||||||
set(PLATFORM_LIBRARIES rt)
|
set(PLATFORM_LIBRARIES rt)
|
||||||
ENDIF (APPLE)
|
ENDIF (APPLE)
|
||||||
|
|
||||||
|
=======
|
||||||
|
find_package(SDL2 REQUIRED)
|
||||||
|
if (SDL2_FOUND)
|
||||||
|
include_directories(${SDL2_INCLUDE_DIRS})
|
||||||
|
else()
|
||||||
|
message(STATUS "SDL2 not found.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
>>>>>>> Have SDL2 as a project dependency
|
||||||
option(ENABLE_QT "Enable the Qt frontend" ON)
|
option(ENABLE_QT "Enable the Qt frontend" ON)
|
||||||
option(CITRA_FORCE_QT4 "Use Qt4 even if Qt5 is available." OFF)
|
option(CITRA_FORCE_QT4 "Use Qt4 even if Qt5 is available." OFF)
|
||||||
if (ENABLE_QT)
|
if (ENABLE_QT)
|
||||||
|
180
externals/cmake-modules/FindSDL2.cmake
vendored
Normal file
180
externals/cmake-modules/FindSDL2.cmake
vendored
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
# Locate SDL2 library
|
||||||
|
# This module defines
|
||||||
|
# SDL2_LIBRARY, the name of the library to link against
|
||||||
|
# SDL2_FOUND, if false, do not try to link to SDL2
|
||||||
|
# SDL2_INCLUDE_DIR, where to find SDL.h
|
||||||
|
#
|
||||||
|
# This module responds to the the flag:
|
||||||
|
# SDL2_BUILDING_LIBRARY
|
||||||
|
# If this is defined, then no SDL2_main will be linked in because
|
||||||
|
# only applications need main().
|
||||||
|
# Otherwise, it is assumed you are building an application and this
|
||||||
|
# module will attempt to locate and set the the proper link flags
|
||||||
|
# as part of the returned SDL2_LIBRARY variable.
|
||||||
|
#
|
||||||
|
# Don't forget to include SDL2main.h and SDL2main.m your project for the
|
||||||
|
# OS X framework based version. (Other versions link to -lSDL2main which
|
||||||
|
# this module will try to find on your behalf.) Also for OS X, this
|
||||||
|
# module will automatically add the -framework Cocoa on your behalf.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration
|
||||||
|
# and no SDL2_LIBRARY, it means CMake did not find your SDL2 library
|
||||||
|
# (SDL2.dll, libsdl2.so, SDL2.framework, etc).
|
||||||
|
# Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again.
|
||||||
|
# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value
|
||||||
|
# as appropriate. These values are used to generate the final SDL2_LIBRARY
|
||||||
|
# variable, but when these values are unset, SDL2_LIBRARY does not get created.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# $SDL2DIR is an environment variable that would
|
||||||
|
# correspond to the ./configure --prefix=$SDL2DIR
|
||||||
|
# used in building SDL2.
|
||||||
|
# l.e.galup 9-20-02
|
||||||
|
#
|
||||||
|
# Modified by Eric Wing.
|
||||||
|
# Added code to assist with automated building by using environmental variables
|
||||||
|
# and providing a more controlled/consistent search behavior.
|
||||||
|
# Added new modifications to recognize OS X frameworks and
|
||||||
|
# additional Unix paths (FreeBSD, etc).
|
||||||
|
# Also corrected the header search path to follow "proper" SDL2 guidelines.
|
||||||
|
# Added a search for SDL2main which is needed by some platforms.
|
||||||
|
# Added a search for threads which is needed by some platforms.
|
||||||
|
# Added needed compile switches for MinGW.
|
||||||
|
#
|
||||||
|
# On OSX, this will prefer the Framework version (if found) over others.
|
||||||
|
# People will have to manually change the cache values of
|
||||||
|
# SDL2_LIBRARY to override this selection or set the CMake environment
|
||||||
|
# CMAKE_INCLUDE_PATH to modify the search paths.
|
||||||
|
#
|
||||||
|
# Note that the header path has changed from SDL2/SDL.h to just SDL.h
|
||||||
|
# This needed to change because "proper" SDL2 convention
|
||||||
|
# is #include "SDL.h", not <SDL2/SDL.h>. This is done for portability
|
||||||
|
# reasons because not all systems place things in SDL2/ (see FreeBSD).
|
||||||
|
#
|
||||||
|
# Ported by Johnny Patterson. This is a literal port for SDL2 of the FindSDL.cmake
|
||||||
|
# module with the minor edit of changing "SDL" to "SDL2" where necessary. This
|
||||||
|
# was not created for redistribution, and exists temporarily pending official
|
||||||
|
# SDL2 CMake modules.
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Copyright 2003-2009 Kitware, Inc.
|
||||||
|
#
|
||||||
|
# Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
# see accompanying file Copyright.txt for details.
|
||||||
|
#
|
||||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# See the License for more information.
|
||||||
|
#=============================================================================
|
||||||
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
|
# License text for the above reference.)
|
||||||
|
|
||||||
|
FIND_PATH(SDL2_INCLUDE_DIR SDL.h
|
||||||
|
HINTS
|
||||||
|
$ENV{SDL2DIR}
|
||||||
|
PATH_SUFFIXES include/SDL2 include
|
||||||
|
PATHS
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/usr/local/include/SDL2
|
||||||
|
/usr/include/SDL2
|
||||||
|
/sw # Fink
|
||||||
|
/opt/local # DarwinPorts
|
||||||
|
/opt/csw # Blastwave
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
#MESSAGE("SDL2_INCLUDE_DIR is ${SDL2_INCLUDE_DIR}")
|
||||||
|
|
||||||
|
FIND_LIBRARY(SDL2_LIBRARY_TEMP
|
||||||
|
NAMES SDL2
|
||||||
|
HINTS
|
||||||
|
$ENV{SDL2DIR}
|
||||||
|
PATH_SUFFIXES lib64 lib
|
||||||
|
PATHS
|
||||||
|
/sw
|
||||||
|
/opt/local
|
||||||
|
/opt/csw
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
|
||||||
|
#MESSAGE("SDL2_LIBRARY_TEMP is ${SDL2_LIBRARY_TEMP}")
|
||||||
|
|
||||||
|
IF(NOT SDL2_BUILDING_LIBRARY)
|
||||||
|
IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
|
||||||
|
# Non-OS X framework versions expect you to also dynamically link to
|
||||||
|
# SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
|
||||||
|
# seem to provide SDL2main for compatibility even though they don't
|
||||||
|
# necessarily need it.
|
||||||
|
FIND_LIBRARY(SDL2MAIN_LIBRARY
|
||||||
|
NAMES SDL2main
|
||||||
|
HINTS
|
||||||
|
$ENV{SDL2DIR}
|
||||||
|
PATH_SUFFIXES lib64 lib
|
||||||
|
PATHS
|
||||||
|
/sw
|
||||||
|
/opt/local
|
||||||
|
/opt/csw
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
|
||||||
|
ENDIF(NOT SDL2_BUILDING_LIBRARY)
|
||||||
|
|
||||||
|
# SDL2 may require threads on your system.
|
||||||
|
# The Apple build may not need an explicit flag because one of the
|
||||||
|
# frameworks may already provide it.
|
||||||
|
# But for non-OSX systems, I will use the CMake Threads package.
|
||||||
|
IF(NOT APPLE)
|
||||||
|
FIND_PACKAGE(Threads)
|
||||||
|
ENDIF(NOT APPLE)
|
||||||
|
|
||||||
|
# MinGW needs an additional library, mwindows
|
||||||
|
# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -lmwindows
|
||||||
|
# (Actually on second look, I think it only needs one of the m* libraries.)
|
||||||
|
IF(MINGW)
|
||||||
|
SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
|
||||||
|
ENDIF(MINGW)
|
||||||
|
|
||||||
|
SET(SDL2_FOUND "NO")
|
||||||
|
IF(SDL2_LIBRARY_TEMP)
|
||||||
|
# For SDL2main
|
||||||
|
IF(NOT SDL2_BUILDING_LIBRARY)
|
||||||
|
IF(SDL2MAIN_LIBRARY)
|
||||||
|
SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
|
||||||
|
ENDIF(SDL2MAIN_LIBRARY)
|
||||||
|
ENDIF(NOT SDL2_BUILDING_LIBRARY)
|
||||||
|
|
||||||
|
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
|
||||||
|
# CMake doesn't display the -framework Cocoa string in the UI even
|
||||||
|
# though it actually is there if I modify a pre-used variable.
|
||||||
|
# I think it has something to do with the CACHE STRING.
|
||||||
|
# So I use a temporary variable until the end so I can set the
|
||||||
|
# "real" variable in one-shot.
|
||||||
|
IF(APPLE)
|
||||||
|
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
|
||||||
|
ENDIF(APPLE)
|
||||||
|
|
||||||
|
# For threads, as mentioned Apple doesn't need this.
|
||||||
|
# In fact, there seems to be a problem if I used the Threads package
|
||||||
|
# and try using this line, so I'm just skipping it entirely for OS X.
|
||||||
|
IF(NOT APPLE)
|
||||||
|
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
ENDIF(NOT APPLE)
|
||||||
|
|
||||||
|
# For MinGW library
|
||||||
|
IF(MINGW)
|
||||||
|
SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
|
||||||
|
ENDIF(MINGW)
|
||||||
|
|
||||||
|
# Set the final string here so the GUI reflects the final state.
|
||||||
|
SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
|
||||||
|
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
|
||||||
|
SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
|
||||||
|
|
||||||
|
SET(SDL2_FOUND "YES")
|
||||||
|
ENDIF(SDL2_LIBRARY_TEMP)
|
||||||
|
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2
|
||||||
|
REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
|
@ -4,9 +4,7 @@ include_directories(.)
|
|||||||
add_subdirectory(common)
|
add_subdirectory(common)
|
||||||
add_subdirectory(core)
|
add_subdirectory(core)
|
||||||
add_subdirectory(video_core)
|
add_subdirectory(video_core)
|
||||||
if (ENABLE_GLFW)
|
|
||||||
add_subdirectory(citra)
|
add_subdirectory(citra)
|
||||||
endif()
|
|
||||||
if (ENABLE_QT)
|
if (ENABLE_QT)
|
||||||
add_subdirectory(citra_qt)
|
add_subdirectory(citra_qt)
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
set(SRCS
|
set(SRCS
|
||||||
emu_window/emu_window_glfw.cpp
|
emu_window/emu_window_sdl.cpp
|
||||||
citra.cpp
|
citra.cpp
|
||||||
config.cpp
|
config.cpp
|
||||||
citra.rc
|
citra.rc
|
||||||
)
|
)
|
||||||
set(HEADERS
|
set(HEADERS
|
||||||
emu_window/emu_window_glfw.h
|
emu_window/emu_window_sdl.h
|
||||||
config.h
|
config.h
|
||||||
default_ini.h
|
default_ini.h
|
||||||
resource.h
|
resource.h
|
||||||
@ -15,7 +15,7 @@ create_directory_groups(${SRCS} ${HEADERS})
|
|||||||
|
|
||||||
add_executable(citra ${SRCS} ${HEADERS})
|
add_executable(citra ${SRCS} ${HEADERS})
|
||||||
target_link_libraries(citra core common video_core)
|
target_link_libraries(citra core common video_core)
|
||||||
target_link_libraries(citra ${GLFW_LIBRARIES} ${OPENGL_gl_LIBRARY} inih)
|
target_link_libraries(citra ${SDL2_LIBRARY} ${OPENGL_gl_LIBRARY} inih)
|
||||||
target_link_libraries(citra ${PLATFORM_LIBRARIES})
|
target_link_libraries(citra ${PLATFORM_LIBRARIES})
|
||||||
|
|
||||||
#install(TARGETS citra RUNTIME DESTINATION ${bindir})
|
#install(TARGETS citra RUNTIME DESTINATION ${bindir})
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
|
|
||||||
#include "citra/config.h"
|
#include "citra/config.h"
|
||||||
#include "citra/emu_window/emu_window_glfw.h"
|
#include "citra/emu_window/emu_window_sdl.h"
|
||||||
|
|
||||||
#include "video_core/video_core.h"
|
#include "video_core/video_core.h"
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ int main(int argc, char **argv) {
|
|||||||
log_filter.ParseFilterString(Settings::values.log_filter);
|
log_filter.ParseFilterString(Settings::values.log_filter);
|
||||||
|
|
||||||
std::string boot_filename = argv[1];
|
std::string boot_filename = argv[1];
|
||||||
EmuWindow_GLFW* emu_window = new EmuWindow_GLFW;
|
EmuWindow_SDL* emu_window = new EmuWindow_SDL;
|
||||||
|
|
||||||
VideoCore::g_hw_renderer_enabled = Settings::values.use_hw_renderer;
|
VideoCore::g_hw_renderer_enabled = Settings::values.use_hw_renderer;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
#include "citra/default_ini.h"
|
#include "citra/default_ini.h"
|
||||||
|
|
||||||
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
Config::Config() {
|
Config::Config() {
|
||||||
// TODO: Don't hardcode the path; let the frontend decide where to put the config files.
|
// TODO: Don't hardcode the path; let the frontend decide where to put the config files.
|
||||||
glfw_config_loc = FileUtil::GetUserPath(D_CONFIG_IDX) + "glfw-config.ini";
|
sdl_config_loc = FileUtil::GetUserPath(D_CONFIG_IDX) + "sdl-config.ini";
|
||||||
glfw_config = new INIReader(glfw_config_loc);
|
sdl_config = new INIReader(sdl_config_loc);
|
||||||
|
|
||||||
Reload();
|
Reload();
|
||||||
}
|
}
|
||||||
@ -41,55 +41,60 @@ bool Config::LoadINI(INIReader* config, const char* location, const std::string&
|
|||||||
|
|
||||||
void Config::ReadValues() {
|
void Config::ReadValues() {
|
||||||
// Controls
|
// Controls
|
||||||
Settings::values.pad_a_key = glfw_config->GetInteger("Controls", "pad_a", GLFW_KEY_A);
|
Settings::values.pad_a_key = sdl_config->GetInteger("Controls", "pad_a", SDL_SCANCODE_A);
|
||||||
Settings::values.pad_b_key = glfw_config->GetInteger("Controls", "pad_b", GLFW_KEY_S);
|
Settings::values.pad_b_key = sdl_config->GetInteger("Controls", "pad_b", SDL_SCANCODE_S);
|
||||||
Settings::values.pad_x_key = glfw_config->GetInteger("Controls", "pad_x", GLFW_KEY_Z);
|
Settings::values.pad_x_key = sdl_config->GetInteger("Controls", "pad_x", SDL_SCANCODE_Z);
|
||||||
Settings::values.pad_y_key = glfw_config->GetInteger("Controls", "pad_y", GLFW_KEY_X);
|
Settings::values.pad_y_key = sdl_config->GetInteger("Controls", "pad_y", SDL_SCANCODE_X);
|
||||||
Settings::values.pad_l_key = glfw_config->GetInteger("Controls", "pad_l", GLFW_KEY_Q);
|
Settings::values.pad_l_key = sdl_config->GetInteger("Controls", "pad_l", SDL_SCANCODE_Q);
|
||||||
Settings::values.pad_r_key = glfw_config->GetInteger("Controls", "pad_r", GLFW_KEY_W);
|
Settings::values.pad_r_key = sdl_config->GetInteger("Controls", "pad_r", SDL_SCANCODE_W);
|
||||||
Settings::values.pad_zl_key = glfw_config->GetInteger("Controls", "pad_zl", GLFW_KEY_1);
|
Settings::values.pad_zl_key = sdl_config->GetInteger("Controls", "pad_zl", SDL_SCANCODE_1);
|
||||||
Settings::values.pad_zr_key = glfw_config->GetInteger("Controls", "pad_zr", GLFW_KEY_2);
|
Settings::values.pad_zr_key = sdl_config->GetInteger("Controls", "pad_zr", SDL_SCANCODE_2);
|
||||||
Settings::values.pad_start_key = glfw_config->GetInteger("Controls", "pad_start", GLFW_KEY_M);
|
Settings::values.pad_start_key = sdl_config->GetInteger("Controls", "pad_start", SDL_SCANCODE_M);
|
||||||
Settings::values.pad_select_key = glfw_config->GetInteger("Controls", "pad_select", GLFW_KEY_N);
|
Settings::values.pad_select_key = sdl_config->GetInteger("Controls", "pad_select", SDL_SCANCODE_N);
|
||||||
Settings::values.pad_home_key = glfw_config->GetInteger("Controls", "pad_home", GLFW_KEY_B);
|
Settings::values.pad_home_key = sdl_config->GetInteger("Controls", "pad_home", SDL_SCANCODE_B);
|
||||||
Settings::values.pad_dup_key = glfw_config->GetInteger("Controls", "pad_dup", GLFW_KEY_T);
|
Settings::values.pad_dup_key = sdl_config->GetInteger("Controls", "pad_dup", SDL_SCANCODE_T);
|
||||||
Settings::values.pad_ddown_key = glfw_config->GetInteger("Controls", "pad_ddown", GLFW_KEY_G);
|
Settings::values.pad_ddown_key = sdl_config->GetInteger("Controls", "pad_ddown", SDL_SCANCODE_G);
|
||||||
Settings::values.pad_dleft_key = glfw_config->GetInteger("Controls", "pad_dleft", GLFW_KEY_F);
|
Settings::values.pad_dleft_key = sdl_config->GetInteger("Controls", "pad_dleft", SDL_SCANCODE_F);
|
||||||
Settings::values.pad_dright_key = glfw_config->GetInteger("Controls", "pad_dright", GLFW_KEY_H);
|
Settings::values.pad_dright_key = sdl_config->GetInteger("Controls", "pad_dright", SDL_SCANCODE_H);
|
||||||
Settings::values.pad_sup_key = glfw_config->GetInteger("Controls", "pad_sup", GLFW_KEY_UP);
|
Settings::values.pad_sup_key = sdl_config->GetInteger("Controls", "pad_sup", SDL_SCANCODE_UP);
|
||||||
Settings::values.pad_sdown_key = glfw_config->GetInteger("Controls", "pad_sdown", GLFW_KEY_DOWN);
|
Settings::values.pad_sdown_key = sdl_config->GetInteger("Controls", "pad_sdown", SDL_SCANCODE_DOWN);
|
||||||
Settings::values.pad_sleft_key = glfw_config->GetInteger("Controls", "pad_sleft", GLFW_KEY_LEFT);
|
Settings::values.pad_sleft_key = sdl_config->GetInteger("Controls", "pad_sleft", SDL_SCANCODE_LEFT);
|
||||||
Settings::values.pad_sright_key = glfw_config->GetInteger("Controls", "pad_sright", GLFW_KEY_RIGHT);
|
Settings::values.pad_sright_key = sdl_config->GetInteger("Controls", "pad_sright", SDL_SCANCODE_RIGHT);
|
||||||
Settings::values.pad_cup_key = glfw_config->GetInteger("Controls", "pad_cup", GLFW_KEY_I);
|
Settings::values.pad_cup_key = sdl_config->GetInteger("Controls", "pad_cup", SDL_SCANCODE_I);
|
||||||
Settings::values.pad_cdown_key = glfw_config->GetInteger("Controls", "pad_cdown", GLFW_KEY_K);
|
Settings::values.pad_cdown_key = sdl_config->GetInteger("Controls", "pad_cdown", SDL_SCANCODE_K);
|
||||||
Settings::values.pad_cleft_key = glfw_config->GetInteger("Controls", "pad_cleft", GLFW_KEY_J);
|
Settings::values.pad_cleft_key = sdl_config->GetInteger("Controls", "pad_cleft", SDL_SCANCODE_K);
|
||||||
Settings::values.pad_cright_key = glfw_config->GetInteger("Controls", "pad_cright", GLFW_KEY_L);
|
Settings::values.pad_cright_key = sdl_config->GetInteger("Controls", "pad_cright", SDL_SCANCODE_L);
|
||||||
|
|
||||||
// Core
|
// Core
|
||||||
|
<<<<<<< HEAD
|
||||||
Settings::values.frame_skip = glfw_config->GetInteger("Core", "frame_skip", 0);
|
Settings::values.frame_skip = glfw_config->GetInteger("Core", "frame_skip", 0);
|
||||||
|
=======
|
||||||
|
Settings::values.gpu_refresh_rate = sdl_config->GetInteger("Core", "gpu_refresh_rate", 30);
|
||||||
|
Settings::values.frame_skip = sdl_config->GetInteger("Core", "frame_skip", 0);
|
||||||
|
>>>>>>> Have SDL2 as a project dependency
|
||||||
|
|
||||||
// Renderer
|
// Renderer
|
||||||
Settings::values.use_hw_renderer = glfw_config->GetBoolean("Renderer", "use_hw_renderer", false);
|
Settings::values.use_hw_renderer = sdl_config->GetBoolean("Renderer", "use_hw_renderer", true);
|
||||||
|
|
||||||
Settings::values.bg_red = (float)glfw_config->GetReal("Renderer", "bg_red", 1.0);
|
Settings::values.bg_red = (float)sdl_config->GetReal("Renderer", "bg_red", 1.0);
|
||||||
Settings::values.bg_green = (float)glfw_config->GetReal("Renderer", "bg_green", 1.0);
|
Settings::values.bg_green = (float)sdl_config->GetReal("Renderer", "bg_green", 1.0);
|
||||||
Settings::values.bg_blue = (float)glfw_config->GetReal("Renderer", "bg_blue", 1.0);
|
Settings::values.bg_blue = (float)sdl_config->GetReal("Renderer", "bg_blue", 1.0);
|
||||||
|
|
||||||
// Data Storage
|
// Data Storage
|
||||||
Settings::values.use_virtual_sd = glfw_config->GetBoolean("Data Storage", "use_virtual_sd", true);
|
Settings::values.use_virtual_sd = sdl_config->GetBoolean("Data Storage", "use_virtual_sd", true);
|
||||||
|
|
||||||
// System Region
|
// System Region
|
||||||
Settings::values.region_value = glfw_config->GetInteger("System Region", "region_value", 1);
|
Settings::values.region_value = sdl_config->GetInteger("System Region", "region_value", 1);
|
||||||
|
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
Settings::values.log_filter = glfw_config->Get("Miscellaneous", "log_filter", "*:Info");
|
Settings::values.log_filter = sdl_config->Get("Miscellaneous", "log_filter", "*:Info");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::Reload() {
|
void Config::Reload() {
|
||||||
LoadINI(glfw_config, glfw_config_loc.c_str(), DefaultINI::glfw_config_file);
|
LoadINI(sdl_config, sdl_config_loc.c_str(), DefaultINI::sdl_config_file);
|
||||||
ReadValues();
|
ReadValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::~Config() {
|
Config::~Config() {
|
||||||
delete glfw_config;
|
delete sdl_config;
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
INIReader* glfw_config;
|
INIReader* sdl_config;
|
||||||
std::string glfw_config_loc;
|
std::string sdl_config_loc;
|
||||||
|
|
||||||
bool LoadINI(INIReader* config, const char* location, const std::string& default_contents="", bool retry=true);
|
bool LoadINI(INIReader* config, const char* location, const std::string& default_contents="", bool retry=true);
|
||||||
void ReadValues();
|
void ReadValues();
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
namespace DefaultINI {
|
namespace DefaultINI {
|
||||||
|
|
||||||
const char* glfw_config_file = R"(
|
const char* sdl_config_file = R"(
|
||||||
[Controls]
|
[Controls]
|
||||||
pad_start =
|
pad_start =
|
||||||
pad_select =
|
pad_select =
|
||||||
@ -62,6 +62,11 @@ use_virtual_sd =
|
|||||||
# 0: Japan, 1: USA (default), 2: Europe, 3: Australia, 4: China, 5: Korea, 6: Taiwan
|
# 0: Japan, 1: USA (default), 2: Europe, 3: Australia, 4: China, 5: Korea, 6: Taiwan
|
||||||
region_value =
|
region_value =
|
||||||
|
|
||||||
|
[Input Backend]
|
||||||
|
# Input system Citra will use during emulation
|
||||||
|
# 0: Keyboard (default), 1: SDL2 (gamepad)
|
||||||
|
input_backend =
|
||||||
|
|
||||||
[Miscellaneous]
|
[Miscellaneous]
|
||||||
# A filter which removes logs below a certain logging level.
|
# A filter which removes logs below a certain logging level.
|
||||||
# Examples: *:Debug Kernel.SVC:Trace Service.*:Critical
|
# Examples: *:Debug Kernel.SVC:Trace Service.*:Critical
|
||||||
|
@ -1,179 +0,0 @@
|
|||||||
// Copyright 2014 Citra Emulator Project
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
|
||||||
|
|
||||||
#include "common/logging/log.h"
|
|
||||||
|
|
||||||
#include "video_core/video_core.h"
|
|
||||||
|
|
||||||
#include "core/settings.h"
|
|
||||||
|
|
||||||
#include "citra/emu_window/emu_window_glfw.h"
|
|
||||||
|
|
||||||
EmuWindow_GLFW* EmuWindow_GLFW::GetEmuWindow(GLFWwindow* win) {
|
|
||||||
return static_cast<EmuWindow_GLFW*>(glfwGetWindowUserPointer(win));
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmuWindow_GLFW::OnMouseButtonEvent(GLFWwindow* win, int button, int action, int mods) {
|
|
||||||
if (button == GLFW_MOUSE_BUTTON_LEFT) {
|
|
||||||
auto emu_window = GetEmuWindow(win);
|
|
||||||
auto layout = emu_window->GetFramebufferLayout();
|
|
||||||
double x, y;
|
|
||||||
glfwGetCursorPos(win, &x, &y);
|
|
||||||
|
|
||||||
if (action == GLFW_PRESS)
|
|
||||||
emu_window->TouchPressed(static_cast<unsigned>(x), static_cast<unsigned>(y));
|
|
||||||
else if (action == GLFW_RELEASE)
|
|
||||||
emu_window->TouchReleased();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmuWindow_GLFW::OnCursorPosEvent(GLFWwindow* win, double x, double y) {
|
|
||||||
GetEmuWindow(win)->TouchMoved(static_cast<unsigned>(std::max(x, 0.0)), static_cast<unsigned>(std::max(y, 0.0)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Called by GLFW when a key event occurs
|
|
||||||
void EmuWindow_GLFW::OnKeyEvent(GLFWwindow* win, int key, int scancode, int action, int mods) {
|
|
||||||
auto emu_window = GetEmuWindow(win);
|
|
||||||
int keyboard_id = emu_window->keyboard_id;
|
|
||||||
|
|
||||||
if (action == GLFW_PRESS) {
|
|
||||||
emu_window->KeyPressed({key, keyboard_id});
|
|
||||||
} else if (action == GLFW_RELEASE) {
|
|
||||||
emu_window->KeyReleased({key, keyboard_id});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Whether the window is still open, and a close request hasn't yet been sent
|
|
||||||
const bool EmuWindow_GLFW::IsOpen() {
|
|
||||||
return glfwWindowShouldClose(m_render_window) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmuWindow_GLFW::OnFramebufferResizeEvent(GLFWwindow* win, int width, int height) {
|
|
||||||
GetEmuWindow(win)->NotifyFramebufferLayoutChanged(EmuWindow::FramebufferLayout::DefaultScreenLayout(width, height));
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmuWindow_GLFW::OnClientAreaResizeEvent(GLFWwindow* win, int width, int height) {
|
|
||||||
// NOTE: GLFW provides no proper way to set a minimal window size.
|
|
||||||
// Hence, we just ignore the corresponding EmuWindow hint.
|
|
||||||
OnFramebufferResizeEvent(win, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// EmuWindow_GLFW constructor
|
|
||||||
EmuWindow_GLFW::EmuWindow_GLFW() {
|
|
||||||
keyboard_id = KeyMap::NewDeviceId();
|
|
||||||
|
|
||||||
ReloadSetKeymaps();
|
|
||||||
|
|
||||||
glfwSetErrorCallback([](int error, const char *desc){
|
|
||||||
LOG_ERROR(Frontend, "GLFW 0x%08x: %s", error, desc);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Initialize the window
|
|
||||||
if(glfwInit() != GL_TRUE) {
|
|
||||||
LOG_CRITICAL(Frontend, "Failed to initialize GLFW! Exiting...");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
|
|
||||||
// GLFW on OSX requires these window hints to be set to create a 3.2+ GL context.
|
|
||||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
|
||||||
|
|
||||||
std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc);
|
|
||||||
m_render_window = glfwCreateWindow(VideoCore::kScreenTopWidth,
|
|
||||||
(VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight),
|
|
||||||
window_title.c_str(), nullptr, nullptr);
|
|
||||||
|
|
||||||
if (m_render_window == nullptr) {
|
|
||||||
LOG_CRITICAL(Frontend, "Failed to create GLFW window! Exiting...");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
glfwSetWindowUserPointer(m_render_window, this);
|
|
||||||
|
|
||||||
// Notify base interface about window state
|
|
||||||
int width, height;
|
|
||||||
glfwGetFramebufferSize(m_render_window, &width, &height);
|
|
||||||
OnFramebufferResizeEvent(m_render_window, width, height);
|
|
||||||
|
|
||||||
glfwGetWindowSize(m_render_window, &width, &height);
|
|
||||||
OnClientAreaResizeEvent(m_render_window, width, height);
|
|
||||||
|
|
||||||
// Setup callbacks
|
|
||||||
glfwSetKeyCallback(m_render_window, OnKeyEvent);
|
|
||||||
glfwSetMouseButtonCallback(m_render_window, OnMouseButtonEvent);
|
|
||||||
glfwSetCursorPosCallback(m_render_window, OnCursorPosEvent);
|
|
||||||
glfwSetFramebufferSizeCallback(m_render_window, OnFramebufferResizeEvent);
|
|
||||||
glfwSetWindowSizeCallback(m_render_window, OnClientAreaResizeEvent);
|
|
||||||
|
|
||||||
DoneCurrent();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// EmuWindow_GLFW destructor
|
|
||||||
EmuWindow_GLFW::~EmuWindow_GLFW() {
|
|
||||||
glfwTerminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Swap buffers to display the next frame
|
|
||||||
void EmuWindow_GLFW::SwapBuffers() {
|
|
||||||
glfwSwapBuffers(m_render_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Polls window events
|
|
||||||
void EmuWindow_GLFW::PollEvents() {
|
|
||||||
glfwPollEvents();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Makes the GLFW OpenGL context current for the caller thread
|
|
||||||
void EmuWindow_GLFW::MakeCurrent() {
|
|
||||||
glfwMakeContextCurrent(m_render_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Releases (dunno if this is the "right" word) the GLFW context from the caller thread
|
|
||||||
void EmuWindow_GLFW::DoneCurrent() {
|
|
||||||
glfwMakeContextCurrent(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmuWindow_GLFW::ReloadSetKeymaps() {
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_a_key, keyboard_id}, Service::HID::PAD_A);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_b_key, keyboard_id}, Service::HID::PAD_B);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_select_key, keyboard_id}, Service::HID::PAD_SELECT);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_start_key, keyboard_id}, Service::HID::PAD_START);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_dright_key, keyboard_id}, Service::HID::PAD_RIGHT);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_dleft_key, keyboard_id}, Service::HID::PAD_LEFT);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_dup_key, keyboard_id}, Service::HID::PAD_UP);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_ddown_key, keyboard_id}, Service::HID::PAD_DOWN);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_r_key, keyboard_id}, Service::HID::PAD_R);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_l_key, keyboard_id}, Service::HID::PAD_L);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_x_key, keyboard_id}, Service::HID::PAD_X);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_y_key, keyboard_id}, Service::HID::PAD_Y);
|
|
||||||
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_zl_key, keyboard_id}, Service::HID::PAD_ZL);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_zr_key, keyboard_id}, Service::HID::PAD_ZR);
|
|
||||||
|
|
||||||
// KeyMap::SetKeyMapping({Settings::values.pad_touch_key, keyboard_id}, Service::HID::PAD_TOUCH);
|
|
||||||
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_cright_key, keyboard_id}, Service::HID::PAD_C_RIGHT);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_cleft_key, keyboard_id}, Service::HID::PAD_C_LEFT);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_cup_key, keyboard_id}, Service::HID::PAD_C_UP);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_cdown_key, keyboard_id}, Service::HID::PAD_C_DOWN);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_sright_key, keyboard_id}, Service::HID::PAD_CIRCLE_RIGHT);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_sleft_key, keyboard_id}, Service::HID::PAD_CIRCLE_LEFT);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_sup_key, keyboard_id}, Service::HID::PAD_CIRCLE_UP);
|
|
||||||
KeyMap::SetKeyMapping({Settings::values.pad_sdown_key, keyboard_id}, Service::HID::PAD_CIRCLE_DOWN);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmuWindow_GLFW::OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) {
|
|
||||||
std::pair<int,int> current_size;
|
|
||||||
glfwGetWindowSize(m_render_window, ¤t_size.first, ¤t_size.second);
|
|
||||||
|
|
||||||
DEBUG_ASSERT((int)minimal_size.first > 0 && (int)minimal_size.second > 0);
|
|
||||||
int new_width = std::max(current_size.first, (int)minimal_size.first);
|
|
||||||
int new_height = std::max(current_size.second, (int)minimal_size.second);
|
|
||||||
|
|
||||||
if (current_size != std::make_pair(new_width, new_height))
|
|
||||||
glfwSetWindowSize(m_render_window, new_width, new_height);
|
|
||||||
}
|
|
192
src/citra/emu_window/emu_window_sdl.cpp
Normal file
192
src/citra/emu_window/emu_window_sdl.cpp
Normal file
@ -0,0 +1,192 @@
|
|||||||
|
// Copyright 2014 Citra Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "common/logging/log.h"
|
||||||
|
|
||||||
|
#include "video_core/video_core.h"
|
||||||
|
|
||||||
|
#include "core/settings.h"
|
||||||
|
|
||||||
|
#include "citra/emu_window/emu_window_sdl.h"
|
||||||
|
|
||||||
|
/// Whether the window is still open, and a close request hasn't yet been sent
|
||||||
|
const bool EmuWindow_SDL::IsOpen() {
|
||||||
|
return (m_render_window != nullptr) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmuWindow_SDL::OnFramebufferResizeEvent(SDL_Window* win, int width, int height) {
|
||||||
|
NotifyFramebufferLayoutChanged(EmuWindow::FramebufferLayout::DefaultScreenLayout(width, height));
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmuWindow_SDL::OnClientAreaResizeEvent(SDL_Window* win, int width, int height) {
|
||||||
|
OnFramebufferResizeEvent(win, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// EmuWindow_SDL constructor
|
||||||
|
EmuWindow_SDL::EmuWindow_SDL() {
|
||||||
|
keyboard_id = KeyMap::NewDeviceId();
|
||||||
|
|
||||||
|
ReloadSetKeymaps();
|
||||||
|
|
||||||
|
// Initialize SDL first
|
||||||
|
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||||
|
LOG_CRITICAL(Frontend, "Failed to initialize SDL! Exiting...");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Window title formatting
|
||||||
|
std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc);
|
||||||
|
|
||||||
|
// SDL-OpenGL attributes are set here
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
|
||||||
|
//SDL_GL_SetAttribute(SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG, GL_TRUE);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||||
|
|
||||||
|
// Initialize the window
|
||||||
|
m_render_window = SDL_CreateWindow(window_title.c_str(),
|
||||||
|
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||||
|
VideoCore::kScreenTopWidth, (VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight),
|
||||||
|
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
|
||||||
|
|
||||||
|
if (m_render_window == nullptr) {
|
||||||
|
LOG_CRITICAL(Frontend, "Failed to initialize SDL render window! Exiting...");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create an SDL-OpenGL context
|
||||||
|
m_render_context = SDL_GL_CreateContext(m_render_window);
|
||||||
|
|
||||||
|
// Notify base interface about window state
|
||||||
|
int width, height;
|
||||||
|
SDL_GetWindowSize(m_render_window, &width, &height);
|
||||||
|
OnClientAreaResizeEvent(m_render_window, width, height);
|
||||||
|
OnMinimalClientAreaChangeRequest(std::make_pair(width, height));
|
||||||
|
|
||||||
|
DoneCurrent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// EmuWindow_SDL destructor
|
||||||
|
EmuWindow_SDL::~EmuWindow_SDL() {
|
||||||
|
QuitWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Quits the current SDL EmuWindow
|
||||||
|
void EmuWindow_SDL::QuitWindow() {
|
||||||
|
SDL_DestroyWindow(m_render_window);
|
||||||
|
m_render_window = nullptr;
|
||||||
|
SDL_Quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Swap buffers to display the next frame
|
||||||
|
void EmuWindow_SDL::SwapBuffers() {
|
||||||
|
SDL_GL_SwapWindow(m_render_window);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Polls window events
|
||||||
|
void EmuWindow_SDL::PollEvents() {
|
||||||
|
SDL_Event event;
|
||||||
|
int sdl_key = 0;
|
||||||
|
|
||||||
|
//Poll for window, keyboard, and mouse events
|
||||||
|
while (SDL_PollEvent(&event)) {
|
||||||
|
switch (event.type) {
|
||||||
|
//X out of window
|
||||||
|
case SDL_QUIT:
|
||||||
|
QuitWindow();
|
||||||
|
break;
|
||||||
|
|
||||||
|
//Key press
|
||||||
|
case SDL_KEYDOWN:
|
||||||
|
sdl_key = event.key.keysym.scancode;
|
||||||
|
KeyPressed({sdl_key, keyboard_id});
|
||||||
|
break;
|
||||||
|
|
||||||
|
//Key release
|
||||||
|
case SDL_KEYUP:
|
||||||
|
sdl_key = event.key.keysym.scancode;
|
||||||
|
KeyReleased({sdl_key, keyboard_id});
|
||||||
|
break;
|
||||||
|
|
||||||
|
//Cursor movement
|
||||||
|
case SDL_MOUSEMOTION:
|
||||||
|
TouchMoved(static_cast<unsigned>(std::max(event.motion.x, 0)),
|
||||||
|
static_cast<unsigned>(std::max(event.motion.y, 0)));
|
||||||
|
break;
|
||||||
|
|
||||||
|
//Mouse button press
|
||||||
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
if (event.button.button == SDL_BUTTON_LEFT) {
|
||||||
|
TouchPressed(static_cast<unsigned>(event.button.x),
|
||||||
|
static_cast<unsigned>(event.button.y));
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
//Mouse button release
|
||||||
|
case SDL_MOUSEBUTTONUP:
|
||||||
|
if (event.button.button == SDL_BUTTON_LEFT) TouchReleased();
|
||||||
|
break;
|
||||||
|
|
||||||
|
//Window resize event
|
||||||
|
case SDL_WINDOWEVENT:
|
||||||
|
if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
|
||||||
|
OnClientAreaResizeEvent(m_render_window, event.window.data1, event.window.data2);
|
||||||
|
SDL_SetWindowSize(m_render_window, event.window.data1, event.window.data2);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
//Leave everything else to InputCommon
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Makes the SDL OpenGL context current for the caller thread
|
||||||
|
void EmuWindow_SDL::MakeCurrent() {
|
||||||
|
SDL_GL_MakeCurrent(m_render_window, m_render_context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Releases (dunno if this is the "right" word) the SDL context from the caller thread
|
||||||
|
void EmuWindow_SDL::DoneCurrent() {
|
||||||
|
SDL_GL_MakeCurrent(m_render_window, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmuWindow_SDL::ReloadSetKeymaps() {
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_a_key, keyboard_id}, Service::HID::PAD_A);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_b_key, keyboard_id}, Service::HID::PAD_B);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_select_key, keyboard_id}, Service::HID::PAD_SELECT);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_start_key, keyboard_id}, Service::HID::PAD_START);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_dright_key, keyboard_id}, Service::HID::PAD_RIGHT);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_dleft_key, keyboard_id}, Service::HID::PAD_LEFT);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_dup_key, keyboard_id}, Service::HID::PAD_UP);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_ddown_key, keyboard_id}, Service::HID::PAD_DOWN);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_r_key, keyboard_id}, Service::HID::PAD_R);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_l_key, keyboard_id}, Service::HID::PAD_L);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_x_key, keyboard_id}, Service::HID::PAD_X);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_y_key, keyboard_id}, Service::HID::PAD_Y);
|
||||||
|
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_zl_key, keyboard_id}, Service::HID::PAD_ZL);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_zr_key, keyboard_id}, Service::HID::PAD_ZR);
|
||||||
|
|
||||||
|
// KeyMap::SetKeyMapping({Settings::values.pad_touch_key, keyboard_id}, Service::HID::PAD_TOUCH);
|
||||||
|
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_cright_key, keyboard_id}, Service::HID::PAD_C_RIGHT);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_cleft_key, keyboard_id}, Service::HID::PAD_C_LEFT);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_cup_key, keyboard_id}, Service::HID::PAD_C_UP);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_cdown_key, keyboard_id}, Service::HID::PAD_C_DOWN);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_sright_key, keyboard_id}, Service::HID::PAD_CIRCLE_RIGHT);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_sleft_key, keyboard_id}, Service::HID::PAD_CIRCLE_LEFT);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_sup_key, keyboard_id}, Service::HID::PAD_CIRCLE_UP);
|
||||||
|
KeyMap::SetKeyMapping({Settings::values.pad_sdown_key, keyboard_id}, Service::HID::PAD_CIRCLE_DOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmuWindow_SDL::OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) {
|
||||||
|
DEBUG_ASSERT((int)minimal_size.first > 0 && (int)minimal_size.second > 0);
|
||||||
|
int min_width = minimal_size.first;
|
||||||
|
int min_height = minimal_size.second;
|
||||||
|
|
||||||
|
SDL_SetWindowMinimumSize(m_render_window, min_width, min_height);
|
||||||
|
}
|
@ -4,14 +4,15 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <SDL2/SDL_opengl.h>
|
||||||
|
|
||||||
#include "common/emu_window.h"
|
#include "common/emu_window.h"
|
||||||
|
|
||||||
struct GLFWwindow;
|
class EmuWindow_SDL : public EmuWindow {
|
||||||
|
|
||||||
class EmuWindow_GLFW : public EmuWindow {
|
|
||||||
public:
|
public:
|
||||||
EmuWindow_GLFW();
|
EmuWindow_SDL();
|
||||||
~EmuWindow_GLFW();
|
~EmuWindow_SDL();
|
||||||
|
|
||||||
/// Swap buffers to display the next frame
|
/// Swap buffers to display the next frame
|
||||||
void SwapBuffers() override;
|
void SwapBuffers() override;
|
||||||
@ -22,30 +23,26 @@ public:
|
|||||||
/// Makes the graphics context current for the caller thread
|
/// Makes the graphics context current for the caller thread
|
||||||
void MakeCurrent() override;
|
void MakeCurrent() override;
|
||||||
|
|
||||||
/// Releases (dunno if this is the "right" word) the GLFW context from the caller thread
|
/// Releases (dunno if this is the "right" word) the SDL context from the caller thread
|
||||||
void DoneCurrent() override;
|
void DoneCurrent() override;
|
||||||
|
|
||||||
static void OnKeyEvent(GLFWwindow* win, int key, int scancode, int action, int mods);
|
|
||||||
|
|
||||||
static void OnMouseButtonEvent(GLFWwindow* window, int button, int action, int mods);
|
|
||||||
|
|
||||||
static void OnCursorPosEvent(GLFWwindow* window, double x, double y);
|
|
||||||
|
|
||||||
/// Whether the window is still open, and a close request hasn't yet been sent
|
/// Whether the window is still open, and a close request hasn't yet been sent
|
||||||
const bool IsOpen();
|
const bool IsOpen();
|
||||||
|
|
||||||
static void OnClientAreaResizeEvent(GLFWwindow* win, int width, int height);
|
void OnClientAreaResizeEvent(SDL_Window* win, int width, int height);
|
||||||
|
|
||||||
static void OnFramebufferResizeEvent(GLFWwindow* win, int width, int height);
|
void OnFramebufferResizeEvent(SDL_Window* win, int width, int height);
|
||||||
|
|
||||||
void ReloadSetKeymaps() override;
|
void ReloadSetKeymaps() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) override;
|
void OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) override;
|
||||||
|
|
||||||
static EmuWindow_GLFW* GetEmuWindow(GLFWwindow* win);
|
/// Quits the current SDL EmuWindow
|
||||||
|
void QuitWindow();
|
||||||
|
|
||||||
GLFWwindow* m_render_window; ///< Internal GLFW render window
|
SDL_Window* m_render_window; ///< Internal SDL render window
|
||||||
|
SDL_GLContext m_render_context; ///< SDL-OpenGL context
|
||||||
|
|
||||||
/// Device id of keyboard for use with KeyMap
|
/// Device id of keyboard for use with KeyMap
|
||||||
int keyboard_id;
|
int keyboard_id;
|
Loading…
Reference in New Issue
Block a user