implement circle pad modifier

This commit is contained in:
wwylele 2016-05-11 10:31:26 +03:00
parent a44ffd12b7
commit 7dfaad90b5
8 changed files with 42 additions and 8 deletions

View File

@ -49,7 +49,8 @@ static const std::array<int, Settings::NativeInput::NUM_INPUTS> defaults = {
SDL_SCANCODE_M, SDL_SCANCODE_N, SDL_SCANCODE_B, SDL_SCANCODE_M, SDL_SCANCODE_N, SDL_SCANCODE_B,
SDL_SCANCODE_T, SDL_SCANCODE_G, SDL_SCANCODE_F, SDL_SCANCODE_H, SDL_SCANCODE_T, SDL_SCANCODE_G, SDL_SCANCODE_F, SDL_SCANCODE_H,
SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, 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_I, SDL_SCANCODE_K, SDL_SCANCODE_J, SDL_SCANCODE_L,
SDL_SCANCODE_D
}; };
void Config::ReadValues() { void Config::ReadValues() {
@ -58,6 +59,7 @@ void Config::ReadValues() {
Settings::values.input_mappings[Settings::NativeInput::All[i]] = Settings::values.input_mappings[Settings::NativeInput::All[i]] =
sdl2_config->GetInteger("Controls", Settings::NativeInput::Mapping[i], defaults[i]); sdl2_config->GetInteger("Controls", Settings::NativeInput::Mapping[i], defaults[i]);
} }
Settings::values.circle_pad_modifier_scale = (float)sdl2_config->GetReal("Controls", "circle_pad_modifier_scale", 0.5);
// Core // Core
Settings::values.frame_skip = sdl2_config->GetInteger("Core", "frame_skip", 0); Settings::values.frame_skip = sdl2_config->GetInteger("Core", "frame_skip", 0);

View File

@ -31,6 +31,11 @@ pad_cup =
pad_cdown = pad_cdown =
pad_cleft = pad_cleft =
pad_cright = pad_cright =
pad_cmodifier =
# The multiplier to the circle pad radius when modifier is pressed.
# Must be in range of 0.0-1.0. Defaults to 0.5
circle_pad_modifier_scale =
[Core] [Core]
# The applied frameskip amount. Must be a power of two. # The applied frameskip amount. Must be a power of two.

View File

@ -27,7 +27,8 @@ static const std::array<QVariant, Settings::NativeInput::NUM_INPUTS> defaults =
Qt::Key_M, Qt::Key_N, Qt::Key_B, Qt::Key_M, Qt::Key_N, Qt::Key_B,
Qt::Key_T, Qt::Key_G, Qt::Key_F, Qt::Key_H, 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_Up, Qt::Key_Down, Qt::Key_Left, Qt::Key_Right,
Qt::Key_I, Qt::Key_K, Qt::Key_J, Qt::Key_L Qt::Key_I, Qt::Key_K, Qt::Key_J, Qt::Key_L,
Qt::Key_D
}; };
void Config::ReadValues() { void Config::ReadValues() {
@ -36,6 +37,7 @@ void Config::ReadValues() {
Settings::values.input_mappings[Settings::NativeInput::All[i]] = Settings::values.input_mappings[Settings::NativeInput::All[i]] =
qt_config->value(QString::fromStdString(Settings::NativeInput::Mapping[i]), defaults[i]).toInt(); qt_config->value(QString::fromStdString(Settings::NativeInput::Mapping[i]), defaults[i]).toInt();
} }
Settings::values.circle_pad_modifier_scale = qt_config->value("circle_pad_modifier_scale", 0.5).toFloat();
qt_config->endGroup(); qt_config->endGroup();
qt_config->beginGroup("Core"); qt_config->beginGroup("Core");
@ -125,6 +127,7 @@ void Config::SaveValues() {
qt_config->setValue(QString::fromStdString(Settings::NativeInput::Mapping[i]), qt_config->setValue(QString::fromStdString(Settings::NativeInput::Mapping[i]),
Settings::values.input_mappings[Settings::NativeInput::All[i]]); Settings::values.input_mappings[Settings::NativeInput::All[i]]);
} }
qt_config->setValue("circle_pad_modifier_scale", (double)Settings::values.circle_pad_modifier_scale);
qt_config->endGroup(); qt_config->endGroup();
qt_config->beginGroup("Core"); qt_config->beginGroup("Core");

View File

