citra-emu
/
citra-canary
Archived
1
0
Fork 0

implement circle pad modifier

This commit is contained in:
wwylele 2016-05-13 18:32:43 +03:00
parent 03631f9b8f
commit 416faa20d1
6 changed files with 37 additions and 5 deletions

View File

@ -53,6 +53,7 @@ static const std::array<int, Settings::NativeInput::NUM_INPUTS> defaults = {
// indirectly mapped keys
SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT,
SDL_SCANCODE_D,
};
void Config::ReadValues() {
@ -61,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);

View File

@ -31,6 +31,11 @@ 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.

View File

@ -31,6 +31,7 @@ static const std::array<QVariant, Settings::NativeInput::NUM_INPUTS> defaults =
// indirectly mapped keys
Qt::Key_Up, Qt::Key_Down, Qt::Key_Left, Qt::Key_Right,
Qt::Key_D,
};
void Config::ReadValues() {
@ -39,6 +40,7 @@ void Config::ReadValues() {
Settings::values.input_mappings[Settings::NativeInput::All[i]] =
qt_config->value(QString::fromStdString(Settings::NativeInput::Mapping[i]), defaults[i]).toInt();
}
Settings::values.pad_circle_modifier_scale = qt_config->value("pad_circle_modifier_scale", 0.5).toFloat();
qt_config->endGroup();
qt_config->beginGroup("Core");
@ -128,6 +130,7 @@ void Config::SaveValues() {
qt_config->setValue(QString::fromStdString(Settings::NativeInput::Mapping[i]),
Settings::values.input_mappings[Settings::NativeInput::All[i]]);
}
qt_config->setValue("pad_circle_modifier_scale", (double)Settings::values.pad_circle_modifier_scale);
qt_config->endGroup();
qt_config->beginGroup("Core");

View File

@ -23,12 +23,17 @@ const std::array<KeyTarget, Settings::NativeInput::NUM_INPUTS> mapping_targets =
IndirectTarget::CIRCLE_PAD_DOWN,
IndirectTarget::CIRCLE_PAD_LEFT,
IndirectTarget::CIRCLE_PAD_RIGHT,
IndirectTarget::CIRCLE_PAD_MODIFIER,
}};
static std::map<HostDeviceKey, KeyTarget> key_map;
static int next_device_id = 0;
static bool circle_pad_up = false, circle_pad_down = false, circle_pad_left = false, circle_pad_right = false;
static bool circle_pad_up = false;
static bool circle_pad_down = false;
static bool circle_pad_left = false;
static bool circle_pad_right = false;
static bool circle_pad_modifier = false;
static void UpdateCirclePad(EmuWindow& emu_window) {
constexpr float SQRT_HALF = 0.707106781;
@ -42,8 +47,9 @@ static void UpdateCirclePad(EmuWindow& emu_window) {
++y;
if (circle_pad_down)
--y;
// TODO: apply modifier here
emu_window.CirclePadUpdated(x * (y == 0 ? 1.0 : SQRT_HALF), y * (x == 0 ? 1.0 : SQRT_HALF));
float modifier = circle_pad_modifier ? Settings::values.pad_circle_modifier_scale : 1.0;
emu_window.CirclePadUpdated(x * modifier * (y == 0 ? 1.0 : SQRT_HALF), y * modifier * (x == 0 ? 1.0 : SQRT_HALF));
}
int NewDeviceId() {
@ -89,6 +95,10 @@ void PressKey(EmuWindow& emu_window, HostDeviceKey key) {
circle_pad_right = true;
UpdateCirclePad(emu_window);
break;
case IndirectTarget::CIRCLE_PAD_MODIFIER:
circle_pad_modifier = true;
UpdateCirclePad(emu_window);
break;
}
}
}
@ -118,6 +128,10 @@ void ReleaseKey(EmuWindow& emu_window,HostDeviceKey key) {
circle_pad_right = false;
UpdateCirclePad(emu_window);
break;
case IndirectTarget::CIRCLE_PAD_MODIFIER:
circle_pad_modifier = false;
UpdateCirclePad(emu_window);
break;
}
}
}

View File

@ -13,7 +13,11 @@ class EmuWindow;
namespace KeyMap {
enum class IndirectTarget {
CIRCLE_PAD_UP, CIRCLE_PAD_DOWN, CIRCLE_PAD_LEFT, CIRCLE_PAD_RIGHT,
CIRCLE_PAD_UP,
CIRCLE_PAD_DOWN,
CIRCLE_PAD_LEFT,
CIRCLE_PAD_RIGHT,
CIRCLE_PAD_MODIFIER,
};
/**

View File

@ -22,6 +22,7 @@ enum Values {
// indirectly mapped keys
CIRCLE_UP, CIRCLE_DOWN, CIRCLE_LEFT, CIRCLE_RIGHT,
CIRCLE_MODIFIER,
NUM_INPUTS
};
@ -35,7 +36,8 @@ static const std::array<const char*, NUM_INPUTS> Mapping = {{
"pad_cup", "pad_cdown", "pad_cleft", "pad_cright",
// indirectly mapped keys
"pad_circle_up", "pad_circle_down", "pad_circle_left", "pad_circle_right"
"pad_circle_up", "pad_circle_down", "pad_circle_left", "pad_circle_right",
"pad_circle_modifier",
}};
static const std::array<Values, NUM_INPUTS> All = {{
A, B, X, Y,
@ -44,6 +46,7 @@ static const std::array<Values, NUM_INPUTS> All = {{
DUP, DDOWN, DLEFT, DRIGHT,
CUP, CDOWN, CLEFT, CRIGHT,
CIRCLE_UP, CIRCLE_DOWN, CIRCLE_LEFT, CIRCLE_RIGHT,
CIRCLE_MODIFIER,
}};
}
@ -51,6 +54,7 @@ static const std::array<Values, NUM_INPUTS> All = {{
struct Values {
// Controls
std::array<int, NativeInput::NUM_INPUTS> input_mappings;
float pad_circle_modifier_scale;
// Core
int frame_skip;