Merge pull request #101 from adamgp/master
Moving hardcoded dead zone into cfg file per controller mapping.
This commit is contained in:
commit
fbe9cc3936
|
@ -218,7 +218,7 @@ bool GamepadDevice::gamepad_axis_input(u32 code, int value)
|
|||
}
|
||||
// Radial dead zone
|
||||
// FIXME compute both axes at the same time
|
||||
if ((float)(v * v + *other_axis * *other_axis) < _dead_zone * _dead_zone * 128.f * 128.f)
|
||||
if ((float)(v * v + *other_axis * *other_axis) < input_mapper->dead_zone * input_mapper->dead_zone * 128.f * 128.f)
|
||||
{
|
||||
*this_axis = 0;
|
||||
*other_axis = 0;
|
||||
|
|
|
@ -89,7 +89,6 @@ private:
|
|||
double _detection_start_time = 0.0;
|
||||
input_detected_cb _input_detected;
|
||||
bool _remappable;
|
||||
float _dead_zone = 0.1f;
|
||||
|
||||
static std::vector<std::shared_ptr<GamepadDevice>> _gamepads;
|
||||
static std::mutex _gamepads_mutex;
|
||||
|
|
|
@ -67,7 +67,7 @@ axis_list[] =
|
|||
{
|
||||
{ DC_AXIS_X, "dreamcast", "axis_x", "compat", "axis_x_inverted" },
|
||||
{ DC_AXIS_Y, "dreamcast", "axis_y", "compat", "axis_y_inverted" },
|
||||
{ DC_AXIS_LT, "dreamcast", "axis_trigger_left", "compat", "axis_trigger_left_inverted" },
|
||||
{ DC_AXIS_LT, "dreamcast", "axis_trigger_left", "compat", "axis_trigger_left_inverted" },
|
||||
{ DC_AXIS_RT, "dreamcast", "axis_trigger_right", "compat", "axis_trigger_right_inverted" },
|
||||
{ DC_AXIS_X2, "dreamcast", "axis_right_x", "compat", "axis_right_x_inverted" },
|
||||
{ DC_AXIS_Y2, "dreamcast", "axis_right_y", "compat", "axis_right_y_inverted" },
|
||||
|
@ -137,6 +137,12 @@ void InputMapping::load(FILE* fp)
|
|||
|
||||
this->name = mf.get("emulator", "mapping_name", "<Unknown>");
|
||||
|
||||
int dz = mf.get_int("emulator", "dead_zone", 10);
|
||||
dz = std::min(dz, 100);
|
||||
dz = std::max(dz, 0);
|
||||
|
||||
this->dead_zone = ((float) dz) / 100;
|
||||
|
||||
for (u32 i = 0; i < ARRAY_SIZE(button_list); i++)
|
||||
{
|
||||
int button_code = mf.get_int(button_list[i].section, button_list[i].option, -1);
|
||||
|
@ -212,6 +218,7 @@ bool InputMapping::save(const char *name)
|
|||
ConfigFile mf;
|
||||
|
||||
mf.set("emulator", "mapping_name", this->name);
|
||||
mf.set_int("emulator", "dead_zone", this->dead_zone * 100);
|
||||
|
||||
for (u32 i = 0; i < ARRAY_SIZE(button_list); i++)
|
||||
{
|
||||
|
|
|
@ -30,12 +30,14 @@ public:
|
|||
InputMapping() {}
|
||||
InputMapping(const InputMapping& other) {
|
||||
name = other.name;
|
||||
dead_zone = other.dead_zone;
|
||||
buttons = other.buttons;
|
||||
axes = other.axes;
|
||||
axes_inverted = other.axes_inverted;
|
||||
}
|
||||
|
||||
std::string name;
|
||||
float dead_zone;
|
||||
|
||||
DreamcastKey get_button_id(u32 code)
|
||||
{
|
||||
|
@ -91,6 +93,8 @@ class IdentityInputMapping : public InputMapping
|
|||
public:
|
||||
IdentityInputMapping() {
|
||||
name = "Default";
|
||||
dead_zone = 0.1f;
|
||||
|
||||
for (int i = 0; i < 32; i++)
|
||||
set_button((DreamcastKey)(1 << i), 1 << i);
|
||||
set_axis(DC_AXIS_X, DC_AXIS_X, false);
|
||||
|
|
Loading…
Reference in New Issue