yuzu-emu
/
yuzu
Archived
1
0
Fork 0

settings: Fix Debug controller type options

This commit is contained in:
german77 2021-10-31 10:41:44 -05:00 committed by Narr the Reg
parent 2b1b0c2a30
commit 730f078302
13 changed files with 77 additions and 95 deletions

View File

@ -100,7 +100,7 @@ struct StickStatus {
struct TriggerStatus {
AnalogStatus analog{};
bool pressed{};
ButtonStatus pressed{};
};
struct MotionSensor {
@ -119,7 +119,7 @@ struct TouchStatus {
ButtonStatus pressed{};
AnalogStatus x{};
AnalogStatus y{};
u32 id{};
int id{};
};
struct BodyColorStatus {

View File

@ -166,9 +166,10 @@ void EmulatedConsole::SetTouch(Common::Input::CallbackStatus callback,
return;
}
// TODO(german77): Remap touch id in sequential order
console.touch_state[index] = {
.position = {console.touch_values[index].x.value, console.touch_values[index].y.value},
.id = console.touch_values[index].id,
.id = static_cast<u32>(console.touch_values[index].id),
.pressed = console.touch_values[index].pressed.value,
};

View File

@ -77,7 +77,12 @@ void EmulatedController::ReloadFromSettings() {
controller.colors_state.fullkey = controller.colors_state.left;
// Other or debug controller should always be a pro controller
if (npad_id_type != NpadIdType::Other) {
SetNpadType(MapSettingsTypeToNPad(player.controller_type));
} else {
SetNpadType(NpadType::ProController);
}
if (player.connected) {
Connect();
@ -606,12 +611,12 @@ void EmulatedController::SetTrigger(Common::Input::CallbackStatus callback, std:
switch (index) {
case Settings::NativeTrigger::LTrigger:
controller.gc_trigger_state.left = static_cast<s32>(trigger.analog.value * HID_TRIGGER_MAX);
controller.npad_button_state.zl.Assign(trigger.pressed);
controller.npad_button_state.zl.Assign(trigger.pressed.value);
break;
case Settings::NativeTrigger::RTrigger:
controller.gc_trigger_state.right =
static_cast<s32>(trigger.analog.value * HID_TRIGGER_MAX);
controller.npad_button_state.zr.Assign(trigger.pressed);
controller.npad_button_state.zr.Assign(trigger.pressed.value);
break;
}

View File

@ -53,7 +53,7 @@ Common::Input::ButtonStatus TransformToButton(const Common::Input::CallbackStatu
switch (callback.type) {
case Common::Input::InputType::Analog:
case Common::Input::InputType::Trigger:
status.value = TransformToTrigger(callback).pressed;
status.value = TransformToTrigger(callback).pressed.value;
break;
case Common::Input::InputType::Button:
status = callback.button_status;
@ -222,7 +222,7 @@ Common::Input::TriggerStatus TransformToTrigger(const Common::Input::CallbackSta
// Set button status
if (calculate_button_value) {
status.pressed = value > properties.threshold;
status.pressed.value = value > properties.threshold;
}
// Adjust if value is inverted

View File

@ -188,7 +188,6 @@ private:
std::string WriteCommandAxis(TasAnalog data) const;
size_t script_length{0};
bool is_old_input_saved{false};
bool is_recording{false};
bool is_running{false};
bool needs_reset{false};

View File

@ -12,7 +12,7 @@ namespace InputCommon {
class TouchFromButtonDevice final : public Common::Input::InputDevice {
public:
using Button = std::unique_ptr<Common::Input::InputDevice>;
TouchFromButtonDevice(Button button_, u32 touch_id_, float x_, float y_)
TouchFromButtonDevice(Button button_, int touch_id_, float x_, float y_)
: button(std::move(button_)), touch_id(touch_id_), x(x_), y(y_) {
Common::Input::InputCallback button_up_callback{
[this](Common::Input::CallbackStatus callback_) { UpdateButtonStatus(callback_); }};
@ -52,7 +52,7 @@ public:
private:
Button button;
const u32 touch_id;
const int touch_id;
const float x;
const float y;
const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false};

View File

@ -315,7 +315,7 @@ void InputEngine::TriggerOnMotionChange(const PadIdentifier& identifier, int mot
bool InputEngine::IsInputIdentifierEqual(const InputIdentifier& input_identifier,
const PadIdentifier& identifier, EngineInputType type,
std::size_t index) const {
int index) const {
if (input_identifier.type != type) {
return false;
}

View File

@ -96,7 +96,7 @@ struct MappingCallback {
struct InputIdentifier {
PadIdentifier identifier;
EngineInputType type;
std::size_t index;
int index;
UpdateCallback callback;
};
@ -216,12 +216,11 @@ private:
bool IsInputIdentifierEqual(const InputIdentifier& input_identifier,
const PadIdentifier& identifier, EngineInputType type,
std::size_t index) const;
int index) const;
mutable std::mutex mutex;
mutable std::mutex mutex_callback;
bool configuring{false};
bool is_callback_enabled{true};
const std::string input_engine;
int last_callback_key = 0;
std::unordered_map<PadIdentifier, ControllerData> controller_list;

View File

@ -18,7 +18,7 @@ public:
class InputFromButton final : public Common::Input::InputDevice {
public:
explicit InputFromButton(PadIdentifier identifier_, u32 button_, bool toggle_, bool inverted_,
explicit InputFromButton(PadIdentifier identifier_, int button_, bool toggle_, bool inverted_,
InputEngine* input_engine_)
: identifier(identifier_), button(button_), toggle(toggle_), inverted(inverted_),
input_engine(input_engine_) {
@ -69,7 +69,7 @@ public:
private:
const PadIdentifier identifier;
const u32 button;
const int button;
const bool toggle;
const bool inverted;
int callback_key;
@ -79,7 +79,7 @@ private:
class InputFromHatButton final : public Common::Input::InputDevice {
public:
explicit InputFromHatButton(PadIdentifier identifier_, u32 button_, u8 direction_, bool toggle_,
explicit InputFromHatButton(PadIdentifier identifier_, int button_, u8 direction_, bool toggle_,
bool inverted_, InputEngine* input_engine_)
: identifier(identifier_), button(button_), direction(direction_), toggle(toggle_),
inverted(inverted_), input_engine(input_engine_) {
@ -130,7 +130,7 @@ public:
private:
const PadIdentifier identifier;
const u32 button;
const int button;
const u8 direction;
const bool toggle;
const bool inverted;
@ -141,7 +141,7 @@ private:
class InputFromStick final : public Common::Input::InputDevice {
public:
explicit InputFromStick(PadIdentifier identifier_, u32 axis_x_, u32 axis_y_,
explicit InputFromStick(PadIdentifier identifier_, int axis_x_, int axis_y_,
Common::Input::AnalogProperties properties_x_,
Common::Input::AnalogProperties properties_y_,
InputEngine* input_engine_)
@ -211,8 +211,8 @@ public:
private:
const PadIdentifier identifier;
const u32 axis_x;
const u32 axis_y;
const int axis_x;
const int axis_y;
const Common::Input::AnalogProperties properties_x;
const Common::Input::AnalogProperties properties_y;
int callback_key_x;
@ -224,8 +224,8 @@ private:
class InputFromTouch final : public Common::Input::InputDevice {
public:
explicit InputFromTouch(PadIdentifier identifier_, u32 touch_id_, u32 button_, bool toggle_,
bool inverted_, u32 axis_x_, u32 axis_y_,
explicit InputFromTouch(PadIdentifier identifier_, int touch_id_, int button_, bool toggle_,
bool inverted_, int axis_x_, int axis_y_,
Common::Input::AnalogProperties properties_x_,
Common::Input::AnalogProperties properties_y_,
InputEngine* input_engine_)
@ -302,12 +302,12 @@ public:
private:
const PadIdentifier identifier;
const u32 touch_id;
const u32 button;
const int touch_id;
const int button;
const bool toggle;
const bool inverted;
const u32 axis_x;
const u32 axis_y;
const int axis_x;
const int axis_y;
const Common::Input::AnalogProperties properties_x;
const Common::Input::AnalogProperties properties_y;
int callback_key_button;
@ -321,8 +321,8 @@ private:
class InputFromTrigger final : public Common::Input::InputDevice {
public:
explicit InputFromTrigger(PadIdentifier identifier_, u32 button_, bool toggle_, bool inverted_,
u32 axis_, Common::Input::AnalogProperties properties_,
explicit InputFromTrigger(PadIdentifier identifier_, int button_, bool toggle_, bool inverted_,
int axis_, Common::Input::AnalogProperties properties_,
InputEngine* input_engine_)
: identifier(identifier_), button(button_), toggle(toggle_), inverted(inverted_),
axis(axis_), properties(properties_), input_engine(input_engine_) {
@ -355,9 +355,14 @@ public:
.raw_value = input_engine->GetAxis(identifier, axis),
.properties = properties,
};
const Common::Input::ButtonStatus button_status{
.value = input_engine->GetButton(identifier, button),
.inverted = inverted,
.toggle = toggle,
};
return {
.analog = analog_status,
.pressed = input_engine->GetButton(identifier, button),
.pressed = button_status,
};
}
@ -368,19 +373,19 @@ public:
};
if (status.trigger_status.analog.raw_value != last_axis_value ||
status.trigger_status.pressed != last_button_value) {
status.trigger_status.pressed.value != last_button_value) {
last_axis_value = status.trigger_status.analog.raw_value;
last_button_value = status.trigger_status.pressed;
last_button_value = status.trigger_status.pressed.value;
TriggerOnChange(status);
}
}
private:
const PadIdentifier identifier;
const u32 button;
const int button;
const bool toggle;
const bool inverted;
const u32 axis;
const int axis;
const Common::Input::AnalogProperties properties;
int callback_key_button;
int axis_callback_key;
@ -391,7 +396,7 @@ private:
class InputFromAnalog final : public Common::Input::InputDevice {
public:
explicit InputFromAnalog(PadIdentifier identifier_, u32 axis_,
explicit InputFromAnalog(PadIdentifier identifier_, int axis_,
Common::Input::AnalogProperties properties_,
InputEngine* input_engine_)
: identifier(identifier_), axis(axis_), properties(properties_),
@ -432,7 +437,7 @@ public:
private:
const PadIdentifier identifier;
const u32 axis;
const int axis;
const Common::Input::AnalogProperties properties;
int callback_key;
float last_axis_value;
@ -493,7 +498,7 @@ private:
class InputFromMotion final : public Common::Input::InputDevice {
public:
explicit InputFromMotion(PadIdentifier identifier_, u32 motion_sensor_,
explicit InputFromMotion(PadIdentifier identifier_, int motion_sensor_,
InputEngine* input_engine_)
: identifier(identifier_), motion_sensor(motion_sensor_), input_engine(input_engine_) {
UpdateCallback engine_callback{[this]() { OnChange(); }};
@ -539,14 +544,14 @@ public:
private:
const PadIdentifier identifier;
const u32 motion_sensor;
const int motion_sensor;
int callback_key;
InputEngine* input_engine;
};
class InputFromAxisMotion final : public Common::Input::InputDevice {
public:
explicit InputFromAxisMotion(PadIdentifier identifier_, u32 axis_x_, u32 axis_y_, u32 axis_z_,
explicit InputFromAxisMotion(PadIdentifier identifier_, int axis_x_, int axis_y_, int axis_z_,
Common::Input::AnalogProperties properties_x_,
Common::Input::AnalogProperties properties_y_,
Common::Input::AnalogProperties properties_z_,
@ -634,9 +639,9 @@ public:
private:
const PadIdentifier identifier;
const u32 axis_x;
const u32 axis_y;
const u32 axis_z;
const int axis_x;
const int axis_y;
const int axis_z;
const Common::Input::AnalogProperties properties_x;
const Common::Input::AnalogProperties properties_y;
const Common::Input::AnalogProperties properties_z;
@ -680,8 +685,8 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateButtonDevice(
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
};
const auto button_id = static_cast<u32>(params.Get("button", 0));
const auto keyboard_key = static_cast<u32>(params.Get("code", 0));
const auto button_id = params.Get("button", 0);
const auto keyboard_key = params.Get("code", 0);
const auto toggle = params.Get("toggle", false);
const auto inverted = params.Get("inverted", false);
input_engine->PreSetController(identifier);
@ -703,7 +708,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateHatButtonDevice(
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
};
const auto button_id = static_cast<u32>(params.Get("hat", 0));
const auto button_id = params.Get("hat", 0);
const auto direction = input_engine->GetHatButtonId(params.Get("direction", ""));
const auto toggle = params.Get("toggle", false);
const auto inverted = params.Get("inverted", false);
@ -725,7 +730,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateStickDevice(
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
};
const auto axis_x = static_cast<u32>(params.Get("axis_x", 0));
const auto axis_x = params.Get("axis_x", 0);
const Common::Input::AnalogProperties properties_x = {
.deadzone = deadzone,
.range = range,
@ -734,7 +739,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateStickDevice(
.inverted = params.Get("invert_x", "+") == "-",
};
const auto axis_y = static_cast<u32>(params.Get("axis_y", 1));
const auto axis_y = params.Get("axis_y", 1);
const Common::Input::AnalogProperties properties_y = {
.deadzone = deadzone,
.range = range,
@ -757,7 +762,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateAnalogDevice(
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
};
const auto axis = static_cast<u32>(params.Get("axis", 0));
const auto axis = params.Get("axis", 0);
const Common::Input::AnalogProperties properties = {
.deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f),
.range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f),
@ -778,11 +783,11 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTriggerDevice(
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
};
const auto button = static_cast<u32>(params.Get("button", 0));
const auto button = params.Get("button", 0);
const auto toggle = params.Get("toggle", false);
const auto inverted = params.Get("inverted", false);
const auto axis = static_cast<u32>(params.Get("axis", 0));
const auto axis = params.Get("axis", 0);
const Common::Input::AnalogProperties properties = {
.deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f),
.range = std::clamp(params.Get("range", 1.0f), 0.25f, 2.50f),
@ -809,11 +814,11 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice(
.pad = static_cast<std::size_t>(params.Get("pad", 0)),
};
const auto button = static_cast<u32>(params.Get("button", 0));
const auto button = params.Get("button", 0);
const auto toggle = params.Get("toggle", false);
const auto inverted = params.Get("inverted", false);
const auto axis_x = static_cast<u32>(params.Get("axis_x", 0));
const auto axis_x = params.Get("axis_x", 0);
const Common::Input::AnalogProperties properties_x = {
.deadzone = deadzone,
.range = range,
@ -822,7 +827,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice(
.inverted = params.Get("invert_x", "+") == "-",
};
const auto axis_y = static_cast<u32>(params.Get("axis_y", 1));
const auto axis_y = params.Get("axis_y", 1);
const Common::Input::AnalogProperties properties_y = {
.deadzone = deadzone,
.range = range,
@ -869,7 +874,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice(
const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f);
const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f);
const auto axis_x = static_cast<u32>(params.Get("axis_x", 0));
const auto axis_x = params.Get("axis_x", 0);
const Common::Input::AnalogProperties properties_x = {
.deadzone = deadzone,
.range = range,
@ -878,7 +883,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice(
.inverted = params.Get("invert_x", "+") == "-",
};
const auto axis_y = static_cast<u32>(params.Get("axis_y", 1));
const auto axis_y = params.Get("axis_y", 1);
const Common::Input::AnalogProperties properties_y = {
.deadzone = deadzone,
.range = range,
@ -887,7 +892,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice(
.inverted = params.Get("invert_y", "+") != "+",
};
const auto axis_z = static_cast<u32>(params.Get("axis_z", 1));
const auto axis_z = params.Get("axis_z", 1);
const Common::Input::AnalogProperties properties_z = {
.deadzone = deadzone,
.range = range,

View File

@ -26,8 +26,6 @@
namespace {
constexpr std::size_t HANDHELD_INDEX = 8;
void UpdateController(Core::HID::EmulatedController* controller,
Core::HID::NpadType controller_type, bool connected) {
if (controller->IsConnected()) {

View File

@ -38,8 +38,6 @@ const std::array<std::string, ConfigureInputPlayer::ANALOG_SUB_BUTTONS_NUM>
namespace {
constexpr std::size_t HANDHELD_INDEX = 8;
QString GetKeyName(int key_code) {
switch (key_code) {
case Qt::Key_Shift:

View File

@ -89,31 +89,6 @@
<height>21</height>
</size>
</property>
<item>
<property name="text">
<string>Pro Controller</string>
</property>
</item>
<item>
<property name="text">
<string>Dual Joycons</string>
</property>
</item>
<item>
<property name="text">
<string>Left Joycon</string>
</property>
</item>
<item>
<property name="text">
<string>Right Joycon</string>
</property>
</item>
<item>
<property name="text">
<string>Handheld</string>
</property>
</item>
</widget>
</item>
</layout>

View File

@ -118,7 +118,7 @@ void PlayerControlPreview::ResetInputs() {
});
trigger_values.fill({
.analog = {.value = 0, .properties = {0, 1, 0}},
.pressed = false,
.pressed = {.value = false},
});
update();
}
@ -2001,11 +2001,11 @@ void PlayerControlPreview::DrawGCTriggers(QPainter& p, const QPointF center,
// Left trigger
p.setPen(colors.outline);
p.setBrush(left_trigger.pressed ? colors.highlight : colors.button);
p.setBrush(left_trigger.pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qleft_trigger);
// Right trigger
p.setBrush(right_trigger.pressed ? colors.highlight : colors.button);
p.setBrush(right_trigger.pressed.value ? colors.highlight : colors.button);
DrawPolygon(p, qright_trigger);
// Draw L text
@ -2587,15 +2587,17 @@ void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center,
case Direction::Up:
arrow_button[point] = center + QPointF(up_arrow_x * size, up_arrow_y * size);
break;
case Direction::Left:
arrow_button[point] = center + QPointF(up_arrow_y * size, up_arrow_x * size);
break;
case Direction::Right:
arrow_button[point] = center + QPointF(-up_arrow_y * size, up_arrow_x * size);
break;
case Direction::Down:
arrow_button[point] = center + QPointF(up_arrow_x * size, -up_arrow_y * size);
break;
case Direction::Left:
// Compiler doesn't optimize this correctly
arrow_button[point] = center + QPointF(up_arrow_button[point * 2 + 1] * size,
up_arrow_button[point * 2 + 0] * size);
break;
case Direction::None:
break;
}
@ -2610,15 +2612,15 @@ void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center,
case Direction::Up:
offset = QPoint(0, -20 * size);
break;
case Direction::Left:
offset = QPoint(-20 * size, 0);
break;
case Direction::Right:
offset = QPoint(20 * size, 0);
break;
case Direction::Down:
offset = QPoint(0, 20 * size);
break;
case Direction::Left:
offset = QPoint(-20 * size, 0);
break;
case Direction::None:
offset = QPoint(0, 0);
break;