feat(win32 gui): send both shifted and un-shifted input keycodes/codepoints
Also, send input text only for non-modified events.
This commit is contained in:
parent
d90d82a4b7
commit
689b2ca410
1 changed files with 32 additions and 6 deletions
|
@ -791,19 +791,23 @@ fn sendKey(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (char_buf[0..@intCast(unicode_result)]) |codepoint| {
|
for (char_buf[0..@intCast(unicode_result)]) |codepoint| {
|
||||||
|
const mod_bits = @as(u8, @bitCast(mods));
|
||||||
var utf8_buf: [6]u8 = undefined;
|
var utf8_buf: [6]u8 = undefined;
|
||||||
const utf8_len = std.unicode.utf8Encode(codepoint, &utf8_buf) catch {
|
const utf8_len = if (event == input.event.press and (mod_bits & 0xBE == 0)) // ignore shift and caps
|
||||||
|
std.unicode.utf8Encode(codepoint, &utf8_buf) catch {
|
||||||
std.log.err("invalid codepoint {}", .{codepoint});
|
std.log.err("invalid codepoint {}", .{codepoint});
|
||||||
continue;
|
continue;
|
||||||
};
|
}
|
||||||
|
else
|
||||||
|
0;
|
||||||
state.pid.send(.{
|
state.pid.send(.{
|
||||||
"RDR",
|
"RDR",
|
||||||
"I",
|
"I",
|
||||||
event,
|
event,
|
||||||
@as(u21, codepoint),
|
@as(u21, winkey.toKKPKeyCode()),
|
||||||
@as(u21, codepoint),
|
@as(u21, codepoint),
|
||||||
utf8_buf[0..utf8_len],
|
utf8_buf[0..utf8_len],
|
||||||
@as(u8, @bitCast(mods)),
|
mod_bits,
|
||||||
}) catch |e| onexit(e);
|
}) catch |e| onexit(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -933,6 +937,28 @@ const WinKey = struct {
|
||||||
else => null,
|
else => null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn toKKPKeyCode(self: WinKey) u21 {
|
||||||
|
if (self.extended) return self.vk;
|
||||||
|
return switch (self.vk) {
|
||||||
|
'A'...'Z' => |char| char + ('a' - 'A'),
|
||||||
|
|
||||||
|
@intFromEnum(win32.VK_OEM_1) => ';',
|
||||||
|
@intFromEnum(win32.VK_OEM_PLUS) => '+',
|
||||||
|
@intFromEnum(win32.VK_OEM_COMMA) => ',',
|
||||||
|
@intFromEnum(win32.VK_OEM_MINUS) => '-',
|
||||||
|
@intFromEnum(win32.VK_OEM_PERIOD) => '.',
|
||||||
|
@intFromEnum(win32.VK_OEM_2) => '/',
|
||||||
|
@intFromEnum(win32.VK_OEM_3) => '`',
|
||||||
|
@intFromEnum(win32.VK_OEM_4) => '[',
|
||||||
|
@intFromEnum(win32.VK_OEM_5) => '\\',
|
||||||
|
@intFromEnum(win32.VK_OEM_6) => ']',
|
||||||
|
@intFromEnum(win32.VK_OEM_7) => '\'',
|
||||||
|
@intFromEnum(win32.VK_OEM_102) => '\\',
|
||||||
|
|
||||||
|
else => |char| char,
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var global_msg_tail: ?*windowmsg.MessageNode = null;
|
var global_msg_tail: ?*windowmsg.MessageNode = null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue