Skip to content

Commit 18f4fcd

Browse files
committed
support hut 0.3 and 0.4
1 parent 3d353d8 commit 18f4fcd

File tree

5 files changed

+57
-37
lines changed

5 files changed

+57
-37
lines changed

Cargo.lock

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ keywords = ["keyboard", "keycodes", "virtual-keycodes", "constants", "convert"]
1111
[dependencies]
1212
bitflags = { version = "2.9.0", optional = true }
1313
enigo = { version = "0.3.0", default-features = false, optional = true }
14-
hut = "0.3.0"
1514
num_enum = { version = "0.7.3", optional = true }
1615
serde = { version = "1.0.219", features = ["derive"], optional = true }
1716
smol_str = { version = "0.3.2", optional = true }
1817
thiserror = "2.0.12"
1918
xkeysym = { version = "0.2.1", optional = true }
2019

20+
hut_03 = { package = "hut", version = "0.3.0", default-features = false, optional = true }
21+
hut_04 = { package = "hut", version = "0.4.0", default-features = false, optional = true }
22+
2123
[target.'cfg(target_os = "windows")'.dependencies]
2224
windows = { version = "0.61", optional = true, features = ["Win32_UI_Input_KeyboardAndMouse"] }
2325

@@ -54,7 +56,7 @@ serde = [ "dep:serde", "smol_str?/serde", "enigo?/serde", "bitflags?/serde" ]
5456
macos = ["dep:core-graphics", "dep:core-foundation"]
5557
windows = ["dep:windows"]
5658
enigo = ["dep:enigo"]
57-
dep_all = ["windows", "macos", "xkeysym"]
59+
dep_all = ["windows", "macos", "xkeysym", "hut_03", "hut_04"]
5860

5961
generating_convert = []
6062

src/convert/mod.rs

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,17 @@
11
#![allow(deprecated)]
22

33
mod generated_winput_to_hut {
4-
//! https://learn.microsoft.com/en-us/windows/win32/inputdev/about-keyboard-input
5-
//!
6-
//! VK or virtual keys have both mouse and keyboard, and is windows specific,
7-
//! have both VK_SHIFT (0x10), VK_LSHIFT (0xA0) and VK_RSHIFT (0xA1).
8-
//! see also https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
9-
//!
10-
//! Location or key position of AT101 is order (starting from 1) of keys on keyboard, regardless of language,
11-
//! see also first picture at https://learn.microsoft.com/en-us/windows/win32/inputdev/about-keyboard-input#scan-codes
12-
//!
13-
//! Usage or HID Usage Table is tuple of (page, id), the page of keyboard is 0x07,
14-
//! within Keyboard Page,
15-
//! see also https://learn.microsoft.com/en-us/windows-hardware/drivers/hid/hid-usages
16-
//! and https://usb.org/document-library/hid-usage-tables-16
17-
//!
18-
//! Scancode or Scan 1 Make is regardless of layout,
19-
//! see also HidP_TranslateUsagesToI8042ScanCodes
20-
//!
21-
//! e.g.
22-
//! | | VK | AT101 | HID Usage | Scan 1 |
23-
//! | ` (tilde) | VK_OEM_3 0xC0 192 | 1 | 0x0007 0x0035 | 0x0029 |
24-
//! | 1 | VK_1 0x31 49 | 2 | 0x0007 0x001E | 0x0002 |
25-
//! | Numpad1 | VK_NUMPAD1 0x61 97 | 93 | 0x0007 0x0059 | 0x004F |
26-
//! | A | VK_A 0x41 65 | 31 | 0x0007 0x0004 | 0x001E |
27-
//! | ENTER | VK_RETURN 0x0D 13 | 108 | 0x0007 0x0058 | 0xE01C |
28-
//! | LSHIFT | VK_LSHIFT 0xA0 160 | 44 | 0x0007 0x00E1 | 0x002A |
29-
//! | RSHIFT | VK_RSHIFT 0xA1 161 | 57 | 0x0007 0x00E5 | 0x0036 |
30-
//! | SLEEP | VK_SLEEP 0x5F 95 | - | 0x0001 0x0082 | 0xE05F |
31-
//! | PLAY | VK_PLAY 0xFA 250 | - | 0x000C 0x00CD | 0xE022 |
32-
//! | SHIFT | VK_SHIFT 0x10 16 | -
33-
//! | LBUTTON | VK_LBUTTON 0x01 1 | -
4+
mod mirror_to_hut_03 {
5+
use crate::mirror::winput::Vk;
6+
use crate::deps::hut_03::{AsUsage, Button, Consumer, GenericDesktop, KeyboardKeypad, Usage};
7+
include!("generated.Winput_to_HUT.rs");
8+
}
349

35-
use crate::mirror::winput::Vk;
36-
use crate::deps::hut::{AsUsage, Button, Consumer, GenericDesktop, KeyboardKeypad, Usage};
37-
include!("generated.Winput_to_HUT.rs");
10+
mod mirror_to_hut_04 {
11+
use crate::mirror::winput::Vk;
12+
use crate::deps::hut_04::{AsUsage, Button, Consumer, GenericDesktop, KeyboardKeypad, Usage};
13+
include!("generated.Winput_to_HUT.rs");
14+
}
3815
}
3916

