mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-19 19:21:08 +00:00
Implement she::is_key_pressed() on Win32 for the Skia port
This commit is contained in:
parent
20f532ffe8
commit
189ee56c4c
@ -34,11 +34,12 @@ void error_message(const char* msg)
|
||||
// TODO
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
bool is_key_pressed(KeyScancode scancode)
|
||||
{
|
||||
// TODO
|
||||
return false;
|
||||
return false; // Do nothing
|
||||
}
|
||||
#endif
|
||||
|
||||
void clear_keyboard_buffer()
|
||||
{
|
||||
|
@ -294,4 +294,34 @@ KeyScancode win32vk_to_scancode(int vk) {
|
||||
return keymap[vk];
|
||||
}
|
||||
|
||||
static int scancode_to_win32vk(KeyScancode scancode) {
|
||||
static int initialized = false;
|
||||
static int keymap[kKeyScancodes];
|
||||
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
for (int i=0; i<kKeyScancodes; ++i)
|
||||
keymap[i] = 0;
|
||||
for (int vk=0; vk<256; ++vk) {
|
||||
KeyScancode sc = win32vk_to_scancode(vk);
|
||||
if (sc != kKeyNil)
|
||||
keymap[sc] = vk;
|
||||
}
|
||||
}
|
||||
|
||||
if (scancode < kKeyNil || scancode > kKeyScancodes)
|
||||
scancode = kKeyNil;
|
||||
|
||||
return keymap[scancode];
|
||||
}
|
||||
|
||||
bool is_key_pressed(KeyScancode scancode)
|
||||
{
|
||||
int vk = scancode_to_win32vk(scancode);
|
||||
if (vk)
|
||||
return (GetKeyState(vk) & 0xf000 ? true: false);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace she
|
||||
|
Loading…
x
Reference in New Issue
Block a user