Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Changelog
* Runtime: added missing keyboard punctuation and special keys on HTML5, Linux and Windows platforms.
* Runtime: fixed a crash in the Graph subsystem.
* Runtime: fixed ``smoothed`` timestep policy not honoring average_cap during the very first frames.
* Runtime: Linux: fixed joypad D-pad.
* Data Compiler: fixed an issue that caused misdetected file changes before compilation.

.. _v0.61.0:
Expand Down
64 changes: 44 additions & 20 deletions src/device/main_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,29 +423,53 @@ struct Joypad
JoypadAxis::TRIGGER_RIGHT
};

// Remap triggers to [0, INT16_MAX]
s16 value = ev.value;
if (ev.number == 2 || ev.number == 5)
value = (ev.value + INT16_MAX) >> 1;

s16 *values = ev.number > 2 ? _axis[joypad_id].right : _axis[joypad_id].left;
values[axis_idx[ev.number]] = value;

if (ev.number == 2 || ev.number == 5) {
_queue->push_axis_event(InputDeviceType::JOYPAD
if (ev.number < countof(axis_map)) {
// Remap triggers to [0, INT16_MAX].
s16 value = ev.value;
if (ev.number == 2 || ev.number == 5)
value = (ev.value + INT16_MAX) >> 1;

s16 *values = ev.number > 2 ? _axis[joypad_id].right : _axis[joypad_id].left;
values[axis_idx[ev.number]] = value;

if (ev.number == 2 || ev.number == 5) {
_queue->push_axis_event(InputDeviceType::JOYPAD
, joypad_id
, axis_map[ev.number]
, 0
, 0
, values[2]
);
} else {
_queue->push_axis_event(InputDeviceType::JOYPAD
, joypad_id
, axis_map[ev.number]
, values[0]
, -values[1]
, 0
);
}
} else if (ev.number == 6) { // DPAD X axis.
_queue->push_button_event(InputDeviceType::JOYPAD
, joypad_id
, axis_map[ev.number]
, 0
, 0
, values[2]
, JoypadButton::LEFT
, ev.value < 0
);
} else if (ev.number < countof(axis_map)) {
_queue->push_axis_event(InputDeviceType::JOYPAD
_queue->push_button_event(InputDeviceType::JOYPAD
, joypad_id
, axis_map[ev.number]
, values[0]
, -values[1]
, 0
, JoypadButton::RIGHT
, ev.value > 0
);
} else if (ev.number == 7) { // DPAD Y axis.
_queue->push_button_event(InputDeviceType::JOYPAD
, joypad_id
, JoypadButton::UP
, ev.value < 0
);
_queue->push_button_event(InputDeviceType::JOYPAD
, joypad_id
, JoypadButton::DOWN
, ev.value > 0
);
}
break;
Expand Down