Fix new Ctrl+' and Ctrl+Shift+' keyboard shortcuts on Windows

Now Unicode characters are included on keyboard messages generated from
a Control+key on Windows.
This commit is contained in:
David Capello 2017-12-06 15:06:56 -03:00
parent 7dcc0072f1
commit 29d2988112
2 changed files with 26 additions and 2 deletions

View File

@ -1,5 +1,5 @@
// SHE library
// Copyright (C) 2012-2016 David Capello
// Copyright (C) 2012-2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -30,6 +30,18 @@ namespace she {
m_size =
ToUnicode(vk, scancode, m_keystate, m_buffer,
sizeof(m_buffer)/sizeof(m_buffer[0]), 0);
// If there is a control key pressed, we'll try to get the
// unicode character turning control/shift off.
if (m_size == 0 ||
(m_size == 1 && m_buffer[0] == 0 &&
m_keystate[VK_CONTROL] | m_keystate[VK_LCONTROL] | m_keystate[VK_RCONTROL])) {
m_keystate[VK_SHIFT] = m_keystate[VK_LSHIFT] = m_keystate[VK_RSHIFT] = 0;
m_keystate[VK_CONTROL] = m_keystate[VK_LCONTROL] = m_keystate[VK_RCONTROL] = 0;
m_size =
ToUnicode(vk, scancode, m_keystate, m_buffer,
sizeof(m_buffer)/sizeof(m_buffer[0]), 0);
}
}
operator bool() { return m_ok; }

View File

@ -27,6 +27,7 @@
#define SHE_WND_CLASS_NAME L"Aseprite.Window"
#define KEY_TRACE TRACE
#define MOUSE_TRACE(...)
// Gets the window client are in absolute/screen coordinates
@ -966,6 +967,9 @@ LRESULT WinWindow::wndProc(UINT msg, WPARAM wparam, LPARAM lparam)
ev.setUnicodeChar(0);
ev.setRepeat(MAX(0, (lparam & 0xffff)-1));
KEY_TRACE("KEYDOWN vk=%d scancode=%d->%d modifiers=%d\n",
vk, scancode, ev.scancode(), ev.modifiers());
{
VkToUnicode tu;
if (tu) {
@ -981,13 +985,21 @@ LRESULT WinWindow::wndProc(UINT msg, WPARAM wparam, LPARAM lparam)
for (int chr : tu) {
ev.setUnicodeChar(chr);
queueEvent(ev);
KEY_TRACE(" -> queued unicode char=%d <%c>\n",
ev.unicodeChar(),
ev.unicodeChar() ? ev.unicodeChar(): ' ');
}
}
}
}
if (sendMsg)
if (sendMsg) {
queueEvent(ev);
KEY_TRACE(" -> queued unicode char=%d <%c>\n",
ev.unicodeChar(),
ev.unicodeChar() ? ev.unicodeChar(): ' ');
}
return 0;
}