Android and iOS support. Change dead zone to integer % value in UI

UI: dead zone changes from 0 to 100%. Add % for Rumble too.
Support Android and iOS gamepads.
Assume legacy gamepads have an analog stick (evdev, xinput)
This commit is contained in:
Flyinghead 2023-10-30 18:28:29 +01:00
parent c0de126b2b
commit 7b71bd319c
5 changed files with 10 additions and 5 deletions

View File

@ -65,6 +65,7 @@ public:
}
else
INFO_LOG(INPUT, "using custom mapping '%s'", input_mapper->name.c_str());
hasAnalogStick = true;
}
~EvdevGamepadDevice() override
{

View File

@ -1682,16 +1682,16 @@ static void gui_display_settings()
ImGui::SameLine(0, 16 * settings.display.uiScale);
int power = gamepad->get_rumble_power();
ImGui::SetNextItemWidth(150 * settings.display.uiScale);
if (ImGui::SliderInt("Rumble", &power, 0, 100))
if (ImGui::SliderInt("Rumble", &power, 0, 100, "%d%%"))
gamepad->set_rumble_power(power);
}
if (gamepad->has_analog_stick())
{
ImGui::SameLine(0, 16 * settings.display.uiScale);
float deadzone = gamepad->get_dead_zone();
int deadzone = std::round(gamepad->get_dead_zone() * 100.f);
ImGui::SetNextItemWidth(150 * settings.display.uiScale);
if (ImGui::SliderFloat("Deadzone", &deadzone, 0.0f, 1.0f))
gamepad->set_dead_zone(deadzone);
if (ImGui::SliderInt("Dead zone", &deadzone, 0, 100, "%d%%"))
gamepad->set_dead_zone(deadzone / 100.f);
}
ImGui::NextColumn();
ImGui::PopID();

View File

@ -45,6 +45,7 @@ public:
char buf[32];
sprintf(buf, "xinput-%d", xinput_port + 1);
_unique_id = buf;
hasAnalogStick = true;
}
std::shared_ptr<InputMapping> getDefaultMapping() override {

View File

@ -107,11 +107,13 @@ public:
{
input_mapper = std::make_shared<IdentityInputMapping>();
rumbleEnabled = true;
// hasAnalogStick = true; // TODO has an analog stick but input mapping isn't persisted
}
else
{
loadMapping();
save_mapping();
hasAnalogStick = !fullAxes.empty();
}
}
~AndroidGamepadDevice() override

View File

@ -229,7 +229,7 @@ public:
[gcController.extendedGamepad.rightThumbstick.yAxis setValueChangedHandler:^(GCControllerAxisInput *axis, float value) {
gamepad_axis_input(IOS_AXIS_RY, (int)std::roundf(-32767.f * value));
}];
hasAnalogStick = true;
}
else
{
@ -491,6 +491,7 @@ public:
_name = "Virtual Gamepad";
_unique_id = "ios-virtual-gamepad";
input_mapper = getDefaultMapping();
//hasAnalogStick = true; // TODO has an analog stick but input mapping isn't persisted
}
bool is_virtual_gamepad() override { return true; }