drop dispmanx support. move switch main() to its own file
Dispmanx support is provided by SDL Enable omx audio and set TARGET_VIDEOCORE when building for RPi3
This commit is contained in:
parent
06a6e26588
commit
a136583189
|
@ -528,6 +528,7 @@ if(UNIX AND NOT APPLE AND NOT ANDROID)
|
|||
if(USE_GLES2)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE GLES GLES2)
|
||||
if(USE_VIDEOCORE)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE TARGET_VIDEOCORE USE_OMX)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE "-lbrcmGLESv2")
|
||||
target_link_directories(${PROJECT_NAME} PRIVATE "/opt/vc/lib")
|
||||
endif()
|
||||
|
@ -1051,19 +1052,18 @@ else()
|
|||
core/linux/unwind_info.cpp)
|
||||
if(NINTENDO_SWITCH)
|
||||
target_sources(${PROJECT_NAME} PRIVATE
|
||||
core/linux/libnx_vmem.cpp
|
||||
shell/switch/libnx_vmem.cpp
|
||||
shell/switch/stubs.c
|
||||
shell/switch/context_switch.S
|
||||
shell/switch/nswitch.h
|
||||
shell/switch/switch_gamepad.h
|
||||
shell/switch/switch_main.cpp
|
||||
shell/switch/ucontext.h)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT LIBRETRO)
|
||||
target_sources(${PROJECT_NAME} PRIVATE
|
||||
core/linux-dist/dispmanx.cpp
|
||||
core/linux-dist/dispmanx.h
|
||||
core/linux-dist/evdev.cpp
|
||||
core/linux-dist/evdev.h
|
||||
core/linux-dist/icon.h
|
||||
|
@ -1505,7 +1505,7 @@ endif()
|
|||
if((USE_OPENGL OR USE_GLES2 OR USE_GLES) AND NOT LIBRETRO)
|
||||
add_library(glad STATIC core/deps/glad/src/gl.c)
|
||||
if(NOT APPLE AND NOT WIN32 AND NOT SDL2_FOUND)
|
||||
# When SDL2 is not found, we can use EGL with ANativeWindow (Android), DispmanX (Raspberry Pi) or X11
|
||||
# When SDL2 is not found, we can use EGL with ANativeWindow (Android) or X11
|
||||
target_sources(glad PRIVATE core/deps/glad/src/egl.c)
|
||||
endif()
|
||||
target_include_directories(glad PUBLIC core/deps/glad/include)
|
||||
|
@ -1721,7 +1721,7 @@ if(NOT LIBRETRO)
|
|||
${CMAKE_CURRENT_BINARY_DIR}/Flycast.app/Contents/Frameworks/libvulkan.dylib)
|
||||
endif()
|
||||
endif()
|
||||
elseif(UNIX OR NINTENDO_SWITCH)
|
||||
elseif(UNIX)
|
||||
if(NOT BUILD_TESTING)
|
||||
target_sources(${PROJECT_NAME} PRIVATE
|
||||
core/linux-dist/main.cpp)
|
||||
|
|
|
@ -159,10 +159,6 @@ Option<bool> NetworkOutput("NetworkOutput", false, "network");
|
|||
Option<int> MultiboardSlaves("MultiboardSlaves", 1, "network");
|
||||
Option<bool> BattleCableEnable("BattleCable", false, "network");
|
||||
|
||||
#ifdef SUPPORT_DISPMANX
|
||||
Option<bool> DispmanxMaintainAspect("maintain_aspect", true, "dispmanx");
|
||||
#endif
|
||||
|
||||
#ifdef USE_OMX
|
||||
Option<int> OmxAudioLatency("audio_latency", 100, "omx");
|
||||
Option<bool> OmxAudioHdmi("audio_hdmi", true, "omx");
|
||||
|
|
|
@ -525,10 +525,6 @@ extern Option<bool> NetworkOutput;
|
|||
extern Option<int> MultiboardSlaves;
|
||||
extern Option<bool> BattleCableEnable;
|
||||
|
||||
#ifdef SUPPORT_DISPMANX
|
||||
extern Option<bool> DispmanxMaintainAspect;
|
||||
#endif
|
||||
|
||||
#ifdef USE_OMX
|
||||
extern Option<int> OmxAudioLatency;
|
||||
extern Option<bool> OmxAudioHdmi;
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
#if defined(SUPPORT_DISPMANX)
|
||||
#include "dispmanx.h"
|
||||
#include "types.h"
|
||||
#include "wsi/context.h"
|
||||
#include "cfg/option.h"
|
||||
|
||||
#include <bcm_host.h>
|
||||
#include <EGL/egl.h>
|
||||
|
||||
void dispmanx_window_create()
|
||||
{
|
||||
DISPMANX_DISPLAY_HANDLE_T dispman_display;
|
||||
DISPMANX_UPDATE_HANDLE_T dispman_update;
|
||||
DISPMANX_ELEMENT_HANDLE_T dispman_element;
|
||||
VC_RECT_T src_rect;
|
||||
VC_RECT_T dst_rect;
|
||||
VC_DISPMANX_ALPHA_T dispman_alpha;
|
||||
uint32_t screen_width;
|
||||
uint32_t screen_height;
|
||||
uint32_t window_width;
|
||||
uint32_t window_height;
|
||||
|
||||
dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS;
|
||||
dispman_alpha.opacity = 0xFF;
|
||||
dispman_alpha.mask = 0;
|
||||
|
||||
graphics_get_display_size(0 /* LCD */, &screen_width, &screen_height);
|
||||
|
||||
window_width = cfgLoadInt("window", "width", 0);
|
||||
window_height = cfgLoadInt("window", "height", 0);
|
||||
|
||||
if(window_width < 1)
|
||||
window_width = screen_width;
|
||||
if(window_height < 1)
|
||||
window_height = screen_height;
|
||||
|
||||
src_rect.x = 0;
|
||||
src_rect.y = 0;
|
||||
src_rect.width = window_width << 16;
|
||||
src_rect.height = window_height << 16;
|
||||
|
||||
if (config::DispmanxMaintainAspect)
|
||||
{
|
||||
float screen_aspect = (float)screen_width / screen_height;
|
||||
float window_aspect = (float)window_width / window_height;
|
||||
if(screen_aspect > window_aspect)
|
||||
{
|
||||
dst_rect.width = window_width * screen_height / window_height;
|
||||
dst_rect.height = screen_height;
|
||||
}
|
||||
else
|
||||
{
|
||||
dst_rect.width = screen_width;
|
||||
dst_rect.height = window_height * screen_width / window_width;
|
||||
}
|
||||
dst_rect.x = (screen_width - dst_rect.width) / 2;
|
||||
dst_rect.y = (screen_height - dst_rect.height) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
dst_rect.x = 0;
|
||||
dst_rect.y = 0;
|
||||
dst_rect.width = screen_width;
|
||||
dst_rect.height = screen_height;
|
||||
}
|
||||
|
||||
dispman_display = vc_dispmanx_display_open( 0 /* LCD */);
|
||||
dispman_update = vc_dispmanx_update_start( 0 );
|
||||
dispman_element = vc_dispmanx_element_add(dispman_update, dispman_display,
|
||||
0 /*layer*/, &dst_rect, 0 /*src*/,
|
||||
&src_rect, DISPMANX_PROTECTION_NONE,
|
||||
&dispman_alpha /*alpha*/, 0 /*clamp*/, (DISPMANX_TRANSFORM_T)0 /*transform*/);
|
||||
|
||||
static EGL_DISPMANX_WINDOW_T native_window;
|
||||
native_window.element = dispman_element;
|
||||
native_window.width = window_width;
|
||||
native_window.height = window_height;
|
||||
vc_dispmanx_update_submit_sync( dispman_update );
|
||||
|
||||
initRenderApi(&native_window, (void *)dispman_display);
|
||||
}
|
||||
#endif
|
|
@ -1,3 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
extern void dispmanx_window_create();
|
|
@ -3,7 +3,7 @@
|
|||
#endif
|
||||
#include "types.h"
|
||||
|
||||
#if defined(__unix__) || defined(__SWITCH__)
|
||||
#if defined(__unix__)
|
||||
#include "log/LogManager.h"
|
||||
#include "emulator.h"
|
||||
#include "rend/mainui.h"
|
||||
|
@ -16,14 +16,6 @@
|
|||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
#if defined(__SWITCH__)
|
||||
#include "nswitch.h"
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_DISPMANX)
|
||||
#include "dispmanx.h"
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_X11)
|
||||
#include "x11.h"
|
||||
#endif
|
||||
|
@ -96,9 +88,6 @@ void os_SetWindowText(const char * text)
|
|||
|
||||
void os_CreateWindow()
|
||||
{
|
||||
#if defined(SUPPORT_DISPMANX)
|
||||
dispmanx_window_create();
|
||||
#endif
|
||||
#if defined(SUPPORT_X11)
|
||||
x11_window_create();
|
||||
#endif
|
||||
|
@ -113,10 +102,6 @@ void common_linux_setup();
|
|||
// $HOME/.config/flycast on linux
|
||||
std::string find_user_config_dir()
|
||||
{
|
||||
#ifdef __SWITCH__
|
||||
flycast::mkdir("/flycast", 0755);
|
||||
return "/flycast/";
|
||||
#else
|
||||
std::string xdg_home;
|
||||
if (nowide::getenv("XDG_CONFIG_HOME") != nullptr)
|
||||
// If XDG_CONFIG_HOME is set explicitly, we'll use that instead of $HOME/.config
|
||||
|
@ -140,17 +125,12 @@ std::string find_user_config_dir()
|
|||
}
|
||||
// Unable to detect config dir, use the current folder
|
||||
return ".";
|
||||
#endif
|
||||
}
|
||||
|
||||
// Find the user data directory.
|
||||
// $HOME/.local/share/flycast on linux
|
||||
std::string find_user_data_dir()
|
||||
{
|
||||
#ifdef __SWITCH__
|
||||
flycast::mkdir("/flycast/data", 0755);
|
||||
return "/flycast/data/";
|
||||
#else
|
||||
std::string xdg_home;
|
||||
if (nowide::getenv("XDG_DATA_HOME") != nullptr)
|
||||
// If XDG_DATA_HOME is set explicitly, we'll use that instead of $HOME/.local/share
|
||||
|
@ -174,10 +154,8 @@ std::string find_user_data_dir()
|
|||
}
|
||||
// Unable to detect data dir, use the current folder
|
||||
return ".";
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef __SWITCH__
|
||||
static void addDirectoriesFromPath(std::vector<std::string>& dirs, const std::string& path, const std::string& suffix)
|
||||
{
|
||||
std::string::size_type pos = 0;
|
||||
|
@ -193,7 +171,6 @@ static void addDirectoriesFromPath(std::vector<std::string>& dirs, const std::st
|
|||
if (pos < path.length())
|
||||
dirs.push_back(path.substr(pos) + suffix);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Find a file in the user and system config directories.
|
||||
// The following folders are checked in this order:
|
||||
|
@ -208,9 +185,6 @@ std::vector<std::string> find_system_config_dirs()
|
|||
{
|
||||
std::vector<std::string> dirs;
|
||||
|
||||
#ifdef __SWITCH__
|
||||
dirs.push_back("/flycast/");
|
||||
#else
|
||||
std::string xdg_home;
|
||||
if (nowide::getenv("XDG_CONFIG_HOME") != nullptr)
|
||||
// If XDG_CONFIG_HOME is set explicitly, we'll use that instead of $HOME/.config
|
||||
|
@ -235,7 +209,6 @@ std::vector<std::string> find_system_config_dirs()
|
|||
dirs.push_back("/etc/flycast/"); // This isn't part of the XDG spec, but much more common than /etc/xdg/
|
||||
dirs.push_back("/etc/xdg/flycast/");
|
||||
}
|
||||
#endif
|
||||
dirs.push_back("./");
|
||||
|
||||
return dirs;
|
||||
|
@ -256,9 +229,6 @@ std::vector<std::string> find_system_data_dirs()
|
|||
{
|
||||
std::vector<std::string> dirs;
|
||||
|
||||
#ifdef __SWITCH__
|
||||
dirs.push_back("/flycast/data/");
|
||||
#else
|
||||
std::string xdg_home;
|
||||
if (nowide::getenv("XDG_DATA_HOME") != nullptr)
|
||||
// If XDG_DATA_HOME is set explicitly, we'll use that instead of $HOME/.local/share
|
||||
|
@ -288,7 +258,6 @@ std::vector<std::string> find_system_data_dirs()
|
|||
std::string path = (std::string)nowide::getenv("FLYCAST_BIOS_PATH");
|
||||
addDirectoriesFromPath(dirs, path, "/");
|
||||
}
|
||||
#endif
|
||||
dirs.push_back("./");
|
||||
dirs.push_back("data/");
|
||||
|
||||
|
@ -323,11 +292,6 @@ static bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,
|
|||
int main(int argc, char* argv[])
|
||||
{
|
||||
selfPath = argv[0];
|
||||
#if defined(__SWITCH__)
|
||||
socketInitializeDefault();
|
||||
nxlinkStdio();
|
||||
//appletSetFocusHandlingMode(AppletFocusHandlingMode_NoSuspend);
|
||||
#endif
|
||||
#if defined(USE_BREAKPAD)
|
||||
google_breakpad::MinidumpDescriptor descriptor("/tmp");
|
||||
google_breakpad::ExceptionHandler eh(descriptor, nullptr, dumpCallback, nullptr, true, -1);
|
||||
|
@ -353,9 +317,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(__unix__)
|
||||
common_linux_setup();
|
||||
#endif
|
||||
|
||||
if (flycast_init(argc, argv))
|
||||
die("Flycast initialization failed\n");
|
||||
|
@ -376,19 +338,13 @@ int main(int argc, char* argv[])
|
|||
flycast_term();
|
||||
os_UninstallFaultHandler();
|
||||
|
||||
#if defined(__SWITCH__)
|
||||
socketExit();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(__unix__)
|
||||
[[noreturn]] void os_DebugBreak()
|
||||
{
|
||||
raise(SIGTRAP);
|
||||
std::abort();
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __unix__ || __SWITCH__
|
||||
#endif // __unix__
|
||||
|
|
|
@ -88,7 +88,7 @@ private:
|
|||
|
||||
#include "sdl.h"
|
||||
|
||||
#elif defined(__ANDROID__) || defined(SUPPORT_DISPMANX) || defined(SUPPORT_X11)
|
||||
#elif defined(__ANDROID__) || defined(SUPPORT_X11)
|
||||
|
||||
#include "egl.h"
|
||||
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
This file is part of Flycast.
|
||||
|
||||
Flycast is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Flycast is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Flycast. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "nswitch.h"
|
||||
#include "stdclass.h"
|
||||
#include "sdl/sdl.h"
|
||||
#include "log/LogManager.h"
|
||||
#include "emulator.h"
|
||||
#include "rend/mainui.h"
|
||||
#include "oslib/directory.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
socketInitializeDefault();
|
||||
nxlinkStdio();
|
||||
//appletSetFocusHandlingMode(AppletFocusHandlingMode_NoSuspend);
|
||||
|
||||
LogManager::Init();
|
||||
|
||||
// Set directories
|
||||
flycast::mkdir("/flycast", 0755);
|
||||
flycast::mkdir("/flycast/data", 0755);
|
||||
set_user_config_dir("/flycast/");
|
||||
set_user_data_dir("/flycast/data/");
|
||||
|
||||
add_system_config_dir("/flycast");
|
||||
add_system_config_dir("./");
|
||||
add_system_data_dir("/flycast/data/");
|
||||
add_system_data_dir("./");
|
||||
add_system_data_dir("data/");
|
||||
|
||||
if (flycast_init(argc, argv))
|
||||
die("Flycast initialization failed");
|
||||
|
||||
mainui_loop();
|
||||
|
||||
sdl_window_destroy();
|
||||
flycast_term();
|
||||
|
||||
|
||||
socketExit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void os_SetupInput()
|
||||
{
|
||||
input_sdl_init();
|
||||
}
|
||||
|
||||
void os_TermInput()
|
||||
{
|
||||
input_sdl_quit();
|
||||
}
|
||||
|
||||
void UpdateInputState()
|
||||
{
|
||||
input_sdl_handle();
|
||||
}
|
||||
|
||||
void os_DoEvents()
|
||||
{
|
||||
}
|
||||
|
||||
void os_CreateWindow()
|
||||
{
|
||||
sdl_window_create();
|
||||
}
|
Loading…
Reference in New Issue