diff --git a/core/hw/maple/maple_if.cpp b/core/hw/maple/maple_if.cpp index e2defde0c..a8f76ab06 100644 --- a/core/hw/maple/maple_if.cpp +++ b/core/hw/maple/maple_if.cpp @@ -9,6 +9,8 @@ #include "hw/naomi/card_reader.h" #include + +// TODO: should we move these to maple folder? #include #include diff --git a/core/sdl/dreamconn.cpp b/core/sdl/dreamconn.cpp index a108f6479..bef379c69 100644 --- a/core/sdl/dreamconn.cpp +++ b/core/sdl/dreamconn.cpp @@ -18,8 +18,8 @@ */ #include "dreamconn.h" -#ifdef USE_DREAMCASTCONTROLLER #include "hw/maple/maple_devs.h" +#include "hw/maple/maple_if.h" #include "ui/gui.h" #include #include @@ -35,7 +35,6 @@ #include #include #endif -#include // TODO: it doesn't seem sound to assume that only one dreamlink will need reconnecting at a time. std::shared_ptr dreamlink_needs_reconnect = nullptr; @@ -217,18 +216,9 @@ void DreamConn::connect() { iostream.expires_from_now(std::chrono::duration::max()); // don't use a 64-bit based duration to avoid overflow - // TODO: unsure whether to adjust or to delete this condition. We need to stay connected to be notified if a peripheral gets plugged back in later on - if (true || (hasVmu() || hasRumble())) - { - NOTICE_LOG(INPUT, "Connected to DreamcastController[%d]: Type:%s, VMU:%d, Rumble Pack:%d", bus, getName().c_str(), hasVmu(), hasRumble()); - maple_io_connected = true; - } - else - { - WARN_LOG(INPUT, "DreamcastController[%d] connection: no VMU or Rumble Pack connected", bus); - disconnect(); - return; - } + // Remain connected even if no devices were found, so that plugging one in later will be detected + NOTICE_LOG(INPUT, "Connected to DreamcastController[%d]: Type:%s, VMU:%d, Rumble Pack:%d", bus, getName().c_str(), hasVmu(), hasRumble()); + maple_io_connected = true; } void DreamConn::disconnect() { @@ -239,5 +229,3 @@ void DreamConn::disconnect() { NOTICE_LOG(INPUT, "Disconnected from DreamcastController[%d]", bus); } - -#endif diff --git a/core/sdl/dreamconn.h b/core/sdl/dreamconn.h index 3759181e6..497586c73 100644 --- a/core/sdl/dreamconn.h +++ b/core/sdl/dreamconn.h @@ -19,8 +19,6 @@ #pragma once #include "dreamlink.h" -#ifdef USE_DREAMCASTCONTROLLER - #include #include @@ -101,5 +99,3 @@ public: void disconnect() override; }; - -#endif // USE_DREAMCASTCONTROLLER diff --git a/core/sdl/dreamlink.cpp b/core/sdl/dreamlink.cpp index 5e7f83043..ceea249ba 100644 --- a/core/sdl/dreamlink.cpp +++ b/core/sdl/dreamlink.cpp @@ -242,39 +242,4 @@ void DreamLinkGamepad::checkKeyCombo() { if (ltrigPressed && rtrigPressed && startPressed) gui_open_settings(); } - -#else // USE_DREAMCASTCONTROLLER - -bool DreamLinkGamepad::isDreamcastController(int deviceIndex) { - return false; -} -DreamLinkGamepad::DreamLinkGamepad(int maple_port, int joystick_idx, SDL_Joystick* sdl_joystick) - : SDLGamepad(maple_port, joystick_idx, sdl_joystick) { -} -DreamLinkGamepad::~DreamLinkGamepad() { -} -void DreamLinkGamepad::set_maple_port(int port) { - SDLGamepad::set_maple_port(port); -} -void DreamLinkGamepad::registered() { -} -bool DreamLinkGamepad::gamepad_btn_input(u32 code, bool pressed) { - return SDLGamepad::gamepad_btn_input(code, pressed); -} -bool DreamLinkGamepad::gamepad_axis_input(u32 code, int value) { - return SDLGamepad::gamepad_axis_input(code, value); -} -void DreamLinkGamepad::resetMappingToDefault(bool arcade, bool gamepad) { - SDLGamepad::resetMappingToDefault(arcade, gamepad); -} -const char *DreamLinkGamepad::get_button_name(u32 code) { - return SDLGamepad::get_button_name(code); -} -const char *DreamLinkGamepad::get_axis_name(u32 code) { - return SDLGamepad::get_axis_name(code); -} -std::shared_ptr DreamLinkGamepad::getDefaultMapping() { - return SDLGamepad::getDefaultMapping(); -} - #endif diff --git a/core/sdl/dreamlink.h b/core/sdl/dreamlink.h index 4bcad3742..5503d8897 100644 --- a/core/sdl/dreamlink.h +++ b/core/sdl/dreamlink.h @@ -18,22 +18,21 @@ */ #pragma once -// This file contains abstraction layer for access to different kinds of physical controllers +// This file contains abstraction layer for access to different kinds of remote peripherals. +// This includes both real Dreamcast controllers, VMUs, rumble packs etc. but also emulated VMUs. #include "types.h" #include "emulator.h" + +#if (defined(_WIN32) || defined(__linux__) || (defined(__APPLE__) && defined(TARGET_OS_MAC))) && !defined(TARGET_UWP) && defined(USE_SDL) +#define USE_DREAMCASTCONTROLLER 1 #include "sdl_gamepad.h" +#endif #include #include #include -#if (defined(_WIN32) || defined(__linux__) || (defined(__APPLE__) && defined(TARGET_OS_MAC))) && !defined(TARGET_UWP) -#define USE_DREAMCASTCONTROLLER 1 -#endif - -#include - struct MapleMsg { u8 command = 0; @@ -96,9 +95,11 @@ public: return -1; } +#if defined(USE_DREAMCASTCONTROLLER) //! Allows a DreamLink device to dictate the default mapping virtual void setDefaultMapping(const std::shared_ptr& mapping) const { } +#endif //! Allows button names to be defined by a DreamLink device //! @param[in] code The button code to retrieve name of @@ -140,6 +141,7 @@ public: virtual void disconnect() = 0; }; +#if defined(USE_DREAMCASTCONTROLLER) class DreamLinkGamepad : public SDLGamepad { public: @@ -168,6 +170,7 @@ private: bool startPressed = false; std::string device_guid; }; +#endif extern std::vector> allDreamLinks; void createDreamLinkDevices(std::shared_ptr dreamlink, bool gameStart);