From 5084fb82b8043d48bb54ce919b83f4aa39479f7a Mon Sep 17 00:00:00 2001 From: DH Date: Mon, 24 Feb 2025 05:59:06 +0300 Subject: [PATCH] Android stuff 2 --- 3rdparty/CMakeLists.txt | 19 +++++++++++-------- 3rdparty/hidapi/CMakeLists.txt | 2 ++ rpcs3/Emu/Cell/Modules/cellMic.cpp | 23 ++++++++++++++++++----- rpcs3/Input/pad_thread.cpp | 13 ++++++++++++- 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 92805027e3..cb0909e978 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -79,17 +79,16 @@ else() # we don't have the system libusb, so we compile from submodule unset(LIBUSB_LIBRARIES CACHE) add_subdirectory(libusb EXCLUDE_FROM_ALL) + + if (NOT TARGET usb-1.0 AND TARGET usb-1.0-static) + add_library(usb-1.0 ALIAS usb-1.0-static) + endif() endif() endif() # hidapi -if (NOT ANDROID) - add_subdirectory(hidapi) -else() - add_library(3rdparty_hidapi INTERFACE) - target_compile_definitions(3rdparty_hidapi INTERFACE WITHOUT_HIDAPI=1) -endif() +add_subdirectory(hidapi) # glslang add_subdirectory(glslang EXCLUDE_FROM_ALL) @@ -278,13 +277,17 @@ if(NOT ANDROID) if (WIN32) target_link_libraries(3rdparty_ffmpeg INTERFACE "Bcrypt.lib") endif() - else() + find_library(FFMPEG_LIB_AVFORMAT avformat PATHS ${FFMPEG_LIB_DIR} NO_DEFAULT_PATH) find_library(FFMPEG_LIB_AVCODEC avcodec PATHS ${FFMPEG_LIB_DIR} NO_DEFAULT_PATH) find_library(FFMPEG_LIB_AVUTIL avutil PATHS ${FFMPEG_LIB_DIR} NO_DEFAULT_PATH) find_library(FFMPEG_LIB_SWSCALE swscale PATHS ${FFMPEG_LIB_DIR} NO_DEFAULT_PATH) find_library(FFMPEG_LIB_SWRESAMPLE swresample PATHS ${FFMPEG_LIB_DIR} NO_DEFAULT_PATH) + if (FFMPEG_LIB_AVFORMAT MATCHES "FFMPEG_LIB_AVFORMAT-NOTFOUND") + message(FATAL_ERROR "@#$%! FFMPEG NOT FOUND! ${FFMPEG_LIB_DIR}") + endif() + target_link_libraries(3rdparty_ffmpeg INTERFACE ${FFMPEG_LIB_AVFORMAT} @@ -293,11 +296,11 @@ if(NOT ANDROID) ${FFMPEG_LIB_SWSCALE} ${FFMPEG_LIB_SWRESAMPLE} ) - endif() target_include_directories(3rdparty_ffmpeg INTERFACE "ffmpeg/include") endif() endif() + # GLEW add_library(3rdparty_glew INTERFACE) if(NOT MSVC AND NOT ANDROID) diff --git a/3rdparty/hidapi/CMakeLists.txt b/3rdparty/hidapi/CMakeLists.txt index af4d1b0f00..e1e36ac13e 100644 --- a/3rdparty/hidapi/CMakeLists.txt +++ b/3rdparty/hidapi/CMakeLists.txt @@ -15,6 +15,8 @@ elseif(CMAKE_SYSTEM MATCHES "Linux") target_link_libraries(3rdparty_hidapi INTERFACE hidapi-hidraw udev) elseif(WIN32) target_link_libraries(3rdparty_hidapi INTERFACE hidapi::hidapi hidapi::include Shlwapi.lib) +elseif(ANDROID) + target_link_libraries(3rdparty_hidapi INTERFACE hidapi::libusb) else() target_link_libraries(3rdparty_hidapi INTERFACE hidapi-libusb usb) endif() diff --git a/rpcs3/Emu/Cell/Modules/cellMic.cpp b/rpcs3/Emu/Cell/Modules/cellMic.cpp index 62ae150f7f..267dc889f5 100644 --- a/rpcs3/Emu/Cell/Modules/cellMic.cpp +++ b/rpcs3/Emu/Cell/Modules/cellMic.cpp @@ -10,11 +10,13 @@ #include #include +#ifndef WITHOUT_OPENAL #include "3rdparty/OpenAL/openal-soft/include/AL/alext.h" +#endif LOG_CHANNEL(cellMic); -template<> +template <> void fmt_class_string::format(std::string& out, u64 arg) { format_enum(out, arg, [](auto error) @@ -43,7 +45,7 @@ void fmt_class_string::format(std::string& out, u64 arg) }); } -template<> +template <> void fmt_class_string::format(std::string& out, u64 arg) { format_enum(out, arg, [](auto error) @@ -240,7 +242,6 @@ bool mic_context::check_device(u32 dev_num) return device.is_registered(); } - // Static functions template @@ -304,6 +305,7 @@ error_code microphone_device::open_microphone(const u8 type, const u32 dsp_r, co raw_samplingrate = raw_r; num_channels = channels; +#ifndef WITHOUT_OPENAL // Adjust number of channels depending on microphone type switch (device_type) { @@ -482,10 +484,14 @@ error_code microphone_device::open_microphone(const u8 type, const u32 dsp_r, co mic_opened = true; return CELL_OK; +#else + return CELL_MICIN_ERROR_DEVICE_NOT_SUPPORT; +#endif } error_code microphone_device::close_microphone() { +#ifndef WITHOUT_OPENAL if (mic_started) { stop_microphone(); @@ -504,12 +510,14 @@ error_code microphone_device::close_microphone() temp_buf.clear(); mic_opened = false; +#endif return CELL_OK; } error_code microphone_device::start_microphone() { +#ifndef WITHOUT_OPENAL for (const mic_device& micdevice : devices) { alcCaptureStart(micdevice.device); @@ -520,14 +528,15 @@ error_code microphone_device::start_microphone() return CELL_MICIN_ERROR_FATAL; } } +#endif mic_started = true; - return CELL_OK; } error_code microphone_device::stop_microphone() { +#ifndef WITHOUT_OPENAL for (const mic_device& micdevice : devices) { alcCaptureStop(micdevice.device); @@ -536,9 +545,9 @@ error_code microphone_device::stop_microphone() cellMic.error("Error stopping capture of device %s (error=0x%x)", micdevice.name, err); } } +#endif mic_started = false; - return CELL_OK; } @@ -600,6 +609,7 @@ f32 microphone_device::calculate_energy_level() u32 microphone_device::capture_audio() { +#ifndef WITHOUT_OPENAL ensure(sample_size > 0); u32 num_samples = inbuf_size / sample_size; @@ -634,6 +644,9 @@ u32 microphone_device::capture_audio() } return num_samples; +#else + return 0; +#endif } // Private functions diff --git a/rpcs3/Input/pad_thread.cpp b/rpcs3/Input/pad_thread.cpp index 4465035c3f..8fa79e55dd 100644 --- a/rpcs3/Input/pad_thread.cpp +++ b/rpcs3/Input/pad_thread.cpp @@ -15,7 +15,9 @@ #ifdef HAVE_SDL3 #include "sdl_pad_handler.h" #endif +#ifndef ANDROID #include "keyboard_pad_handler.h" +#endif #include "Emu/Io/Null/NullPadHandler.h" #include "Emu/Io/interception.h" #include "Emu/Io/PadHandler.h" @@ -149,7 +151,9 @@ void pad_thread::Init() input_log.trace("Using pad config:\n%s", g_cfg_input); +#ifndef ANDROID std::shared_ptr keyptr; +#endif // Always have a Null Pad Handler std::shared_ptr nullpad = std::make_shared(); @@ -170,16 +174,19 @@ void pad_thread::Init() { if (handler_type == pad_handler::keyboard) { +#ifndef ANDROID keyptr = std::make_shared(); keyptr->moveToThread(static_cast(m_curthread)); keyptr->SetTargetWindow(static_cast(m_curwindow)); cur_pad_handler = keyptr; +#else + cur_pad_handler = nullpad; +#endif } else { cur_pad_handler = GetHandler(handler_type); } - m_handlers.emplace(handler_type, cur_pad_handler); } cur_pad_handler->Init(); @@ -651,7 +658,11 @@ std::shared_ptr pad_thread::GetHandler(pad_handler type) case pad_handler::null: return std::make_shared(); case pad_handler::keyboard: +#ifdef ANDROID + return std::make_shared(); +#else return std::make_shared(); +#endif case pad_handler::ds3: return std::make_shared(); case pad_handler::ds4: