Simplify check for Alt-Numpad
Create two new inline functions is_alt_numpad_key(PINPUT_RECORD) and is_alt_numpad_event(PINPUT_RECORD) which contain the actual checks. Call these functions from fhandler_console::read and peek_console for better readability. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
@ -9,9 +9,34 @@ details. */
|
||||
#ifndef _MISCFUNCS_H
|
||||
#define _MISCFUNCS_H
|
||||
|
||||
#include <dinput.h>
|
||||
|
||||
#define likely(X) __builtin_expect (!!(X), 1)
|
||||
#define unlikely(X) __builtin_expect (!!(X), 0)
|
||||
|
||||
/* Check for Alt+Numpad keys in a console input record. These are used to
|
||||
enter codepoints not available in the current keyboard layout For details
|
||||
see http://www.fileformat.info/tip/microsoft/enter_unicode.htm */
|
||||
static inline bool
|
||||
is_alt_numpad_key (PINPUT_RECORD pirec)
|
||||
{
|
||||
return pirec->Event.KeyEvent.uChar.UnicodeChar == 0
|
||||
&& pirec->Event.KeyEvent.dwControlKeyState == LEFT_ALT_PRESSED
|
||||
&& pirec->Event.KeyEvent.wVirtualScanCode >= DIK_NUMPAD7
|
||||
&& pirec->Event.KeyEvent.wVirtualScanCode <= DIK_NUMPAD0
|
||||
&& pirec->Event.KeyEvent.wVirtualScanCode != DIK_SUBTRACT;
|
||||
}
|
||||
|
||||
/* Event for left Alt, with a non-zero character, comes from Alt+Numpad
|
||||
key sequence. e.g. <left-alt> 233 => é This is typically handled
|
||||
as the key up event after releasing the Alt key. */
|
||||
static inline bool
|
||||
is_alt_numpad_event (PINPUT_RECORD pirec)
|
||||
{
|
||||
return pirec->Event.KeyEvent.uChar.UnicodeChar != 0
|
||||
&& pirec->Event.KeyEvent.wVirtualKeyCode == VK_MENU
|
||||
&& pirec->Event.KeyEvent.wVirtualScanCode == 0x38;
|
||||
}
|
||||
|
||||
int __reg1 winprio_to_nice (DWORD);
|
||||
DWORD __reg1 nice_to_winprio (int &);
|
||||
|
Reference in New Issue
Block a user