apprt/embedded: if a physical key input is a keypad key, keep it

This commit is contained in:
Mitchell Hashimoto
2023-09-22 11:44:18 -07:00
parent 4b8056afd8
commit 510f0fe8f2
2 changed files with 29 additions and 0 deletions

View File

@ -595,6 +595,9 @@ pub const Surface = struct {
//
// We also only do key translation if this is not a dead key.
const key = if (!result.composing) key: {
// If our physical key is a keypad key, we use that.
if (physical_key.keypad()) break :key physical_key;
// A completed key. If the length of the key is one then we can
// attempt to translate it to a key enum and call the key
// callback. First try plain ASCII.

View File

@ -422,4 +422,30 @@ pub const Key = enum(c_int) {
else => false,
};
}
/// Returns true if this is a keypad key.
pub fn keypad(self: Key) bool {
return switch (self) {
.kp_0,
.kp_1,
.kp_2,
.kp_3,
.kp_4,
.kp_5,
.kp_6,
.kp_7,
.kp_8,
.kp_9,
.kp_decimal,
.kp_divide,
.kp_multiply,
.kp_subtract,
.kp_add,
.kp_enter,
.kp_equal,
=> true,
else => false,
};
}
};