mirror of
https://github.com/citra-emu/citra.git
synced 2024-12-18 14:40:05 +00:00
Move input values into an array
This commit is contained in:
parent
453764aefc
commit
1bc7829ee9
@ -40,31 +40,21 @@ bool Config::LoadINI(INIReader* config, const char* location, const std::string&
|
||||
return true;
|
||||
}
|
||||
|
||||
static const std::array<int, Settings::NativeInput::NUM_INPUTS> defaults = {
|
||||
GLFW_KEY_A, GLFW_KEY_S, GLFW_KEY_Z, GLFW_KEY_X,
|
||||
GLFW_KEY_Q, GLFW_KEY_W, GLFW_KEY_1, GLFW_KEY_2,
|
||||
GLFW_KEY_M, GLFW_KEY_N, GLFW_KEY_B,
|
||||
GLFW_KEY_T, GLFW_KEY_G, GLFW_KEY_F, GLFW_KEY_H,
|
||||
GLFW_KEY_UP, GLFW_KEY_DOWN, GLFW_KEY_LEFT, GLFW_KEY_RIGHT,
|
||||
GLFW_KEY_I, GLFW_KEY_K, GLFW_KEY_J, GLFW_KEY_L
|
||||
};
|
||||
|
||||
void Config::ReadValues() {
|
||||
// Controls
|
||||
Settings::values.pad_a_key = glfw_config->GetInteger("Controls", "pad_a", GLFW_KEY_A);
|
||||
Settings::values.pad_b_key = glfw_config->GetInteger("Controls", "pad_b", GLFW_KEY_S);
|
||||
Settings::values.pad_x_key = glfw_config->GetInteger("Controls", "pad_x", GLFW_KEY_Z);
|
||||
Settings::values.pad_y_key = glfw_config->GetInteger("Controls", "pad_y", GLFW_KEY_X);
|
||||
Settings::values.pad_l_key = glfw_config->GetInteger("Controls", "pad_l", GLFW_KEY_Q);
|
||||
Settings::values.pad_r_key = glfw_config->GetInteger("Controls", "pad_r", GLFW_KEY_W);
|
||||
Settings::values.pad_zl_key = glfw_config->GetInteger("Controls", "pad_zl", GLFW_KEY_1);
|
||||
Settings::values.pad_zr_key = glfw_config->GetInteger("Controls", "pad_zr", GLFW_KEY_2);
|
||||
Settings::values.pad_start_key = glfw_config->GetInteger("Controls", "pad_start", GLFW_KEY_M);
|
||||
Settings::values.pad_select_key = glfw_config->GetInteger("Controls", "pad_select", GLFW_KEY_N);
|
||||
Settings::values.pad_home_key = glfw_config->GetInteger("Controls", "pad_home", GLFW_KEY_B);
|
||||
Settings::values.pad_dup_key = glfw_config->GetInteger("Controls", "pad_dup", GLFW_KEY_T);
|
||||
Settings::values.pad_ddown_key = glfw_config->GetInteger("Controls", "pad_ddown", GLFW_KEY_G);
|
||||
Settings::values.pad_dleft_key = glfw_config->GetInteger("Controls", "pad_dleft", GLFW_KEY_F);
|
||||
Settings::values.pad_dright_key = glfw_config->GetInteger("Controls", "pad_dright", GLFW_KEY_H);
|
||||
Settings::values.pad_sup_key = glfw_config->GetInteger("Controls", "pad_sup", GLFW_KEY_UP);
|
||||
Settings::values.pad_sdown_key = glfw_config->GetInteger("Controls", "pad_sdown", GLFW_KEY_DOWN);
|
||||
Settings::values.pad_sleft_key = glfw_config->GetInteger("Controls", "pad_sleft", GLFW_KEY_LEFT);
|
||||
Settings::values.pad_sright_key = glfw_config->GetInteger("Controls", "pad_sright", GLFW_KEY_RIGHT);
|
||||
Settings::values.pad_cup_key = glfw_config->GetInteger("Controls", "pad_cup", GLFW_KEY_I);
|
||||
Settings::values.pad_cdown_key = glfw_config->GetInteger("Controls", "pad_cdown", GLFW_KEY_K);
|
||||
Settings::values.pad_cleft_key = glfw_config->GetInteger("Controls", "pad_cleft", GLFW_KEY_J);
|
||||
Settings::values.pad_cright_key = glfw_config->GetInteger("Controls", "pad_cright", GLFW_KEY_L);
|
||||
for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) {
|
||||
Settings::values.input_mappings[Settings::NativeInput::All[i]] =
|
||||
glfw_config->GetInteger("Controls", Settings::NativeInput::Mapping[i], defaults[i]);
|
||||
}
|
||||
|
||||
// Core
|
||||
Settings::values.frame_skip = glfw_config->GetInteger("Core", "frame_skip", 0);
|
||||
|
@ -150,32 +150,9 @@ void EmuWindow_GLFW::DoneCurrent() {
|
||||
}
|
||||
|
||||
void EmuWindow_GLFW::ReloadSetKeymaps() {
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_a_key, keyboard_id}, Service::HID::PAD_A);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_b_key, keyboard_id}, Service::HID::PAD_B);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_select_key, keyboard_id}, Service::HID::PAD_SELECT);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_start_key, keyboard_id}, Service::HID::PAD_START);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_dright_key, keyboard_id}, Service::HID::PAD_RIGHT);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_dleft_key, keyboard_id}, Service::HID::PAD_LEFT);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_dup_key, keyboard_id}, Service::HID::PAD_UP);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_ddown_key, keyboard_id}, Service::HID::PAD_DOWN);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_r_key, keyboard_id}, Service::HID::PAD_R);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_l_key, keyboard_id}, Service::HID::PAD_L);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_x_key, keyboard_id}, Service::HID::PAD_X);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_y_key, keyboard_id}, Service::HID::PAD_Y);
|
||||
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_zl_key, keyboard_id}, Service::HID::PAD_ZL);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_zr_key, keyboard_id}, Service::HID::PAD_ZR);
|
||||
|
||||
// KeyMap::SetKeyMapping({Settings::values.pad_touch_key, keyboard_id}, Service::HID::PAD_TOUCH);
|
||||
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_cright_key, keyboard_id}, Service::HID::PAD_C_RIGHT);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_cleft_key, keyboard_id}, Service::HID::PAD_C_LEFT);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_cup_key, keyboard_id}, Service::HID::PAD_C_UP);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_cdown_key, keyboard_id}, Service::HID::PAD_C_DOWN);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_sright_key, keyboard_id}, Service::HID::PAD_CIRCLE_RIGHT);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_sleft_key, keyboard_id}, Service::HID::PAD_CIRCLE_LEFT);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_sup_key, keyboard_id}, Service::HID::PAD_CIRCLE_UP);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_sdown_key, keyboard_id}, Service::HID::PAD_CIRCLE_DOWN);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
void EmuWindow_GLFW::OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) {
|
||||
|
@ -248,32 +248,9 @@ void GRenderWindow::mouseReleaseEvent(QMouseEvent *event)
|
||||
|
||||
void GRenderWindow::ReloadSetKeymaps()
|
||||
{
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_a_key, keyboard_id}, Service::HID::PAD_A);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_b_key, keyboard_id}, Service::HID::PAD_B);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_select_key, keyboard_id}, Service::HID::PAD_SELECT);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_start_key, keyboard_id}, Service::HID::PAD_START);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_dright_key, keyboard_id}, Service::HID::PAD_RIGHT);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_dleft_key, keyboard_id}, Service::HID::PAD_LEFT);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_dup_key, keyboard_id}, Service::HID::PAD_UP);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_ddown_key, keyboard_id}, Service::HID::PAD_DOWN);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_r_key, keyboard_id}, Service::HID::PAD_R);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_l_key, keyboard_id}, Service::HID::PAD_L);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_x_key, keyboard_id}, Service::HID::PAD_X);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_y_key, keyboard_id}, Service::HID::PAD_Y);
|
||||
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_zl_key, keyboard_id}, Service::HID::PAD_ZL);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_zr_key, keyboard_id}, Service::HID::PAD_ZR);
|
||||
|
||||
// KeyMap::SetKeyMapping({Settings::values.pad_touch_key, keyboard_id}, Service::HID::PAD_TOUCH);
|
||||
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_cright_key, keyboard_id}, Service::HID::PAD_C_RIGHT);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_cleft_key, keyboard_id}, Service::HID::PAD_C_LEFT);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_cup_key, keyboard_id}, Service::HID::PAD_C_UP);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_cdown_key, keyboard_id}, Service::HID::PAD_C_DOWN);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_sright_key, keyboard_id}, Service::HID::PAD_CIRCLE_RIGHT);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_sleft_key, keyboard_id}, Service::HID::PAD_CIRCLE_LEFT);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_sup_key, keyboard_id}, Service::HID::PAD_CIRCLE_UP);
|
||||
KeyMap::SetKeyMapping({Settings::values.pad_sdown_key, keyboard_id}, Service::HID::PAD_CIRCLE_DOWN);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
void GRenderWindow::OnClientAreaResized(unsigned width, unsigned height)
|
||||
|
@ -21,31 +21,21 @@ Config::Config() {
|
||||
Reload();
|
||||
}
|
||||
|
||||
static const std::array<QVariant, Settings::NativeInput::NUM_INPUTS> defaults = {
|
||||
Qt::Key_A, Qt::Key_S, Qt::Key_Z, Qt::Key_X,
|
||||
Qt::Key_Q, Qt::Key_W, Qt::Key_1, Qt::Key_2,
|
||||
Qt::Key_M, Qt::Key_N, Qt::Key_B,
|
||||
Qt::Key_T, Qt::Key_G, Qt::Key_F, Qt::Key_H,
|
||||
Qt::Key_Up, Qt::Key_Down, Qt::Key_Left, Qt::Key_Right,
|
||||
Qt::Key_I, Qt::Key_K, Qt::Key_J, Qt::Key_L
|
||||
};
|
||||
|
||||
void Config::ReadValues() {
|
||||
qt_config->beginGroup("Controls");
|
||||
Settings::values.pad_a_key = qt_config->value("pad_a", Qt::Key_A).toInt();
|
||||
Settings::values.pad_b_key = qt_config->value("pad_b", Qt::Key_S).toInt();
|
||||
Settings::values.pad_x_key = qt_config->value("pad_x", Qt::Key_Z).toInt();
|
||||
Settings::values.pad_y_key = qt_config->value("pad_y", Qt::Key_X).toInt();
|
||||
Settings::values.pad_l_key = qt_config->value("pad_l", Qt::Key_Q).toInt();
|
||||
Settings::values.pad_r_key = qt_config->value("pad_r", Qt::Key_W).toInt();
|
||||
Settings::values.pad_zl_key = qt_config->value("pad_zl", Qt::Key_1).toInt();
|
||||
Settings::values.pad_zr_key = qt_config->value("pad_zr", Qt::Key_2).toInt();
|
||||
Settings::values.pad_start_key = qt_config->value("pad_start", Qt::Key_M).toInt();
|
||||
Settings::values.pad_select_key = qt_config->value("pad_select", Qt::Key_N).toInt();
|
||||
Settings::values.pad_home_key = qt_config->value("pad_home", Qt::Key_B).toInt();
|
||||
Settings::values.pad_dup_key = qt_config->value("pad_dup", Qt::Key_T).toInt();
|
||||
Settings::values.pad_ddown_key = qt_config->value("pad_ddown", Qt::Key_G).toInt();
|
||||
Settings::values.pad_dleft_key = qt_config->value("pad_dleft", Qt::Key_F).toInt();
|
||||
Settings::values.pad_dright_key = qt_config->value("pad_dright", Qt::Key_H).toInt();
|
||||
Settings::values.pad_sup_key = qt_config->value("pad_sup", Qt::Key_Up).toInt();
|
||||
Settings::values.pad_sdown_key = qt_config->value("pad_sdown", Qt::Key_Down).toInt();
|
||||
Settings::values.pad_sleft_key = qt_config->value("pad_sleft", Qt::Key_Left).toInt();
|
||||
Settings::values.pad_sright_key = qt_config->value("pad_sright", Qt::Key_Right).toInt();
|
||||
Settings::values.pad_cup_key = qt_config->value("pad_cup", Qt::Key_I).toInt();
|
||||
Settings::values.pad_cdown_key = qt_config->value("pad_cdown", Qt::Key_K).toInt();
|
||||
Settings::values.pad_cleft_key = qt_config->value("pad_cleft", Qt::Key_J).toInt();
|
||||
Settings::values.pad_cright_key = qt_config->value("pad_cright", Qt::Key_L).toInt();
|
||||
for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) {
|
||||
Settings::values.input_mappings[Settings::NativeInput::All[i]] =
|
||||
qt_config->value(QString::fromStdString(Settings::NativeInput::Mapping[i]), defaults[i]).toInt();
|
||||
}
|
||||
qt_config->endGroup();
|
||||
|
||||
qt_config->beginGroup("Core");
|
||||
@ -75,29 +65,9 @@ void Config::ReadValues() {
|
||||
|
||||
void Config::SaveValues() {
|
||||
qt_config->beginGroup("Controls");
|
||||
qt_config->setValue("pad_a", Settings::values.pad_a_key);
|
||||
qt_config->setValue("pad_b", Settings::values.pad_b_key);
|
||||
qt_config->setValue("pad_x", Settings::values.pad_x_key);
|
||||
qt_config->setValue("pad_y", Settings::values.pad_y_key);
|
||||
qt_config->setValue("pad_l", Settings::values.pad_l_key);
|
||||
qt_config->setValue("pad_r", Settings::values.pad_r_key);
|
||||
qt_config->setValue("pad_zl", Settings::values.pad_zl_key);
|
||||
qt_config->setValue("pad_zr", Settings::values.pad_zr_key);
|
||||
qt_config->setValue("pad_start", Settings::values.pad_start_key);
|
||||
qt_config->setValue("pad_select", Settings::values.pad_select_key);
|
||||
qt_config->setValue("pad_home", Settings::values.pad_home_key);
|
||||
qt_config->setValue("pad_dup", Settings::values.pad_dup_key);
|
||||
qt_config->setValue("pad_ddown", Settings::values.pad_ddown_key);
|
||||
qt_config->setValue("pad_dleft", Settings::values.pad_dleft_key);
|
||||
qt_config->setValue("pad_dright", Settings::values.pad_dright_key);
|
||||
qt_config->setValue("pad_sup", Settings::values.pad_sup_key);
|
||||
qt_config->setValue("pad_sdown", Settings::values.pad_sdown_key);
|
||||
qt_config->setValue("pad_sleft", Settings::values.pad_sleft_key);
|
||||
qt_config->setValue("pad_sright", Settings::values.pad_sright_key);
|
||||
qt_config->setValue("pad_cup", Settings::values.pad_cup_key);
|
||||
qt_config->setValue("pad_cdown", Settings::values.pad_cdown_key);
|
||||
qt_config->setValue("pad_cleft", Settings::values.pad_cleft_key);
|
||||
qt_config->setValue("pad_cright", Settings::values.pad_cright_key);
|
||||
for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) {
|
||||
qt_config->setValue(QString::fromStdString(Settings::NativeInput::Mapping[i]), Settings::NativeInput::All[i]);
|
||||
}
|
||||
qt_config->endGroup();
|
||||
|
||||
qt_config->beginGroup("Core");
|
||||
|
@ -35,6 +35,16 @@ static Kernel::SharedPtr<Kernel::Event> event_debug_pad;
|
||||
static u32 next_pad_index;
|
||||
static u32 next_touch_index;
|
||||
|
||||
const std::array<Service::HID::PadState, Settings::NativeInput::NUM_INPUTS> pad_mapping = {
|
||||
Service::HID::PAD_A, Service::HID::PAD_B, Service::HID::PAD_X, Service::HID::PAD_Y,
|
||||
Service::HID::PAD_L, Service::HID::PAD_R, Service::HID::PAD_ZL, Service::HID::PAD_ZR,
|
||||
Service::HID::PAD_START, Service::HID::PAD_SELECT, Service::HID::PAD_NONE,
|
||||
Service::HID::PAD_UP, Service::HID::PAD_DOWN, Service::HID::PAD_LEFT, Service::HID::PAD_RIGHT,
|
||||
Service::HID::PAD_CIRCLE_UP, Service::HID::PAD_CIRCLE_DOWN, Service::HID::PAD_CIRCLE_LEFT, Service::HID::PAD_CIRCLE_RIGHT,
|
||||
Service::HID::PAD_C_UP, Service::HID::PAD_C_DOWN, Service::HID::PAD_C_LEFT, Service::HID::PAD_C_RIGHT
|
||||
};
|
||||
|
||||
|
||||
// TODO(peachum):
|
||||
// Add a method for setting analog input from joystick device for the circle Pad.
|
||||
//
|
||||
|
@ -9,7 +9,7 @@
|
||||
#ifndef _MSC_VER
|
||||
#include <cstddef>
|
||||
#endif
|
||||
|
||||
#include "core/settings.h"
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
@ -157,6 +157,9 @@ const PadState PAD_CIRCLE_LEFT = {{1u << 29}};
|
||||
const PadState PAD_CIRCLE_UP = {{1u << 30}};
|
||||
const PadState PAD_CIRCLE_DOWN = {{1u << 31}};
|
||||
|
||||
|
||||
extern const std::array<Service::HID::PadState, Settings::NativeInput::NUM_INPUTS> pad_mapping;
|
||||
|
||||
/**
|
||||
* HID::GetIPCHandles service function
|
||||
* Inputs:
|
||||
|
@ -5,34 +5,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <array>
|
||||
|
||||
namespace Settings {
|
||||
|
||||
namespace NativeInput {
|
||||
enum Values {
|
||||
A, B, X, Y,
|
||||
L, R, ZL, ZR,
|
||||
START, SELECT, HOME,
|
||||
DUP, DDOWN, DLEFT, DRIGHT,
|
||||
SUP, SDOWN, SLEFT, SRIGHT,
|
||||
CUP, CDOWN, CLEFT, CRIGHT,
|
||||
NUM_INPUTS
|
||||
};
|
||||
static const std::array<const char*, NUM_INPUTS> Mapping = {
|
||||
"pad_a", "pad_b", "pad_x", "pad_y",
|
||||
"pad_l", "pad_r", "pad_zl", "pad_zr",
|
||||
"pad_start", "pad_select", "pad_home",
|
||||
"pad_dup", "pad_ddown", "pad_dleft", "pad_dright",
|
||||
"pad_sup", "pad_sdown", "pad_sleft", "pad_sright",
|
||||
"pad_cup", "pad_cdown", "pad_cleft", "pad_cright"
|
||||
};
|
||||
static const std::array<Values, NUM_INPUTS> All = {
|
||||
A, B, X, Y,
|
||||
L, R, ZL, ZR,
|
||||
START, SELECT, HOME,
|
||||
DUP, DDOWN, DLEFT, DRIGHT,
|
||||
SUP, SDOWN, SLEFT, SRIGHT,
|
||||
CUP, CDOWN, CLEFT, CRIGHT
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
struct Values {
|
||||
// Controls
|
||||
int pad_a_key;
|
||||
int pad_b_key;
|
||||
int pad_x_key;
|
||||
int pad_y_key;
|
||||
int pad_l_key;
|
||||
int pad_r_key;
|
||||
int pad_zl_key;
|
||||
int pad_zr_key;
|
||||
int pad_start_key;
|
||||
int pad_select_key;
|
||||
int pad_home_key;
|
||||
int pad_dup_key;
|
||||
int pad_ddown_key;
|
||||
int pad_dleft_key;
|
||||
int pad_dright_key;
|
||||
int pad_sup_key;
|
||||
int pad_sdown_key;
|
||||
int pad_sleft_key;
|
||||
int pad_sright_key;
|
||||
int pad_cup_key;
|
||||
int pad_cdown_key;
|
||||
int pad_cleft_key;
|
||||
int pad_cright_key;
|
||||
std::array<int, NativeInput::NUM_INPUTS> input_mappings;
|
||||
|
||||
// Core
|
||||
int frame_skip;
|
||||
|
Loading…
Reference in New Issue
Block a user