4017
mod generated_winput_to_enigo {

src/deps/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
pub use ::hut::{self, Usage, UsagePage};
1+
pub use ::hut_03;
2+
pub use ::hut_04;
3+
pub use hut_04 as hut;
24

35
#[cfg(all(feature = "windows", target_os = "windows"))]
46
pub use ::windows::Win32::UI::Input::KeyboardAndMouse::{self as windows, VIRTUAL_KEY};

src/lib.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
2+
//! https://learn.microsoft.com/en-us/windows/win32/inputdev/about-keyboard-input
3+
//!
4+
//! VK or virtual keys have both mouse and keyboard, and is windows specific,
5+
//! have both VK_SHIFT (0x10), VK_LSHIFT (0xA0) and VK_RSHIFT (0xA1).
6+
//! see also https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
7+
//!
8+
//! Location or key position of AT101 is order (starting from 1) of keys on keyboard, regardless of language,
9+
//! see also first picture at https://learn.microsoft.com/en-us/windows/win32/inputdev/about-keyboard-input#scan-codes
10+
//!
11+
//! Usage or HID Usage Table is tuple of (page, id), the page of keyboard is 0x07,
12+
//! within Keyboard Page,
13+
//! see also https://learn.microsoft.com/en-us/windows-hardware/drivers/hid/hid-usages
14+
//! and https://usb.org/document-library/hid-usage-tables-16
15+
//!
16+
//! Scancode or Scan 1 Make is regardless of layout,
17+
//! see also HidP_TranslateUsagesToI8042ScanCodes
18+
//!
19+
//! e.g.
20+
//! | | VK | AT101 | HID Usage | Scan 1 |
21+
//! | ` (tilde) | VK_OEM_3 0xC0 192 | 1 | 0x0007 0x0035 | 0x0029 |
22+
//! | 1 | VK_1 0x31 49 | 2 | 0x0007 0x001E | 0x0002 |
23+
//! | Numpad1 | VK_NUMPAD1 0x61 97 | 93 | 0x0007 0x0059 | 0x004F |
24+
//! | A | VK_A 0x41 65 | 31 | 0x0007 0x0004 | 0x001E |
25+
//! | ENTER | VK_RETURN 0x0D 13 | 108 | 0x0007 0x0058 | 0xE01C |
26+
//! | LSHIFT | VK_LSHIFT 0xA0 160 | 44 | 0x0007 0x00E1 | 0x002A |
27+
//! | RSHIFT | VK_RSHIFT 0xA1 161 | 57 | 0x0007 0x00E5 | 0x0036 |
28+
//! | SLEEP | VK_SLEEP 0x5F 95 | - | 0x0001 0x0082 | 0xE05F |
29+
//! | PLAY | VK_PLAY 0xFA 250 | - | 0x000C 0x00CD | 0xE022 |
30+
//! | SHIFT | VK_SHIFT 0x10 16 | -
31+
//! | LBUTTON | VK_LBUTTON 0x01 1 | -
32+
133
pub mod mirror;
234
pub mod deps;
335
pub mod convert;

0 commit comments

Comments
 (0)