Fix DolphinSA Hotkeys
This commit is contained in:
parent
b1490f3390
commit
df54c288c8
7 changed files with 132 additions and 7718 deletions
|
@ -6,6 +6,7 @@ Buttons/Start = Button 7
|
|||
Buttons/X = Button 3
|
||||
Buttons/Y = Button 2
|
||||
Buttons/Z = Button 5
|
||||
Buttons/Hotkey = Button 6
|
||||
C-Stick/Dead Zone = 25.000000000000000
|
||||
C-Stick/Down = Axis 4+
|
||||
C-Stick/Left = Axis 3-
|
||||
|
|
|
@ -58,7 +58,8 @@ PKG_CMAKE_OPTS_TARGET+=" -DENABLE_HEADLESS=ON \
|
|||
-DENABLE_ANALYTICS=OFF \
|
||||
-DENABLE_LTO=ON \
|
||||
-DENABLE_QT=OFF \
|
||||
-DENCODE_FRAMEDUMPS=OFF"
|
||||
-DENCODE_FRAMEDUMPS=OFF \
|
||||
-DENABLE_CLI_TOOL=OFF"
|
||||
|
||||
makeinstall_target() {
|
||||
mkdir -p ${INSTALL}/usr/bin
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,129 @@
|
|||
diff --git a/Source/Core/Core/HW/GCPadEmu.cpp b/Source/Core/Core/HW/GCPadEmu.cpp
|
||||
index c8e7016..fb089c4 100644
|
||||
--- a/Source/Core/Core/HW/GCPadEmu.cpp
|
||||
+++ b/Source/Core/Core/HW/GCPadEmu.cpp
|
||||
@@ -26,6 +26,7 @@ static const u16 button_bitmasks[] = {
|
||||
PAD_BUTTON_Y,
|
||||
PAD_TRIGGER_Z,
|
||||
PAD_BUTTON_START,
|
||||
+ PAD_BUTTON_HOTKEY,
|
||||
0 // MIC HAX
|
||||
};
|
||||
|
||||
@@ -37,7 +38,7 @@ static const u16 trigger_bitmasks[] = {
|
||||
static const u16 dpad_bitmasks[] = {PAD_BUTTON_UP, PAD_BUTTON_DOWN, PAD_BUTTON_LEFT,
|
||||
PAD_BUTTON_RIGHT};
|
||||
|
||||
-static const char* const named_buttons[] = {"A", "B", "X", "Y", "Z", "Start"};
|
||||
+static const char* const named_buttons[] = {"A", "B", "X", "Y", "Z", "Start", "Hotkey"};
|
||||
|
||||
static const char* const named_triggers[] = {
|
||||
// i18n: The left trigger button (labeled L on real controllers)
|
||||
diff --git a/Source/Core/DolphinNoGUI/PlatformX11.cpp b/Source/Core/DolphinNoGUI/PlatformX11.cpp
|
||||
index 8dcd93bf52..5d7386da38 100644
|
||||
--- a/Source/Core/DolphinNoGUI/PlatformX11.cpp
|
||||
+++ b/Source/Core/DolphinNoGUI/PlatformX11.cpp
|
||||
@@ -16,6 +16,12 @@ static constexpr auto X_None = None;
|
||||
#include "Core/Core.h"
|
||||
#include "Core/State.h"
|
||||
|
||||
+#include "Core/HW/GCPad.h"
|
||||
+#include "InputCommon/GCPadStatus.h"
|
||||
+#include <fmt/format.h>
|
||||
+#include "Core/Config/GraphicsSettings.h"
|
||||
+#include "VideoCommon/VideoConfig.h"
|
||||
+
|
||||
#include <climits>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
@@ -149,11 +155,78 @@ void PlatformX11::MainLoop()
|
||||
{
|
||||
while (IsRunning())
|
||||
{
|
||||
+ static int hotkey = 0;
|
||||
+ static int slot = 0;
|
||||
+ static int fps = 0;
|
||||
+ static int aspect = 0;
|
||||
+
|
||||
UpdateRunningFlag();
|
||||
Core::HostDispatchJobs();
|
||||
ProcessEvents();
|
||||
UpdateWindowPosition();
|
||||
|
||||
+ if(Pad::IsInitialized()) {
|
||||
+ GCPadStatus x = Pad::GetStatus(0);
|
||||
+
|
||||
+ if( (x.button & PAD_BUTTON_HOTKEY) == PAD_BUTTON_HOTKEY) { // hotkey pressed
|
||||
+ if(hotkey == 1) {
|
||||
+ hotkey = 2;
|
||||
+ }
|
||||
+ } else {
|
||||
+ hotkey = 1; // assure hotkey is released between actions
|
||||
+ }
|
||||
+
|
||||
+ if(hotkey == 2) { // hotkey pressed
|
||||
+ if( (x.button & PAD_BUTTON_START) == PAD_BUTTON_START) {
|
||||
+ RequestShutdown();
|
||||
+ hotkey = 0;
|
||||
+ }
|
||||
+
|
||||
+ if( (x.button & PAD_TRIGGER_L) == PAD_TRIGGER_L) {
|
||||
+ State::Load(slot);
|
||||
+ hotkey = 0;
|
||||
+ }
|
||||
+ if( (x.button & PAD_TRIGGER_R) == PAD_TRIGGER_R) {
|
||||
+ State::Save(slot);
|
||||
+ hotkey = 0;
|
||||
+ }
|
||||
+ if( (x.button & PAD_BUTTON_DOWN) == PAD_BUTTON_DOWN) {
|
||||
+ if(slot > 0) slot--;
|
||||
+ Core::DisplayMessage(fmt::format("Slot {} selected", slot), 4000);
|
||||
+ hotkey = 0;
|
||||
+ }
|
||||
+ if( (x.button & PAD_BUTTON_UP) == PAD_BUTTON_UP) {
|
||||
+ if(slot < 10) slot++;
|
||||
+ Core::DisplayMessage(fmt::format("Slot {} selected", slot), 4000);
|
||||
+ hotkey = 0;
|
||||
+ }
|
||||
+ if( (x.button & PAD_BUTTON_A) == PAD_BUTTON_A) {
|
||||
+ Core::SaveScreenShot();
|
||||
+ hotkey = 0;
|
||||
+ }
|
||||
+ if( (x.button & PAD_BUTTON_Y) == PAD_BUTTON_Y) {
|
||||
+ if(fps == 0) {
|
||||
+ Config::SetCurrent(Config::GFX_SHOW_FPS, True);
|
||||
+ fps = 1;
|
||||
+ } else {
|
||||
+ Config::SetCurrent(Config::GFX_SHOW_FPS, False);
|
||||
+ fps = 0;
|
||||
+ }
|
||||
+ hotkey = 0;
|
||||
+ }
|
||||
+ if( (x.button & PAD_BUTTON_X) == PAD_BUTTON_X) {
|
||||
+ if(aspect == 0) {
|
||||
+ Config::SetCurrent(Config::GFX_ASPECT_RATIO, AspectMode::Stretch);
|
||||
+ aspect = 1;
|
||||
+ } else {
|
||||
+ Config::SetCurrent(Config::GFX_ASPECT_RATIO, AspectMode::Auto);
|
||||
+ aspect = 0;
|
||||
+ }
|
||||
+ hotkey = 0;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
// TODO: Is this sleep appropriate?
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
diff --git a/Source/Core/InputCommon/GCPadStatus.h b/Source/Core/InputCommon/GCPadStatus.h
|
||||
index 7da1bbd..57d294d 100644
|
||||
--- a/Source/Core/InputCommon/GCPadStatus.h
|
||||
+++ b/Source/Core/InputCommon/GCPadStatus.h
|
||||
@@ -27,6 +27,7 @@ enum PadButton
|
||||
PAD_BUTTON_X = 0x0400,
|
||||
PAD_BUTTON_Y = 0x0800,
|
||||
PAD_BUTTON_START = 0x1000,
|
||||
+ PAD_BUTTON_HOTKEY = 0x2000,
|
||||
};
|
||||
|
||||
struct GCPadStatus
|
|
@ -1,118 +0,0 @@
|
|||
diff --git a/Source/Core/Core/HW/GCPadEmu.cpp b/Source/Core/Core/HW/GCPadEmu.cpp
|
||||
index c8e7016..fb089c4 100644
|
||||
--- a/Source/Core/Core/HW/GCPadEmu.cpp
|
||||
+++ b/Source/Core/Core/HW/GCPadEmu.cpp
|
||||
@@ -26,6 +26,7 @@ static const u16 button_bitmasks[] = {
|
||||
PAD_BUTTON_Y,
|
||||
PAD_TRIGGER_Z,
|
||||
PAD_BUTTON_START,
|
||||
+ PAD_BUTTON_HOTKEY,
|
||||
0 // MIC HAX
|
||||
};
|
||||
|
||||
@@ -37,7 +38,7 @@ static const u16 trigger_bitmasks[] = {
|
||||
static const u16 dpad_bitmasks[] = {PAD_BUTTON_UP, PAD_BUTTON_DOWN, PAD_BUTTON_LEFT,
|
||||
PAD_BUTTON_RIGHT};
|
||||
|
||||
-static const char* const named_buttons[] = {"A", "B", "X", "Y", "Z", "Start"};
|
||||
+static const char* const named_buttons[] = {"A", "B", "X", "Y", "Z", "Start", "Hotkey"};
|
||||
|
||||
static const char* const named_triggers[] = {
|
||||
// i18n: The left trigger button (labeled L on real controllers)
|
||||
diff --git a/Source/Core/DolphinNoGUI/PlatformDRM.cpp b/Source/Core/DolphinNoGUI/PlatformDRM.cpp
|
||||
index b210cea..77d4e86 100644
|
||||
--- a/Source/Core/DolphinNoGUI/PlatformDRM.cpp
|
||||
+++ b/Source/Core/DolphinNoGUI/PlatformDRM.cpp
|
||||
@@ -11,6 +11,12 @@
|
||||
#include "Core/Core.h"
|
||||
#include "Core/State.h"
|
||||
|
||||
+#include "Core/HW/GCPad.h"
|
||||
+#include "InputCommon/GCPadStatus.h"
|
||||
+#include <fmt/format.h>
|
||||
+#include "Core/Config/GraphicsSettings.h"
|
||||
+#include "VideoCommon/VideoConfig.h"
|
||||
+
|
||||
#include <climits>
|
||||
#include <cstdio>
|
||||
|
||||
@@ -54,9 +60,67 @@ void PlatformDRM::MainLoop()
|
||||
{
|
||||
while (IsRunning())
|
||||
{
|
||||
+ static int hotkey = 0;
|
||||
+ static int slot = 0;
|
||||
+ static int stereo = 0;
|
||||
+
|
||||
UpdateRunningFlag();
|
||||
Core::HostDispatchJobs();
|
||||
|
||||
+ if(Pad::IsInitialized()) {
|
||||
+ GCPadStatus x = Pad::GetStatus(0);
|
||||
+
|
||||
+ if( (x.button & PAD_BUTTON_HOTKEY) == PAD_BUTTON_HOTKEY) { // hotkey pressed
|
||||
+ if(hotkey == 1) {
|
||||
+ hotkey = 2;
|
||||
+ }
|
||||
+ } else {
|
||||
+ hotkey = 1; // assure hotkey is released between actions
|
||||
+ }
|
||||
+
|
||||
+ if(hotkey == 2) { // hotkey pressed
|
||||
+ if( (x.button & PAD_BUTTON_START) == PAD_BUTTON_START) {
|
||||
+ RequestShutdown();
|
||||
+ hotkey = 0;
|
||||
+ }
|
||||
+
|
||||
+ if( (x.button & PAD_BUTTON_Y) == PAD_BUTTON_Y) {
|
||||
+ State::Load(slot);
|
||||
+ hotkey = 0;
|
||||
+ }
|
||||
+ if( (x.button & PAD_BUTTON_B) == PAD_BUTTON_B) {
|
||||
+ State::Save(slot);
|
||||
+ hotkey = 0;
|
||||
+ }
|
||||
+ if( (x.button & PAD_BUTTON_DOWN) == PAD_BUTTON_DOWN) {
|
||||
+ if(slot > 0) slot--;
|
||||
+ Core::DisplayMessage(fmt::format("Slot {} selected", slot), 4000);
|
||||
+ hotkey = 0;
|
||||
+ }
|
||||
+ if( (x.button & PAD_BUTTON_UP) == PAD_BUTTON_UP) {
|
||||
+ if(slot < 10) slot++;
|
||||
+ Core::DisplayMessage(fmt::format("Slot {} selected", slot), 4000);
|
||||
+ hotkey = 0;
|
||||
+ }
|
||||
+ if( (x.button & PAD_TRIGGER_L) == PAD_TRIGGER_L) {
|
||||
+ Core::SaveScreenShot();
|
||||
+ hotkey = 0;
|
||||
+ }
|
||||
+ if( (x.button & PAD_TRIGGER_R) == PAD_TRIGGER_R) {
|
||||
+ if(stereo == 0) {
|
||||
+ Config::SetCurrent(Config::GFX_STEREO_MODE, StereoMode::SBS);
|
||||
+ stereo = 1;
|
||||
+ } else {
|
||||
+ Config::SetCurrent(Config::GFX_STEREO_MODE, StereoMode::Off);
|
||||
+ stereo = 0;
|
||||
+ }
|
||||
+ hotkey = 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+ //
|
||||
+
|
||||
// TODO: Is this sleep appropriate?
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
diff --git a/Source/Core/InputCommon/GCPadStatus.h b/Source/Core/InputCommon/GCPadStatus.h
|
||||
index 7da1bbd..57d294d 100644
|
||||
--- a/Source/Core/InputCommon/GCPadStatus.h
|
||||
+++ b/Source/Core/InputCommon/GCPadStatus.h
|
||||
@@ -27,6 +27,7 @@ enum PadButton
|
||||
PAD_BUTTON_X = 0x0400,
|
||||
PAD_BUTTON_Y = 0x0800,
|
||||
PAD_BUTTON_START = 0x1000,
|
||||
+ PAD_BUTTON_HOTKEY = 0x2000,
|
||||
};
|
||||
|
||||
struct GCPadStatus
|
|
@ -1,56 +0,0 @@
|
|||
diff --git a/Source/Core/Common/GL/GLInterface/EGLDRM.cpp b/Source/Core/Common/GL/GLInterface/EGLDRM.cpp
|
||||
index f848761..676c886 100644
|
||||
--- a/Source/Core/Common/GL/GLInterface/EGLDRM.cpp
|
||||
+++ b/Source/Core/Common/GL/GLInterface/EGLDRM.cpp
|
||||
@@ -819,37 +819,24 @@ static bool gfx_ctx_drm_set_video_mode(void* data, unsigned width, unsigned heig
|
||||
if (!drm)
|
||||
return false;
|
||||
|
||||
- /* Find desired video mode, and use that.
|
||||
- * If not fullscreen, we get desired windowed size,
|
||||
- * which is not appropriate. */
|
||||
- if ((width == 0 && height == 0) || !fullscreen)
|
||||
- drm->drm_mode = &drm->drm_connector->modes[0];
|
||||
- else
|
||||
+ // batocera - set resolution
|
||||
{
|
||||
- /* Try to match refresh_rate as closely as possible.
|
||||
- *
|
||||
- * Lower resolutions tend to have multiple supported
|
||||
- * refresh rates as well.
|
||||
- */
|
||||
- float minimum_fps_diff = 0.0f;
|
||||
-
|
||||
- /* Find best match. */
|
||||
- for (i = 0; i < drm->drm_connector->count_modes; i++)
|
||||
- {
|
||||
- float diff;
|
||||
- if (width != drm->drm_connector->modes[i].hdisplay ||
|
||||
- height != drm->drm_connector->modes[i].vdisplay)
|
||||
- continue;
|
||||
-
|
||||
- diff = fabsf(drm->drm_connector->modes[i].vrefresh - video_refresh_rate);
|
||||
-
|
||||
- if (!drm->drm_mode || diff < minimum_fps_diff)
|
||||
- {
|
||||
- drm->drm_mode = &drm->drm_connector->modes[i];
|
||||
- minimum_fps_diff = diff;
|
||||
+ FILE* fdDrmMode;
|
||||
+ int drmMode;
|
||||
+ if((fdDrmMode = fopen("/var/run/drmMode", "r")) != NULL) {
|
||||
+ if(fscanf(fdDrmMode, "%i", &drmMode) == 1) {
|
||||
+ if(drmMode>=0 && drmMode<drm->drm_connector->count_modes) {
|
||||
+ drmModeCrtc *pcrtc = drmModeGetCrtc(drm->drm_fd, drm->drm_encoder->crtc_id);
|
||||
+ if(pcrtc != NULL) {
|
||||
+ drmModeSetCrtc(drm->drm_fd, pcrtc->crtc_id, pcrtc->buffer_id, 0, 0, &drm->drm_connector->connector_id, 1, &drm->drm_connector->modes[drmMode]);
|
||||
+ drm->drm_mode = &drm->drm_connector->modes[drmMode];
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
+ fclose(fdDrmMode);
|
||||
}
|
||||
}
|
||||
+ //
|
||||
|
||||
if (!drm->drm_mode)
|
||||
{
|
|
@ -1,48 +0,0 @@
|
|||
diff --git a/Source/Core/Common/GL/GLInterface/EGLDRM.cpp b/Source/Core/Common/GL/GLInterface/EGLDRM.cpp
|
||||
index 55efc47..b96768f 100644
|
||||
--- a/Source/Core/Common/GL/GLInterface/EGLDRM.cpp
|
||||
+++ b/Source/Core/Common/GL/GLInterface/EGLDRM.cpp
|
||||
@@ -371,14 +371,33 @@ static bool drm_get_connector(GFXContextDRMData* drm, int fd)
|
||||
unsigned i;
|
||||
unsigned monitor_index_count = 0;
|
||||
unsigned monitor = 1;
|
||||
+ int drmConn = 0;
|
||||
|
||||
/* Enumerate all connectors. */
|
||||
|
||||
INFO_LOG(VIDEO, "[DRM]: Found %d connectors.\n", drm->drm_resources->count_connectors);
|
||||
|
||||
+ // batocera
|
||||
+ {
|
||||
+ FILE* fdDrmConn;
|
||||
+ int drmConnRead;
|
||||
+ if((fdDrmConn = fopen("/var/run/drmConn", "r")) != NULL) {
|
||||
+ if(fscanf(fdDrmConn, "%i", &drmConnRead) == 1) {
|
||||
+ if(drmConnRead>=0 && drmConn<drm->drm_resources->count_connectors) {
|
||||
+ drmConn = drmConnRead;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ //
|
||||
+
|
||||
for (i = 0; (int)i < drm->drm_resources->count_connectors; i++)
|
||||
{
|
||||
- drmModeConnectorPtr conn = drmModeGetConnector(fd, drm->drm_resources->connectors[i]);
|
||||
+ drmModeConnectorPtr conn;
|
||||
+
|
||||
+ if(i != drmConn) continue;
|
||||
+
|
||||
+ conn = drmModeGetConnector(fd, drm->drm_resources->connectors[i]);
|
||||
|
||||
if (conn)
|
||||
{
|
||||
@@ -399,6 +418,8 @@ static bool drm_get_connector(GFXContextDRMData* drm, int fd)
|
||||
|
||||
for (i = 0; (int)i < drm->drm_resources->count_connectors; i++)
|
||||
{
|
||||
+ if(i != drmConn) continue;
|
||||
+
|
||||
drm->drm_connector = drmModeGetConnector(fd, drm->drm_resources->connectors[i]);
|
||||
|
||||
if (!drm->drm_connector)
|
Loading…
Reference in a new issue