Skip to content

Commit

Permalink
dreamconn: open pause menu when LT+RT+Start is pressed
Browse files Browse the repository at this point in the history
Issue #1305
  • Loading branch information
flyinghead committed Dec 28, 2024
1 parent 10aaec1 commit ee1a716
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
48 changes: 48 additions & 0 deletions core/sdl/dreamconn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#ifdef USE_DREAMCONN
#include "hw/maple/maple_devs.h"
#include "ui/gui.h"
#include <cfg/option.h>
#include <SDL.h>
#include <asio.hpp>
Expand Down Expand Up @@ -156,6 +157,47 @@ void DreamConnGamepad::handleEvent(Event event, void *arg)
createDreamConnDevices(gamepad->dreamconn, event == Event::Start);
}

bool DreamConnGamepad::gamepad_btn_input(u32 code, bool pressed)
{
if (!is_detecting_input() && input_mapper)
{
DreamcastKey key = input_mapper->get_button_id(0, code);
if (key == DC_BTN_START) {
startPressed = pressed;
checkKeyCombo();
}
}
else {
startPressed = false;
}
return SDLGamepad::gamepad_btn_input(code, pressed);
}

bool DreamConnGamepad::gamepad_axis_input(u32 code, int value)
{
if (!is_detecting_input())
{
if (code == leftTrigger) {
ltrigPressed = value > 0;
checkKeyCombo();
}
else if (code == rightTrigger) {
rtrigPressed = value > 0;
checkKeyCombo();
}
}
else {
ltrigPressed = false;
rtrigPressed = false;
}
return SDLGamepad::gamepad_axis_input(code, value);
}

void DreamConnGamepad::checkKeyCombo() {
if (ltrigPressed && rtrigPressed && startPressed)
gui_open_settings();
}

#else

void DreamConn::connect() {
Expand All @@ -174,4 +216,10 @@ DreamConnGamepad::~DreamConnGamepad() {
void DreamConnGamepad::set_maple_port(int port) {
SDLGamepad::set_maple_port(port);
}
bool DreamConnGamepad::gamepad_btn_input(u32 code, bool pressed) {
return SDLGamepad::gamepad_btn_input(code, pressed);
}
bool DreamConnGamepad::gamepad_axis_input(u32 code, int value) {
return SDLGamepad::gamepad_axis_input(code, value);
}
#endif
6 changes: 6 additions & 0 deletions core/sdl/dreamconn.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,16 @@ class DreamConnGamepad : public SDLGamepad
~DreamConnGamepad();

void set_maple_port(int port) override;
bool gamepad_btn_input(u32 code, bool pressed) override;
bool gamepad_axis_input(u32 code, int value) override;
static bool isDreamConn(int deviceIndex);

private:
static void handleEvent(Event event, void *arg);
void checkKeyCombo();

std::shared_ptr<DreamConn> dreamconn;
bool ltrigPressed = false;
bool rtrigPressed = false;
bool startPressed = false;
};

0 comments on commit ee1a716

Please sign in to comment.