Add UI to configure keyboard-to-controller mapping (#308)

* Add UI to configure keyboard-to-controller mapping

* Add an optional "---fix" argument to format-checking script

* clang fix

---------

Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
This commit is contained in:
Vasyl_Baran 2024-09-11 08:51:18 +03:00 committed by GitHub
parent 74c2888aaa
commit fdb13a3b90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 1436 additions and 173 deletions

View file

@ -3,8 +3,10 @@
#pragma once
#include <map>
#include <string>
#include "common/types.h"
#include "input/keys_constants.h"
struct SDL_Window;
struct SDL_Gamepad;
@ -12,7 +14,8 @@ union SDL_Event;
namespace Input {
class GameController;
}
enum class Axis;
} // namespace Input
namespace Frontend {
@ -68,6 +71,8 @@ public:
void waitEvent();
void setKeysBindingsMap(const std::map<u32, KeysMapping>& bindingsMap);
private:
void onResize();
void onKeyPress(const SDL_Event* event);
@ -75,12 +80,34 @@ private:
int sdlGamepadToOrbisButton(u8 button);
void handleR2Key(const SDL_Event* event, u32& button, Input::Axis& axis, int& axisvalue,
int& ax);
void handleL2Key(const SDL_Event* event, u32& button, Input::Axis& axis, int& axisvalue,
int& ax);
void handleLAnalogRightKey(const SDL_Event* event, u32& button, Input::Axis& axis,
int& axisvalue, int& ax);
void handleLAnalogLeftKey(const SDL_Event* event, u32& button, Input::Axis& axis,
int& axisvalue, int& ax);
void handleLAnalogUpKey(const SDL_Event* event, u32& button, Input::Axis& axis, int& axisvalue,
int& ax);
void handleLAnalogDownKey(const SDL_Event* event, u32& button, Input::Axis& axis,
int& axisvalue, int& ax);
void handleRAnalogRightKey(const SDL_Event* event, u32& button, Input::Axis& axis,
int& axisvalue, int& ax);
void handleRAnalogLeftKey(const SDL_Event* event, u32& button, Input::Axis& axis,
int& axisvalue, int& ax);
void handleRAnalogUpKey(const SDL_Event* event, u32& button, Input::Axis& axis, int& axisvalue,
int& ax);
void handleRAnalogDownKey(const SDL_Event* event, u32& button, Input::Axis& axis,
int& axisvalue, int& ax);
private:
s32 width;
s32 height;
Input::GameController* controller;
WindowSystemInfo window_info{};
SDL_Window* window{};
std::map<u32, KeysMapping> keysBindingsMap;
bool is_shown{};
bool is_open{true};
};