Added key mappings

This commit is contained in:
Niellune
2025-06-11 22:34:47 +03:00
parent 5e97501c0c
commit 95a4e29501
5 changed files with 66 additions and 19 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ The project is using make. You can edit ./conf/settings.txt after copy if needed
make clean make clean
make release make release
mkdir ./conf mkdir ./conf
cp ./settings.txt /conf cp ./settings.txt ./conf
./out/app ./conf/settings.txt ./out/app ./conf/settings.txt
``` ```
+8
View File
@@ -134,6 +134,14 @@
#on-connect-script = #on-connect-script =
#on-disconnect-script = #on-disconnect-script =
# Map extra keys for control with there codes
# If you set logging true you and press keys you will see there codes in logs
#key-left = 0
#key-right = 0
#key-enter = 0
#key-back = 0
#key-home = 0
############################################################################## ##############################################################################
# 4.Debug # 4.Debug
############################################################################## ##############################################################################
+8
View File
@@ -35,6 +35,14 @@
#define CMD_VERSION 204 #define CMD_VERSION 204
#define CMD_ENCRYPTION 240 #define CMD_ENCRYPTION 240
#define BTN_LEFT 100
#define BTN_RIGHT 101
#define BTN_SELECT_DOWN 104
#define BTN_SELECT_UP 105
#define BTN_BACK 106
#define BTN_HOME 200
#define AUDIO_BUFFER_SIZE 2560 #define AUDIO_BUFFER_SIZE 2560
#define AUDIO_BUFFER_OFFSET 12 #define AUDIO_BUFFER_OFFSET 12
+40 -12
View File
@@ -51,32 +51,60 @@ void processKey(Protocol &protocol, SDL_Keysym key, RunParams &params)
params.fullscreen = !params.fullscreen; // Toggle fullscreen mode params.fullscreen = !params.fullscreen; // Toggle fullscreen mode
SDL_SetWindowFullscreen(window, params.fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); SDL_SetWindowFullscreen(window, params.fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
SDL_SetWindowBordered(window, params.fullscreen ? SDL_FALSE : SDL_TRUE); SDL_SetWindowBordered(window, params.fullscreen ? SDL_FALSE : SDL_TRUE);
break; return;
case SDLK_q: case SDLK_q:
active = false; active = false;
break; return;
case SDLK_r: case SDLK_r:
params.dirty = true; params.dirty = true;
break; return;
case SDLK_LEFT: case SDLK_LEFT:
protocol.sendKey(100); protocol.sendKey(BTN_LEFT);
break; return;
case SDLK_RIGHT: case SDLK_RIGHT:
protocol.sendKey(101); protocol.sendKey(BTN_RIGHT);
break; return;
case SDLK_RETURN: case SDLK_RETURN:
protocol.sendKey(104); protocol.sendKey(BTN_SELECT_DOWN);
protocol.sendKey(105); protocol.sendKey(BTN_SELECT_UP);
break; return;
case SDLK_BACKSPACE: case SDLK_BACKSPACE:
protocol.sendKey(106); protocol.sendKey(BTN_BACK);
break; return;
case 0:
return;
}
if (key.sym == Settings::keyLeft)
{
protocol.sendKey(BTN_LEFT);
}
else if (key.sym == Settings::keyRight)
{
protocol.sendKey(BTN_RIGHT);
}
else if (key.sym == Settings::keyEnter)
{
protocol.sendKey(BTN_SELECT_DOWN);
protocol.sendKey(BTN_SELECT_UP);
}
else if (key.sym == Settings::keyBack)
{
protocol.sendKey(BTN_BACK);
}
else if (key.sym == Settings::keyHome)
{
protocol.sendKey(BTN_HOME);
} else
{
std::cout << "[Key] Unmapped key " << key.sym << std::endl;
} }
} }
+9 -6
View File
@@ -26,13 +26,11 @@ public:
static inline Setting<bool> wifi5{"wifi-5", true}; static inline Setting<bool> wifi5{"wifi-5", true};
static inline Setting<bool> bluetoothAudio{"bluetooth-audio", false}; static inline Setting<bool> bluetoothAudio{"bluetooth-audio", false};
static inline Setting<int> micType{"mic-type", 1}; static inline Setting<int> micType{"mic-type", 1};
static inline Setting<int> dpi{"android-dpi", 120}; static inline Setting<int> dpi{"android-dpi", 120};
static inline Setting<int> androidMode{"android-resolution", 0}; static inline Setting<int> androidMode{"android-resolution", 0};
static inline Setting<int> mediaDelay{"android-media-delay", 300}; static inline Setting<int> mediaDelay{"android-media-delay", 300};
// Application configuration section
// Application configuration section
static inline Setting<int> fontSize{"font-size", 30}; static inline Setting<int> fontSize{"font-size", 30};
static inline Setting<bool> vsync{"vsync", false}; static inline Setting<bool> vsync{"vsync", false};
static inline Setting<float> aspectCorrection{"aspect-correction", 1}; static inline Setting<float> aspectCorrection{"aspect-correction", 1};
@@ -40,11 +38,16 @@ public:
static inline Setting<int> videoQueue{"video-buffer-size", 32}; static inline Setting<int> videoQueue{"video-buffer-size", 32};
static inline Setting<int> audioQueue{"audio-buffer-size", 16}; static inline Setting<int> audioQueue{"audio-buffer-size", 16};
static inline Setting<int> audioDelay{"audio-buffer-wait", 2}; static inline Setting<int> audioDelay{"audio-buffer-wait", 2};
static inline Setting<int> audioDelayCall{"audio-buffer-wait-call", 8}; static inline Setting<int> audioDelayCall{"audio-buffer-wait-call", 8};
static inline Setting<float> audioFade{"audio-fade", 0.3}; static inline Setting<float> audioFade{"audio-fade", 0.3};
static inline Setting<std::string> audioDriver{"audio-driver", ""}; static inline Setting<std::string> audioDriver{"audio-driver", ""};
static inline Setting<std::string> onConnect{"on-connect-script", ""}; static inline Setting<std::string> onConnect{"on-connect-script", ""};
static inline Setting<std::string> onDisconnect{"on-disconnect-script", ""}; static inline Setting<std::string> onDisconnect{"on-disconnect-script", ""};
static inline Setting<int> keyLeft{"key-left", 0};
static inline Setting<int> keyRight{"key-right", 0};
static inline Setting<int> keyEnter{"key-enter", 0};
static inline Setting<int> keyBack{"key-back", 0};
static inline Setting<int> keyHome{"key-home", 0};
// Debug section // Debug section
static inline Setting<int> protocolDebug{"protocol-debug", 0}; static inline Setting<int> protocolDebug{"protocol-debug", 0};