mirror of
https://github.com/niellun/FastCarPlay.git
synced 2026-07-29 09:28:49 +02:00
Added key mappings
This commit is contained in:
@@ -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
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|||||||
@@ -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
@@ -51,32 +51,60 @@ void processKey(Protocol &protocol, SDL_Keysym key, RunParams ¶ms)
|
|||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -30,8 +30,6 @@ public:
|
|||||||
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};
|
||||||
@@ -45,6 +43,11 @@ public:
|
|||||||
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};
|
||||||
|
|||||||
Reference in New Issue
Block a user