Skip to content

Commit

Permalink
Fallback source usages names
Browse files Browse the repository at this point in the history
Adds a list of source usages that are not displayed in the modal, but
if mappings with those usages exist, they can get a readable label.

It includes the non-overlapping usages from the mouse/gamepad sets (so
that the non-conflicting usages get proper labels even if the set they
belong to is not the currently selected one) and some alternative
gamepad trigger usages.
  • Loading branch information
jfedor2 committed Dec 2, 2024
1 parent c394335 commit c4bfa53
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config-tool-web/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,9 @@ function readable_usage_name(usage, default_to_hex = true) {
if (usage in usages['source']) {
return usages['source'][usage]['name'];
}
if (usage in usages['source_extra']) {
return usages['source_extra'][usage]['name'];
}
if (((usage & 0xFFFF0000) >>> 0) == BUTTON_USAGE_PAGE) {
return 'Button ' + (usage & 0xFFFF);
}
Expand Down
14 changes: 14 additions & 0 deletions config-tool-web/usages.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ const usages = {
"0x0009000f": { 'name': 'Button 15', 'class': 'gamepad' },
"0x00090010": { 'name': 'Button 16', 'class': 'gamepad' },
},
'source_extra': {
"0x00010038": { 'name': 'V scroll', 'class': 'mouse' },
"0x000c0238": { 'name': 'H scroll', 'class': 'mouse' },
"0x00010032": { 'name': 'Right stick X', 'class': 'gamepad' },
"0x00010035": { 'name': 'Right stick Y', 'class': 'gamepad' },
"0xfff90001": { 'name': 'D-pad left', 'class': 'gamepad' },
"0xfff90002": { 'name': 'D-pad right', 'class': 'gamepad' },
"0xfff90003": { 'name': 'D-pad up', 'class': 'gamepad' },
"0xfff90004": { 'name': 'D-pad down', 'class': 'gamepad' },
"0x00010033": { 'name': 'L2 axis', 'class': 'gamepad' },
"0x00010034": { 'name': 'R2 axis', 'class': 'gamepad' },
"0x000200c5": { 'name': 'Brake', 'class': 'mouse' },
"0x000200c4": { 'name': 'Accelerator', 'class': 'mouse' },
},
'source': {
"0x000700e0": { 'name': 'Left Control', 'class': 'keyboard' },
"0x000700e1": { 'name': 'Left Shift', 'class': 'keyboard' },
Expand Down

0 comments on commit c4bfa53

Please sign in to comment.