@ -12,12 +12,22 @@
#include "video_core/video_core.h" #include "video_core/video_core.h"
void EmuWindow::KeyPressed(KeyMap::HostDeviceKey key) { void EmuWindow::KeyPressed(KeyMap::HostDeviceKey key) {
auto hex = KeyMap::GetPadKey(key).hex;
if (hex == Service::HID::PAD_C_MODIFIER.hex) {
circle_pad_modifier = true;
} else {
pad_state.hex |= KeyMap::GetPadKey(key).hex; pad_state.hex |= KeyMap::GetPadKey(key).hex;
} }
}
void EmuWindow::KeyReleased(KeyMap::HostDeviceKey key) { void EmuWindow::KeyReleased(KeyMap::HostDeviceKey key) {
auto hex = KeyMap::GetPadKey(key).hex;
if (hex == Service::HID::PAD_C_MODIFIER.hex) {
circle_pad_modifier = false;
} else {
pad_state.hex &= ~KeyMap::GetPadKey(key).hex; pad_state.hex &= ~KeyMap::GetPadKey(key).hex;
} }
}
/** /**
* Check if the given x/y coordinates are within the touchpad specified by the framebuffer layout * Check if the given x/y coordinates are within the touchpad specified by the framebuffer layout

View File

@ -138,7 +138,11 @@ public:
y *= SQRT_HALF; y *= SQRT_HALF;
if (y != 0) if (y != 0)
x *= SQRT_HALF; x *= SQRT_HALF;
return std::make_tuple<s16, s16>(x, y); if (circle_pad_modifier) {
x *= Settings::values.circle_pad_modifier_scale;
y *= Settings::values.circle_pad_modifier_scale;
}
return std::make_tuple(x, y);
} }
/** /**
@ -233,6 +237,7 @@ protected:
touch_x = 0; touch_x = 0;
touch_y = 0; touch_y = 0;
touch_pressed = false; touch_pressed = false;
circle_pad_modifier = false;
} }
virtual ~EmuWindow() {} virtual ~EmuWindow() {}
@ -298,4 +303,6 @@ private:
std::tuple<unsigned,unsigned> ClipToTouchScreen(unsigned new_x, unsigned new_y); std::tuple<unsigned,unsigned> ClipToTouchScreen(unsigned new_x, unsigned new_y);
Service::HID::PadState pad_state; Service::HID::PadState pad_state;
bool circle_pad_modifier; ///< True if circle pad modifier is currently pressed, otherwise false
}; };

View File

@ -43,7 +43,8 @@ const std::array<Service::HID::PadState, Settings::NativeInput::NUM_INPUTS> pad_
Service::HID::PAD_START, Service::HID::PAD_SELECT, Service::HID::PAD_NONE, 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_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_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 Service::HID::PAD_C_UP, Service::HID::PAD_C_DOWN, Service::HID::PAD_C_LEFT, Service::HID::PAD_C_RIGHT,
Service::HID::PAD_C_MODIFIER , // place holder for circle pad modifier
}}; }};
void Update() { void Update() {

View File

@ -215,6 +215,8 @@ const PadState PAD_CIRCLE_LEFT = {{1u << 29}};
const PadState PAD_CIRCLE_UP = {{1u << 30}}; const PadState PAD_CIRCLE_UP = {{1u << 30}};
const PadState PAD_CIRCLE_DOWN = {{1u << 31}}; const PadState PAD_CIRCLE_DOWN = {{1u << 31}};
const PadState PAD_C_MODIFIER = {{1u << 23}}; // An intermediate value only used by citra
extern const std::array<Service::HID::PadState, Settings::NativeInput::NUM_INPUTS> pad_mapping; extern const std::array<Service::HID::PadState, Settings::NativeInput::NUM_INPUTS> pad_mapping;

View File

@ -19,6 +19,7 @@ enum Values {
DUP, DDOWN, DLEFT, DRIGHT, DUP, DDOWN, DLEFT, DRIGHT,
SUP, SDOWN, SLEFT, SRIGHT, SUP, SDOWN, SLEFT, SRIGHT,
CUP, CDOWN, CLEFT, CRIGHT, CUP, CDOWN, CLEFT, CRIGHT,
CMODIFIER,
NUM_INPUTS NUM_INPUTS
}; };
static const std::array<const char*, NUM_INPUTS> Mapping = {{ static const std::array<const char*, NUM_INPUTS> Mapping = {{
@ -27,7 +28,8 @@ static const std::array<const char*, NUM_INPUTS> Mapping = {{
"pad_start", "pad_select", "pad_home", "pad_start", "pad_select", "pad_home",
"pad_dup", "pad_ddown", "pad_dleft", "pad_dright", "pad_dup", "pad_ddown", "pad_dleft", "pad_dright",
"pad_sup", "pad_sdown", "pad_sleft", "pad_sright", "pad_sup", "pad_sdown", "pad_sleft", "pad_sright",
"pad_cup", "pad_cdown", "pad_cleft", "pad_cright" "pad_cup", "pad_cdown", "pad_cleft", "pad_cright",
"pad_cmodifier"
}}; }};
static const std::array<Values, NUM_INPUTS> All = {{ static const std::array<Values, NUM_INPUTS> All = {{
A, B, X, Y, A, B, X, Y,
@ -35,7 +37,8 @@ static const std::array<Values, NUM_INPUTS> All = {{
START, SELECT, HOME, START, SELECT, HOME,
DUP, DDOWN, DLEFT, DRIGHT, DUP, DDOWN, DLEFT, DRIGHT,
SUP, SDOWN, SLEFT, SRIGHT, SUP, SDOWN, SLEFT, SRIGHT,
CUP, CDOWN, CLEFT, CRIGHT CUP, CDOWN, CLEFT, CRIGHT,
CMODIFIER
}}; }};
} }
@ -43,6 +46,7 @@ static const std::array<Values, NUM_INPUTS> All = {{
struct Values { struct Values {
// Controls // Controls
std::array<int, NativeInput::NUM_INPUTS> input_mappings; std::array<int, NativeInput::NUM_INPUTS> input_mappings;
float circle_pad_modifier_scale;
// Core // Core
int frame_skip; int frame_skip;