diff --git a/examples/x11rb.rs b/examples/x11rb.rs index f95cdbb..99e6531 100644 --- a/examples/x11rb.rs +++ b/examples/x11rb.rs @@ -119,6 +119,7 @@ fn main() -> Result<(), Box> { keycode.into(), 0, conn.setup().min_keycode.into(), + conn.setup().max_keycode.into(), mapping.keysyms_per_keycode, mapping.keysyms.as_slice(), ); diff --git a/src/lib.rs b/src/lib.rs index 5f65d77..e1b7cd7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -286,16 +286,17 @@ pub const NO_SYMBOL: Keysym = Keysym(0); /// Get the keyboard symbol from a keyboard code and its column. /// -/// `min_keycode` can be retrieved from the X11 setup, and `keysyms_per_keycode` and `keysyms` can be +/// `min_keycode` and `max_keycode` can be retrieved from the X11 setup, and `keysyms_per_keycode` and `keysyms` can be /// retrieved from the X11 server through the `GetKeyboardMapping` request. pub fn keysym( keycode: KeyCode, mut column: u8, min_keycode: KeyCode, + max_keycode: KeyCode, keysyms_per_keycode: u8, keysyms: &[RawKeysym], ) -> Option { - if column >= keysyms_per_keycode && column > 3 { + if column >= keysyms_per_keycode && column > 3 || keycode > max_keycode { return None; }