From e2a72b279894bf51372ef7d12fc7334467bf2e75 Mon Sep 17 00:00:00 2001 From: Gauvain 'GovanifY' Roussel-Tarbouriech Date: Mon, 2 Nov 2020 21:30:13 +0100 Subject: [PATCH] USB: initial merge finally complete --- cmake/FindPulseAudio.cmake | 43 +++++++++++++++++++++++++ cmake/SearchForStuff.cmake | 8 +++++ pcsx2/CMakeLists.txt | 36 ++++++++++++++++++++- pcsx2/USB/linux/config-gtk.cpp | 24 +------------- pcsx2/USB/linux/config.h | 2 +- pcsx2/USB/qemu-usb/usb-ohci.cpp | 4 +-- pcsx2/USB/usb-eyetoy/cam-linux.cpp | 2 +- pcsx2/USB/usb-hid/evdev/evdev-gtk.cpp | 4 +-- pcsx2/USB/usb-hid/evdev/evdev.cpp | 6 ++-- pcsx2/USB/usb-hid/evdev/evdev.h | 4 +-- pcsx2/USB/usb-mic/audiodev-pulse.cpp | 4 +-- pcsx2/USB/usb-mic/audiodev-pulse.h | 4 +-- pcsx2/USB/usb-msd/usb-msd-gtk.cpp | 4 +-- pcsx2/USB/usb-pad/evdev/evdev-ff.cpp | 4 +-- pcsx2/USB/usb-pad/evdev/evdev-gtk.cpp | 4 +-- pcsx2/USB/usb-pad/evdev/evdev.cpp | 4 +-- pcsx2/USB/usb-pad/evdev/evdev.h | 4 +-- pcsx2/USB/usb-pad/evdev/shared-gtk.cpp | 2 +- pcsx2/USB/usb-pad/evdev/shared.h | 2 +- pcsx2/USB/usb-pad/joydev/joydev-gtk.cpp | 4 +-- pcsx2/USB/usb-pad/joydev/joydev.cpp | 2 +- pcsx2/USB/usb-pad/joydev/joydev.h | 4 +-- 22 files changed, 119 insertions(+), 56 deletions(-) create mode 100644 cmake/FindPulseAudio.cmake diff --git a/cmake/FindPulseAudio.cmake b/cmake/FindPulseAudio.cmake new file mode 100644 index 0000000000..1f6f843a1d --- /dev/null +++ b/cmake/FindPulseAudio.cmake @@ -0,0 +1,43 @@ +# - Find PulseAudio includes and libraries +# +# PULSEAUDIO_FOUND - True if PULSEAUDIO_INCLUDE_DIR & +# PULSEAUDIO_LIBRARY are found +# PULSEAUDIO_LIBRARIES - Set when PULSEAUDIO_LIBRARY is found +# PULSEAUDIO_INCLUDE_DIRS - Set when PULSEAUDIO_INCLUDE_DIR is found +# +# PULSEAUDIO_INCLUDE_DIR - where to find pulse/pulseaudio.h, etc. +# PULSEAUDIO_LIBRARY - the pulse library +# PULSEAUDIO_VERSION_STRING - the version of PulseAudio found +# + +find_path(PULSEAUDIO_INCLUDE_DIR + NAMES pulse/pulseaudio.h + DOC "The PulseAudio include directory" +) + +find_library(PULSEAUDIO_LIBRARY + NAMES pulse + DOC "The PulseAudio library" +) + +if(PULSEAUDIO_INCLUDE_DIR AND EXISTS "${PULSEAUDIO_INCLUDE_DIR}/pulse/version.h") + file(STRINGS "${PULSEAUDIO_INCLUDE_DIR}/pulse/version.h" pulse_version_str + REGEX "^#define[\t ]+pa_get_headers_version\\(\\)[\t ]+\\(\".*\"\\)") + + string(REGEX REPLACE "^.*pa_get_headers_version\\(\\)[\t ]+\\(\"([^\"]*)\"\\).*$" "\\1" + PULSEAUDIO_VERSION_STRING "${pulse_version_str}") + unset(pulse_version_str) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PulseAudio + REQUIRED_VARS PULSEAUDIO_LIBRARY PULSEAUDIO_INCLUDE_DIR + VERSION_VAR PULSEAUDIO_VERSION_STRING +) + +if(PULSEAUDIO_FOUND) + set(PULSEAUDIO_LIBRARIES ${PULSEAUDIO_LIBRARY}) + set(PULSEAUDIO_INCLUDE_DIRS ${PULSEAUDIO_INCLUDE_DIR}) +endif() + +mark_as_advanced(PULSEAUDIO_INCLUDE_DIR PULSEAUDIO_LIBRARY) diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index 342aa932bf..a9d0e6ab43 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -96,6 +96,9 @@ include(FindLibc) ## Use pcsx2 package to find module include(Findlibsamplerate) +## Use pcsx2 package to find module +include(FindPulseAudio) + ## Use CheckLib package to find module include(CheckLib) if(Linux) @@ -196,6 +199,11 @@ if(LIBSAMPLERATE_FOUND) include_directories(${LIBSAMPLERATE_INCLUDE_DIR}) endif() +if(PULSEAUDIO_FOUND) + include_directories(${PULSEAUDIO_INCLUDE_DIR}) +endif() + + if(LIBXML2_FOUND) include_directories(${LIBXML2_INCLUDE_DIRS}) endif() diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index 17fc46a6d2..485572c192 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -356,6 +356,25 @@ set(pcsx2USBSources USB/shared/shared.cpp USB/shared/inifile.cpp USB/shared/ringbuffer.cpp + USB/icon_buzz_24.cpp + USB/usb-msd/usb-msd-gtk.cpp + USB/usb-pad/joydev/joydev.cpp + USB/usb-pad/joydev/joydev-gtk.cpp + USB/usb-pad/evdev/shared-gtk.cpp + USB/usb-pad/evdev/evdev-ff.cpp + USB/usb-pad/evdev/evdev.cpp + USB/usb-pad/evdev/evdev-gtk.cpp + USB/usb-hid/evdev/evdev-gtk.cpp + USB/usb-eyetoy/cam-linux.cpp + USB/linux/config.cpp + USB/linux/config-gtk.cpp + USB/linux/util.cpp + USB/qemu-usb/input-keymap-linux-to-qcode.cpp + USB/usb-mic/audiodev-pulse.cpp + USB/usb-pad/api_init_linux.cpp + USB/usb-eyetoy/api_init_linux.cpp + USB/usb-hid/api_init_linux.cpp + USB/usb-mic/api_init_linux.cpp ) # USB headers @@ -400,6 +419,21 @@ set(pcsx2USBHeaders USB/shared/shared.h USB/shared/inifile.h USB/shared/ringbuffer.h + USB/linux/ini.h + USB/linux/actualfile.h + USB/linux/config.h + USB/linux/util.h + USB/gtk.h + USB/icon_buzz_24.h + USB/usb-pad/joydev/joydev.h + USB/usb-pad/evdev/shared.h + USB/usb-pad/evdev/evdev.h + USB/usb-pad/evdev/evdev-ff.h + USB/usb-hid/evdev/evdev.h + USB/usb-hid/evdev/evdev.cpp + USB/usb-eyetoy/cam-linux.h + USB/qemu-usb/input-keymap-linux-to-qcode.h + USB/usb-mic/audiodev-pulse.h ) @@ -903,7 +937,6 @@ set(pcsx2FinalLibs Utilities x86emitter fmt::fmt - libsamplerate ${wxWidgets_LIBRARIES} ${GTK2_LIBRARIES} ${ZLIB_LIBRARIES} @@ -914,6 +947,7 @@ set(pcsx2FinalLibs ${SDL2_LIBRARIES} ${PCAP_LIBRARY} ${LIBSAMPLERATE_LIBRARIES} + ${PULSEAUDIO_LIBRARIES} ${LIBXML2_LIBRARIES} ${Platform_Libs} ) diff --git a/pcsx2/USB/linux/config-gtk.cpp b/pcsx2/USB/linux/config-gtk.cpp index 063e29520b..78eade7644 100644 --- a/pcsx2/USB/linux/config-gtk.cpp +++ b/pcsx2/USB/linux/config-gtk.cpp @@ -5,7 +5,7 @@ #include #include #include -#include "gtk.h" +#include "../gtk.h" #include "../osdebugout.h" #include "../configuration.h" @@ -35,28 +35,6 @@ gboolean run_msg_dialog(gpointer data) return FALSE; } -void SysMessage(const char *fmt, ...) -{ - va_list list; - char msg[1024]; - - va_start (list, fmt); - vsnprintf (msg, sizeof(msg), fmt, list); - va_end (list); - - if (msg[strlen(msg) - 1] == '\n') - msg[strlen(msg) - 1] = 0; - - GtkWidget *dialog; - dialog = gtk_message_dialog_new (NULL, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - "%s", msg); - // run on main thread, a bit iffy - g_idle_add (run_msg_dialog, (gpointer)dialog); -} - static void wheeltypeChanged (GtkComboBox *widget, gpointer data) { gint idx = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); diff --git a/pcsx2/USB/linux/config.h b/pcsx2/USB/linux/config.h index 9cb740b0cf..0952078cc4 100644 --- a/pcsx2/USB/linux/config.h +++ b/pcsx2/USB/linux/config.h @@ -2,6 +2,6 @@ #define LINUXCONFIG_H #include #include -#include "osdebugout.h" +#include "../osdebugout.h" #endif diff --git a/pcsx2/USB/qemu-usb/usb-ohci.cpp b/pcsx2/USB/qemu-usb/usb-ohci.cpp index 628241e5eb..81332ebd13 100644 --- a/pcsx2/USB/qemu-usb/usb-ohci.cpp +++ b/pcsx2/USB/qemu-usb/usb-ohci.cpp @@ -40,9 +40,9 @@ int64_t last_cycle = 0; #define MIN_IRQ_INTERVAL 64 /* hack */ -extern void USBirq(int); extern int64_t get_clock(); extern int get_ticks_per_second(); +extern void usbIrq(int); //#define DEBUG_PACKET //#define DEBUG_OHCI @@ -64,7 +64,7 @@ static inline void ohci_intr_update(OHCIState *ohci) //if ((get_clock() - last_cycle) > MIN_IRQ_INTERVAL) if (ohci->intr_status != OHCI_INTR_WD) //HACK skip first intr with _WD, _SF should follow shortly { - USBirq(1); + usbIrq(1); last_cycle = get_clock(); } } diff --git a/pcsx2/USB/usb-eyetoy/cam-linux.cpp b/pcsx2/USB/usb-eyetoy/cam-linux.cpp index cfb84c9e30..a7d8215ba8 100644 --- a/pcsx2/USB/usb-eyetoy/cam-linux.cpp +++ b/pcsx2/USB/usb-eyetoy/cam-linux.cpp @@ -13,7 +13,7 @@ #include -#include "gtk.h" +#include "../gtk.h" #include "cam-linux.h" #include "usb-eyetoy-webcam.h" diff --git a/pcsx2/USB/usb-hid/evdev/evdev-gtk.cpp b/pcsx2/USB/usb-hid/evdev/evdev-gtk.cpp index e496026abe..e67b0edfd5 100644 --- a/pcsx2/USB/usb-hid/evdev/evdev-gtk.cpp +++ b/pcsx2/USB/usb-hid/evdev/evdev-gtk.cpp @@ -2,7 +2,7 @@ #include "../usb-hid.h" #include "evdev.h" #include -#include "gtk.h" +#include "../../gtk.h" #include #include @@ -171,4 +171,4 @@ int EvDev::Configure(int port, const char* dev_type, HIDType hid_type, void *dat } #undef EVDEV_DIR -}} //namespace \ No newline at end of file +}} //namespace diff --git a/pcsx2/USB/usb-hid/evdev/evdev.cpp b/pcsx2/USB/usb-hid/evdev/evdev.cpp index c00a02882b..aba98aa026 100644 --- a/pcsx2/USB/usb-hid/evdev/evdev.cpp +++ b/pcsx2/USB/usb-hid/evdev/evdev.cpp @@ -1,9 +1,9 @@ #include "evdev.h" -#include "osdebugout.h" +#include "../../osdebugout.h" #include #include #include "../hidproxy.h" -#include "qemu-usb/input-keymap-linux-to-qcode.h" +#include "../../qemu-usb/input-keymap-linux-to-qcode.h" #ifdef USING_X11 #include @@ -324,4 +324,4 @@ void EvDev::ReaderThread(void *ptr) dev->mReaderThreadIsRunning = false; } -}} //namespace \ No newline at end of file +}} //namespace diff --git a/pcsx2/USB/usb-hid/evdev/evdev.h b/pcsx2/USB/usb-hid/evdev/evdev.h index c3eeb8d4d4..127284753a 100644 --- a/pcsx2/USB/usb-hid/evdev/evdev.h +++ b/pcsx2/USB/usb-hid/evdev/evdev.h @@ -1,5 +1,5 @@ #pragma once -#include "linux/util.h" +#include "../../linux/util.h" #include #include #include @@ -68,4 +68,4 @@ bool GetEvdevName(const std::string& path, char (&name)[_Size]) return false; } -}} //namespace \ No newline at end of file +}} //namespace diff --git a/pcsx2/USB/usb-mic/audiodev-pulse.cpp b/pcsx2/USB/usb-mic/audiodev-pulse.cpp index 88c2410954..69d70e461c 100644 --- a/pcsx2/USB/usb-mic/audiodev-pulse.cpp +++ b/pcsx2/USB/usb-mic/audiodev-pulse.cpp @@ -1,4 +1,4 @@ -#include "gtk.h" +#include "../gtk.h" #include "audiodev-pulse.h" #ifdef DYNLINK_PULSE #include "../dynlink/pulse.h" @@ -909,4 +909,4 @@ exit: return; } -}} \ No newline at end of file +}} diff --git a/pcsx2/USB/usb-mic/audiodev-pulse.h b/pcsx2/USB/usb-mic/audiodev-pulse.h index 15024d0756..e146f32bf7 100644 --- a/pcsx2/USB/usb-mic/audiodev-pulse.h +++ b/pcsx2/USB/usb-mic/audiodev-pulse.h @@ -1,10 +1,10 @@ #include #include #include -#include "shared/ringbuffer.h" +#include "../shared/ringbuffer.h" #include "../osdebugout.h" #include "audiodeviceproxy.h" -#include "../libsamplerate/samplerate.h" +#include //#include //#include #include diff --git a/pcsx2/USB/usb-msd/usb-msd-gtk.cpp b/pcsx2/USB/usb-msd/usb-msd-gtk.cpp index f25881abe5..880ae92684 100644 --- a/pcsx2/USB/usb-msd/usb-msd-gtk.cpp +++ b/pcsx2/USB/usb-msd/usb-msd-gtk.cpp @@ -1,7 +1,7 @@ #include "usb-msd.h" #include "../linux/ini.h" #include "../configuration.h" -#include "gtk.h" +#include "../gtk.h" namespace usb_msd { @@ -103,4 +103,4 @@ int MsdDevice::Configure(int port, const std::string& api, void *data) return RESULT_CANCELED; } -} //namespace \ No newline at end of file +} //namespace diff --git a/pcsx2/USB/usb-pad/evdev/evdev-ff.cpp b/pcsx2/USB/usb-pad/evdev/evdev-ff.cpp index 0c946f38a1..0667cf86b4 100644 --- a/pcsx2/USB/usb-pad/evdev/evdev-ff.cpp +++ b/pcsx2/USB/usb-pad/evdev/evdev-ff.cpp @@ -1,6 +1,6 @@ #include "evdev-ff.h" -#include "osdebugout.h" -#include "usb-pad/lg/lg_ff.h" +#include "../../osdebugout.h" +#include "../../usb-pad/lg/lg_ff.h" #include #include #include diff --git a/pcsx2/USB/usb-pad/evdev/evdev-gtk.cpp b/pcsx2/USB/usb-pad/evdev/evdev-gtk.cpp index ef27e42885..23f3f399df 100644 --- a/pcsx2/USB/usb-pad/evdev/evdev-gtk.cpp +++ b/pcsx2/USB/usb-pad/evdev/evdev-gtk.cpp @@ -1,11 +1,11 @@ #include "evdev.h" -#include "osdebugout.h" +#include "../../osdebugout.h" #include #include #include #include -#include "gtk.h" +#include "../../gtk.h" namespace usb_pad { namespace evdev { diff --git a/pcsx2/USB/usb-pad/evdev/evdev.cpp b/pcsx2/USB/usb-pad/evdev/evdev.cpp index fc4ffe6875..9743c29096 100644 --- a/pcsx2/USB/usb-pad/evdev/evdev.cpp +++ b/pcsx2/USB/usb-pad/evdev/evdev.cpp @@ -1,9 +1,9 @@ #include "evdev.h" -#include "osdebugout.h" +#include "../../osdebugout.h" #include #include #include -#include "linux/util.h" +#include "../../linux/util.h" namespace usb_pad { namespace evdev { diff --git a/pcsx2/USB/usb-pad/evdev/evdev.h b/pcsx2/USB/usb-pad/evdev/evdev.h index 201ebc2f5c..09814621e9 100644 --- a/pcsx2/USB/usb-pad/evdev/evdev.h +++ b/pcsx2/USB/usb-pad/evdev/evdev.h @@ -1,12 +1,12 @@ #pragma once -#include "linux/util.h" +#include "../../linux/util.h" //#include //gtk.h pulls in? #include #include #include #include "evdev-ff.h" #include "shared.h" -#include "readerwriterqueue/readerwriterqueue.h" +#include "../../readerwriterqueue/readerwriterqueue.h" namespace usb_pad { namespace evdev { diff --git a/pcsx2/USB/usb-pad/evdev/shared-gtk.cpp b/pcsx2/USB/usb-pad/evdev/shared-gtk.cpp index acabd0ccbd..d666306c6a 100644 --- a/pcsx2/USB/usb-pad/evdev/shared-gtk.cpp +++ b/pcsx2/USB/usb-pad/evdev/shared-gtk.cpp @@ -1,6 +1,6 @@ #include "shared.h" #include "../../osdebugout.h" -#include "icon_buzz_24.h" +#include "../../icon_buzz_24.h" #include #include diff --git a/pcsx2/USB/usb-pad/evdev/shared.h b/pcsx2/USB/usb-pad/evdev/shared.h index 800d3216e8..f78a349462 100644 --- a/pcsx2/USB/usb-pad/evdev/shared.h +++ b/pcsx2/USB/usb-pad/evdev/shared.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include "gtk.h" +#include "../../gtk.h" #include "../padproxy.h" #include "../../configuration.h" diff --git a/pcsx2/USB/usb-pad/joydev/joydev-gtk.cpp b/pcsx2/USB/usb-pad/joydev/joydev-gtk.cpp index 8c8600ee30..5785a1092d 100644 --- a/pcsx2/USB/usb-pad/joydev/joydev-gtk.cpp +++ b/pcsx2/USB/usb-pad/joydev/joydev-gtk.cpp @@ -5,7 +5,7 @@ #include #include #include -#include "gtk.h" +#include "../../gtk.h" namespace usb_pad { namespace joydev { @@ -143,4 +143,4 @@ int JoyDevPad::Configure(int port, const char* dev_type, void *data) return ret; } -}} //namespace \ No newline at end of file +}} //namespace diff --git a/pcsx2/USB/usb-pad/joydev/joydev.cpp b/pcsx2/USB/usb-pad/joydev/joydev.cpp index d61f816856..84b27f022e 100644 --- a/pcsx2/USB/usb-pad/joydev/joydev.cpp +++ b/pcsx2/USB/usb-pad/joydev/joydev.cpp @@ -2,7 +2,7 @@ #include "../../osdebugout.h" #include #include -#include "linux/util.h" +#include "../../linux/util.h" namespace usb_pad { namespace joydev { diff --git a/pcsx2/USB/usb-pad/joydev/joydev.h b/pcsx2/USB/usb-pad/joydev/joydev.h index 5b37e984c8..193ea85507 100644 --- a/pcsx2/USB/usb-pad/joydev/joydev.h +++ b/pcsx2/USB/usb-pad/joydev/joydev.h @@ -1,5 +1,5 @@ #pragma once -#include "linux/util.h" +#include "../../linux/util.h" #include "../evdev/evdev-ff.h" #include "../evdev/shared.h" @@ -57,4 +57,4 @@ bool GetJoystickName(const std::string& path, char (&name)[_Size]) return false; } -}} //namespace \ No newline at end of file +}} //namespace