Merge pull request #1789 from wwylele/input-refactor
Refactor input mapping & implement circle pad modifier
This commit is contained in:
commit
f99961581e
12 changed files with 313 additions and 73 deletions
|
@ -44,12 +44,16 @@ bool Config::LoadINI(const std::string& default_contents, bool retry) {
|
|||
}
|
||||
|
||||
static const std::array<int, Settings::NativeInput::NUM_INPUTS> defaults = {
|
||||
// directly mapped keys
|
||||
SDL_SCANCODE_A, SDL_SCANCODE_S, SDL_SCANCODE_Z, SDL_SCANCODE_X,
|
||||
SDL_SCANCODE_Q, SDL_SCANCODE_W, SDL_SCANCODE_1, SDL_SCANCODE_2,
|
||||
SDL_SCANCODE_M, SDL_SCANCODE_N, SDL_SCANCODE_B,
|
||||
SDL_SCANCODE_T, SDL_SCANCODE_G, SDL_SCANCODE_F, SDL_SCANCODE_H,
|
||||
SDL_SCANCODE_I, SDL_SCANCODE_K, SDL_SCANCODE_J, SDL_SCANCODE_L,
|
||||
|
||||
// indirectly mapped keys
|
||||
SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT,
|
||||
SDL_SCANCODE_I, SDL_SCANCODE_K, SDL_SCANCODE_J, SDL_SCANCODE_L
|
||||
SDL_SCANCODE_D,
|
||||
};
|
||||
|
||||
void Config::ReadValues() {
|
||||
|
@ -58,6 +62,7 @@ void Config::ReadValues() {
|
|||
Settings::values.input_mappings[Settings::NativeInput::All[i]] =
|
||||
sdl2_config->GetInteger("Controls", Settings::NativeInput::Mapping[i], defaults[i]);
|
||||
}
|
||||
Settings::values.pad_circle_modifier_scale = (float)sdl2_config->GetReal("Controls", "pad_circle_modifier_scale", 0.5);
|
||||
|
||||
// Core
|
||||
Settings::values.frame_skip = sdl2_config->GetInteger("Core", "frame_skip", 0);
|
||||
|
|
|
@ -23,14 +23,19 @@ pad_l =
|
|||
pad_r =
|
||||
pad_zl =
|
||||
pad_zr =
|
||||
pad_sup =
|
||||
pad_sdown =
|
||||
pad_sleft =
|
||||
pad_sright =
|
||||
pad_cup =
|
||||
pad_cdown =
|
||||
pad_cleft =
|
||||
pad_cright =
|
||||
pad_circle_up =
|
||||
pad_circle_down =
|
||||
pad_circle_left =
|
||||
pad_circle_right =
|
||||
pad_circle_modifier =
|
||||
|
||||
# The applied modifier scale to circle pad.
|
||||
# Must be in range of 0.0-1.0. Defaults to 0.5
|
||||
pad_circle_modifier_scale =
|
||||
|
||||
[Core]
|
||||
# The applied frameskip amount. Must be a power of two.
|
||||
|
|
|
@ -40,9 +40,9 @@ void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) {
|
|||
|
||||
void EmuWindow_SDL2::OnKeyEvent(int key, u8 state) {
|
||||
if (state == SDL_PRESSED) {
|
||||
KeyPressed({ key, keyboard_id });
|
||||
KeyMap::PressKey(*this, { key, keyboard_id });
|
||||
} else if (state == SDL_RELEASED) {
|
||||
KeyReleased({ key, keyboard_id });
|
||||
KeyMap::ReleaseKey(*this, { key, keyboard_id });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,8 +168,9 @@ void EmuWindow_SDL2::DoneCurrent() {
|
|||
}
|
||||
|
||||
void EmuWindow_SDL2::ReloadSetKeymaps() {
|
||||
KeyMap::ClearKeyMapping(keyboard_id);
|
||||
for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) {
|
||||
KeyMap::SetKeyMapping({ Settings::values.input_mappings[Settings::NativeInput::All[i]], keyboard_id }, Service::HID::pad_mapping[i]);
|
||||
KeyMap::SetKeyMapping({ Settings::values.input_mappings[Settings::NativeInput::All[i]], keyboard_id }, KeyMap::mapping_targets[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue