reduce dreamlink's SDL dependency
This commit is contained in:
parent
1be9722242
commit
53ddbf6e7f
|
@ -9,6 +9,8 @@
|
|||
#include "hw/naomi/card_reader.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
// TODO: should we move these to maple folder?
|
||||
#include <sdl/dreamlink.h>
|
||||
#include <sdl/dreamconn.h>
|
||||
|
||||
|
|
|
@ -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 <cfg/option.h>
|
||||
#include <SDL.h>
|
||||
|
@ -35,7 +35,6 @@
|
|||
#include <windows.h>
|
||||
#include <setupapi.h>
|
||||
#endif
|
||||
#include <hw/maple/maple_if.h>
|
||||
|
||||
// TODO: it doesn't seem sound to assume that only one dreamlink will need reconnecting at a time.
|
||||
std::shared_ptr<DreamLink> dreamlink_needs_reconnect = nullptr;
|
||||
|
@ -217,18 +216,9 @@ void DreamConn::connect() {
|
|||
|
||||
iostream.expires_from_now(std::chrono::duration<u32>::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
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
#pragma once
|
||||
#include "dreamlink.h"
|
||||
|
||||
#ifdef USE_DREAMCASTCONTROLLER
|
||||
|
||||
#include <asio.hpp>
|
||||
#include <mutex>
|
||||
|
||||
|
@ -101,5 +99,3 @@ public:
|
|||
|
||||
void disconnect() override;
|
||||
};
|
||||
|
||||
#endif // USE_DREAMCASTCONTROLLER
|
||||
|
|
|
@ -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<InputMapping> DreamLinkGamepad::getDefaultMapping() {
|
||||
return SDLGamepad::getDefaultMapping();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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 <functional>
|
||||
#include <memory>
|
||||
#include <array>
|
||||
|
||||
#if (defined(_WIN32) || defined(__linux__) || (defined(__APPLE__) && defined(TARGET_OS_MAC))) && !defined(TARGET_UWP)
|
||||
#define USE_DREAMCASTCONTROLLER 1
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
|
||||
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<InputMapping>& 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<std::shared_ptr<DreamLink>> allDreamLinks;
|
||||
void createDreamLinkDevices(std::shared_ptr<DreamLink> dreamlink, bool gameStart);
|
||||
|
|
Loading…
Reference in New Issue