Skip to content

Commit

Permalink
feat(interception): add all missing interception bytes (jtroo#1208)
Browse files Browse the repository at this point in the history
Ensure all bytes coming from Interception can still be read by
Rust library users even if there is no nice-looking/human-readable name
defined for it.
  • Loading branch information
jtroo authored and eugenesvk committed Sep 12, 2024
1 parent 40d4cdf commit 4b27fcd
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 41 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ members = [
"helper",
]
exclude = [
"interception",
"key-sort-add",
"wasm",
"key-sort-add",
]
Expand Down Expand Up @@ -105,7 +107,7 @@ native-windows-gui = { version = "1.0.13", default-features = false}
# native-windows-derive = { version = "1.0.5", default_features = false, optional = true }
lazy_static = { version = "1.4.0", optional = true }
regex = { version = "1.10.4", optional = true }
kanata-interception = { version = "0.2.0", optional = true }
kanata-interception = { version = "0.3.0", optional = true }
muldiv = { version = "1.0.1", optional = true }
strip-ansi-escapes = { version = "0.2.0", optional = true }

Expand Down
5 changes: 4 additions & 1 deletion interception/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[workspace]
members = ["."]

[package]
name = "kanata-interception"
description = "Safe wrapper for Interception. Forked for use with kanata."
version = "0.2.0"
version = "0.3.0"
authors = ["Joe Kaushal <[email protected]>"]
edition = "2018"
repository = "https://github.com/jtroo/kanata"
Expand Down
184 changes: 152 additions & 32 deletions interception/src/scancode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,10 @@ pub enum ScanCode {
I = 0x17,
O = 0x18,
P = 0x19,

LeftBracket = 0x1A,
RightBracket = 0x1B,
Enter = 0x1C,

LeftControl = 0x1D,

A = 0x1E,
S = 0x1F,
D = 0x20,
Expand All @@ -50,21 +47,18 @@ pub enum ScanCode {
J = 0x24,
K = 0x25,
L = 0x26,

SemiColon = 0x27,
Apostrophe = 0x28,
Grave = 0x29,
LeftShift = 0x2A,
BackSlash = 0x2B,

Z = 0x2C,
X = 0x2D,
C = 0x2E,
V = 0x2F,
B = 0x30,
N = 0x31,
M = 0x32,

Comma = 0x33,
Period = 0x34,
Slash = 0x35,
Expand All @@ -73,7 +67,6 @@ pub enum ScanCode {
LeftAlt = 0x38,
Space = 0x39,
CapsLock = 0x3A,

F1 = 0x3B,
F2 = 0x3C,
F3 = 0x3D,
Expand All @@ -84,46 +77,37 @@ pub enum ScanCode {
F8 = 0x42,
F9 = 0x43,
F10 = 0x44,

NumLock = 0x45,
ScrollLock = 0x46,

Numpad7 = 0x47,
Numpad8 = 0x48,
Numpad9 = 0x49,

NumpadMinus = 0x4A,

Numpad4 = 0x4B,
Numpad5 = 0x4C,
Numpad6 = 0x4D,

NumpadPlus = 0x4E,

Numpad1 = 0x4F,
Numpad2 = 0x50,
Numpad3 = 0x51,
Numpad0 = 0x52,

NumpadPeriod = 0x53,
AltPrintScreen = 0x54, /* Alt + print screen. */
Int1 = 0x56, /* Key between the left shift and Z. */

AltPrintScreen = 0x54,
SC_55 = 0x55,
Int1 = 0x56,
F11 = 0x57,
F12 = 0x58,

Oem1 = 0x5A, /* VK_OEM_WSCTRL */
Oem2 = 0x5B, /* VK_OEM_FINISH */
Oem3 = 0x5C, /* VK_OEM_JUMP */

SC_59 = 0x59,
Oem1 = 0x5A,
Oem2 = 0x5B,
Oem3 = 0x5C,
EraseEOF = 0x5D,

Oem4 = 0x5E, /* VK_OEM_BACKTAB */
Oem5 = 0x5F, /* VK_OEM_AUTO */

Oem4 = 0x5E,
Oem5 = 0x5F,
SC_60 = 0x60,
SC_61 = 0x61,
Zoom = 0x62,
Help = 0x63,

F13 = 0x64,
F14 = 0x65,
F15 = 0x66,
Expand All @@ -135,13 +119,149 @@ pub enum ScanCode {
F21 = 0x6C,
F22 = 0x6D,
F23 = 0x6E,

Oem6 = 0x6F, /* VK_OEM_PA3 */
Oem6 = 0x6F,
Katakana = 0x70,
Oem7 = 0x71, /* VK_OEM_RESET */
Oem7 = 0x71,
SC_72 = 0x72,
SC_73 = 0x73,
SC_74 = 0x74,
SC_75 = 0x75,
F24 = 0x76,

SBCSChar = 0x77,
SC_78 = 0x78,
Convert = 0x79,
NonConvert = 0x7B, /* VK_OEM_PA1 */
SC_7A = 0x7A,
NonConvert = 0x7B,
SC_7C = 0x7C,
SC_7D = 0x7D,
SC_7E = 0x7E,
SC_7F = 0x7F,
SC_80 = 0x80,
SC_81 = 0x81,
SC_82 = 0x82,
SC_83 = 0x83,
SC_84 = 0x84,
SC_85 = 0x85,
SC_86 = 0x86,
SC_87 = 0x87,
SC_88 = 0x88,
SC_89 = 0x89,
SC_8A = 0x8A,
SC_8B = 0x8B,
SC_8C = 0x8C,
SC_8D = 0x8D,
SC_8E = 0x8E,
SC_8F = 0x8F,
SC_90 = 0x90,
SC_91 = 0x91,
SC_92 = 0x92,
SC_93 = 0x93,
SC_94 = 0x94,
SC_95 = 0x95,
SC_96 = 0x96,
SC_97 = 0x97,
SC_98 = 0x98,
SC_99 = 0x99,
SC_9A = 0x9A,
SC_9B = 0x9B,
SC_9C = 0x9C,
SC_9D = 0x9D,
SC_9E = 0x9E,
SC_9F = 0x9F,
SC_A0 = 0xA0,
SC_A1 = 0xA1,
SC_A2 = 0xA2,
SC_A3 = 0xA3,
SC_A4 = 0xA4,
SC_A5 = 0xA5,
SC_A6 = 0xA6,
SC_A7 = 0xA7,
SC_A8 = 0xA8,
SC_A9 = 0xA9,
SC_AA = 0xAA,
SC_AB = 0xAB,
SC_AC = 0xAC,
SC_AD = 0xAD,
SC_AE = 0xAE,
SC_AF = 0xAF,
SC_B0 = 0xB0,
SC_B1 = 0xB1,
SC_B2 = 0xB2,
SC_B3 = 0xB3,
SC_B4 = 0xB4,
SC_B5 = 0xB5,
SC_B6 = 0xB6,
SC_B7 = 0xB7,
SC_B8 = 0xB8,
SC_B9 = 0xB9,
SC_BA = 0xBA,
SC_BB = 0xBB,
SC_BC = 0xBC,
SC_BD = 0xBD,
SC_BE = 0xBE,
SC_BF = 0xBF,
SC_C0 = 0xC0,
SC_C1 = 0xC1,
SC_C2 = 0xC2,
SC_C3 = 0xC3,
SC_C4 = 0xC4,
SC_C5 = 0xC5,
SC_C6 = 0xC6,
SC_C7 = 0xC7,
SC_C8 = 0xC8,
SC_C9 = 0xC9,
SC_CA = 0xCA,
SC_CB = 0xCB,
SC_CC = 0xCC,
SC_CD = 0xCD,
SC_CE = 0xCE,
SC_CF = 0xCF,
SC_D0 = 0xD0,
SC_D1 = 0xD1,
SC_D2 = 0xD2,
SC_D3 = 0xD3,
SC_D4 = 0xD4,
SC_D5 = 0xD5,
SC_D6 = 0xD6,
SC_D7 = 0xD7,
SC_D8 = 0xD8,
SC_D9 = 0xD9,
SC_DA = 0xDA,
SC_DB = 0xDB,
SC_DC = 0xDC,
SC_DD = 0xDD,
SC_DE = 0xDE,
SC_DF = 0xDF,
SC_E0 = 0xE0,
SC_E1 = 0xE1,
SC_E2 = 0xE2,
SC_E3 = 0xE3,
SC_E4 = 0xE4,
SC_E5 = 0xE5,
SC_E6 = 0xE6,
SC_E7 = 0xE7,
SC_E8 = 0xE8,
SC_E9 = 0xE9,
SC_EA = 0xEA,
SC_EB = 0xEB,
SC_EC = 0xEC,
SC_ED = 0xED,
SC_EE = 0xEE,
SC_EF = 0xEF,
SC_F0 = 0xF0,
SC_F1 = 0xF1,
SC_F2 = 0xF2,
SC_F3 = 0xF3,
SC_F4 = 0xF4,
SC_F5 = 0xF5,
SC_F6 = 0xF6,
SC_F7 = 0xF7,
SC_F8 = 0xF8,
SC_F9 = 0xF9,
SC_FA = 0xFA,
SC_FB = 0xFB,
SC_FC = 0xFC,
SC_FD = 0xFD,
SC_FE = 0xFE,
SC_NonExtendMax = 0xFF,
}
3 changes: 3 additions & 0 deletions key-sort-add/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[workspace]
members = ["."]

[package]
name = "key-sort-add"
version = "0.1.0"
Expand Down
13 changes: 10 additions & 3 deletions key-sort-add/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ fn main() {
.map(|l| {
let mut segments = l.trim_end_matches(',').trim().split(" = ");
let key = segments.next().expect("a string");
let num: u16 = str::parse(segments.next().expect("string after =")).expect("u16");
let num: u16 = u16::from_str_radix(
segments
.next()
.map(|s| s.trim_start_matches("0x"))
.expect("string after ="),
16,
)
.expect("u16");
(key.to_owned(), num)
})
.collect::<Vec<_>>();
Expand All @@ -36,12 +43,12 @@ fn main() {
for cur in cur_key {
let prev = prev_key.next().expect("lagging iterator is valid");
for missing in prev.1 + 1..cur.1 {
keys_to_add.push((format!("KEY_{missing}"), missing));
keys_to_add.push((format!("KEY_{missing:X?}"), missing));
}
}
keys.append(&mut keys_to_add);
keys.sort_by_key(|k| k.1);
for key in keys {
println!("{} = {},", key.0, key.1);
println!("{} = 0x{:X},", key.0, key.1);
}
}
2 changes: 1 addition & 1 deletion simulated_passthru/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ winapi = { version = "0.3.9", features = [
"mmsystem",
] }
native-windows-gui = { version = "1.0.12", default-features = false }
kanata-interception = { version = "0.2.0", optional = true }
kanata-interception = { version = "0.3.0", optional = true }
win_dbg_logger = "0.1.0"

[features]
Expand Down
2 changes: 1 addition & 1 deletion windows_key_tester/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ winapi = { version = "0.3.9", features = [
"mmsystem",
] }
native-windows-gui = { version = "1.0.12", default-features = false }
kanata-interception = { version = "0.2.0", optional = true }
kanata-interception = { version = "0.3.0", optional = true }
kanata = { path = "..", optional = true }

[features]
Expand Down

0 comments on commit 4b27fcd

Please sign in to comment.