-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Improved key rendering for HID usages.
* Have short/med/long override labels for HID usages, and use CSS container queries to select the right one for display based on key sizing.
- Loading branch information
1 parent
1e4e8a2
commit bf40ddc
Showing
10 changed files
with
202 additions
and
115 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,85 @@ | ||
{ | ||
"7": { | ||
"30": "1", | ||
"31": "2", | ||
"32": "3", | ||
"33": "4", | ||
"34": "5", | ||
"35": "6", | ||
"36": "7", | ||
"37": "8", | ||
"38": "9", | ||
"39": "0", | ||
"40": "Ret", | ||
"41": "Esc", | ||
"42": "BSp", | ||
"44": "␣", | ||
"45": "-", | ||
"46": "=", | ||
"47": "{", | ||
"48": "}", | ||
"49": "\\", | ||
"50": "NUHS", | ||
"51": ";", | ||
"52": "'", | ||
"53": "`", | ||
"54": ",", | ||
"55": ".", | ||
"56": "/", | ||
"57": "Cap", | ||
"70": "PrSc", | ||
"71": "ScLk", | ||
"73": "Ins", | ||
"75": "PgUp", | ||
"76": "Del", | ||
"78": "PgDn", | ||
"79": "→", | ||
"80": "←", | ||
"81": "↓", | ||
"82": "↑", | ||
"83": "Num", | ||
"84": "/", | ||
"85": "*", | ||
"86": "-", | ||
"87": "+", | ||
"88": "Enter", | ||
"89": "1 End", | ||
"90": "2 ↓", | ||
"91": "3 PgDn", | ||
"92": "4 ←", | ||
"93": "5", | ||
"94": "6 →", | ||
"95": "7 Home", | ||
"96": "8 ↑", | ||
"97": "9 PgUp", | ||
"98": "0 Ins", | ||
"99": ". Del", | ||
"100": "NUBS", | ||
"103": "=", | ||
"133": ",", | ||
"134": "=", | ||
"176": "00", | ||
"177": "000", | ||
"224": "Ctrl", | ||
"225": "Shift", | ||
"226": "Alt", | ||
"227": "GUI", | ||
"228": "Ctrl", | ||
"229": "Shift", | ||
"230": "AltGr", | ||
"231": "GUI" | ||
"30": { "short": "1" }, | ||
"31": { "short": "2" }, | ||
"32": { "short": "3" }, | ||
"33": { "short": "4" }, | ||
"34": { "short": "5" }, | ||
"35": { "short": "6" }, | ||
"36": { "short": "7" }, | ||
"37": { "short": "8" }, | ||
"38": { "short": "9" }, | ||
"39": { "short": "0" }, | ||
"40": { "short": "Ret", "med": "Return" }, | ||
"41": { "short": "Esc", "long": "Escape" }, | ||
"42": { "short": "BkSp", "med": "BkSpc", "long": "Backspace" }, | ||
"44": { "short": "␣", "med": "Space" }, | ||
"45": { "short": "-", "med": "Dash" }, | ||
"46": { "short": "=", "med": "Equals" }, | ||
"47": { "short": "{" }, | ||
"48": { "short": "}" }, | ||
"49": { "short": "\\" }, | ||
"50": { "short": "NUHS", "long": "NonUS Hash" }, | ||
"51": { "short": ";" }, | ||
"52": { "short": "'" }, | ||
"53": { "short": "`" }, | ||
"54": { "short": "," }, | ||
"55": { "short": "." }, | ||
"56": { "short": "/" }, | ||
"57": { "short": "Cap", "long": "Caps Lock" }, | ||
"70": { "short": "PrSc", "long": "Print Scr" }, | ||
"71": { "short": "ScLk", "long": "ScrollLock" }, | ||
"72": { "short": "Paus", "med": "Pause" }, | ||
"73": { "short": "Ins", "med": "Insert" }, | ||
"75": { "short": "PgUp", "med": "PageUp", "long": "Page Up" }, | ||
"76": { "short": "Del", "med": "Delete" }, | ||
"78": { "short": "PgDn", "med": "PageDn", "long": "Page Down" }, | ||
"79": { "short": "→" }, | ||
"80": { "short": "←" }, | ||
"81": { "short": "↓" }, | ||
"82": { "short": "↑" }, | ||
"83": { "short": "Num", "med": "NumLck", "long": "Num Lock" }, | ||
"84": { "short": "/" }, | ||
"85": { "short": "*" }, | ||
"86": { "short": "-" }, | ||
"87": { "short": "+" }, | ||
"88": { "short": "Ent", "med": "KP Ent", "long": "KP Enter" }, | ||
"89": { "short": "1 En", "med": "1 End" }, | ||
"90": { "short": "2 ↓" }, | ||
"91": { "short": "3 PD", "med": "3 PgDn" }, | ||
"92": { "short": "4 ←" }, | ||
"93": { "short": "5" }, | ||
"94": { "short": "6 →" }, | ||
"95": { "short": "7 Hm", "med": "7 Home" }, | ||
"96": { "short": "8 ↑" }, | ||
"97": { "short": "9 PU", "med": "9 PgUp" }, | ||
"98": { "short": "0 In", "med": "0 Ins", "long": "0 Insert" }, | ||
"99": { "short": ". Dl", "med": ". Del", "long": ". Delete" }, | ||
"101": { "short": "Appl", "med": "Appl", "long": "Applicat'n" }, | ||
"102": { "short": "Power", "med": "Power" }, | ||
"100": { "short": "NUBS" }, | ||
"103": { "short": "=" }, | ||
"133": { "short": "," }, | ||
"134": { "short": "=" }, | ||
"176": { "short": "00" }, | ||
"177": { "short": "000" }, | ||
"224": { "short": "Ctrl", "med": "L Ctrl" }, | ||
"225": { "short": "Shft", "med": "L Shft", "long": "L Shift" }, | ||
"226": { "short": "Alt", "med": "L Alt", "long": "Left Alt" }, | ||
"227": { "short": "GUI", "med": "L GUI", "long": "Left GUI" }, | ||
"228": { "short": "Ctrl", "med": "R Ctrl" }, | ||
"229": { "short": "Shft", "med": "R Shft", "long": "R Shift" }, | ||
"230": { "short": "AltG", "med": "AltGr" }, | ||
"231": { "short": "GUI", "med": "R GUI", "long": "Right GUI" } | ||
}, | ||
"12": { | ||
"111": "🔆", | ||
"112": "🔅", | ||
"181": "⇥", | ||
"182": "⇤", | ||
"205": "⏯️", | ||
"226": "🔇", | ||
"233": "🔊", | ||
"234": "🔉" | ||
"111": { "short": "🔆" }, | ||
"112": { "short": "🔅" }, | ||
"181": { "short": "⇥" }, | ||
"182": { "short": "⇤" }, | ||
"205": { "short": "⏯️" }, | ||
"226": { "short": "🔇" }, | ||
"233": { "short": "🔊" }, | ||
"234": { "short": "🔉" } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { | ||
hid_usage_get_labels, | ||
hid_usage_page_and_id_from_usage, | ||
} from "../hid-usages"; | ||
|
||
export interface HidUsageLabelProps { | ||
hid_usage: number; | ||
} | ||
|
||
function remove_prefix(s?: string) { | ||
return s?.replace(/^Keyboard /, ""); | ||
} | ||
|
||
export const HidUsageLabel = ({ hid_usage }: HidUsageLabelProps) => { | ||
let [page, id] = hid_usage_page_and_id_from_usage(hid_usage); | ||
|
||
// TODO: Do something with implicit mods! | ||
page &= 0xff; | ||
|
||
let labels = hid_usage_get_labels(page, id); | ||
|
||
return ( | ||
<span | ||
className="@[10em]:before:content-[attr(data-long-content)] @[6em]:before:content-[attr(data-med-content)] before:content-[attr(aria-label)]" | ||
aria-label={remove_prefix(labels.short)} | ||
data-med-content={remove_prefix(labels.med || labels.short)} | ||
data-long-content={remove_prefix( | ||
labels.long || labels.med || labels.short | ||
)} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.