MCPcopy Create free account
hub / github.com/NetHack/NetHack / nh340_processkeystroke

Function nh340_processkeystroke

sys/windows/consoletty.c:3740–3829  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3738 */
3739
3740int
3741nh340_processkeystroke(
3742 HANDLE hConIn UNUSED,
3743 INPUT_RECORD *ir,
3744 boolean *valid,
3745 uchar numberpad,
3746 int portdebug)
3747{
3748 int keycode, vk;
3749 unsigned char ch, pre_ch;
3750 unsigned short int scan;
3751 unsigned long shiftstate;
3752 int altseq = 0;
3753 const struct pad *kpad;
3754
3755#ifdef QWERTZ_SUPPORT
3756 if (numberpad & 0x10) {
3757 numberpad &= ~0x10;
3758 qwertz = TRUE;
3759 } else {
3760 qwertz = FALSE;
3761 }
3762#endif
3763
3764 shiftstate = 0L;
3765 ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar;
3766 scan = ir->Event.KeyEvent.wVirtualScanCode;
3767 vk = ir->Event.KeyEvent.wVirtualKeyCode;
3768 keycode = MapVirtualKey(vk, 2);
3769 shiftstate = ir->Event.KeyEvent.dwControlKeyState;
3770
3771 if (shiftstate & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) {
3772 if (ch || inmap(keycode, vk))
3773 altseq = 1;
3774 else
3775 altseq = -1; /* invalid altseq */
3776 }
3777 if (ch || (iskeypad(scan)) || (altseq > 0))
3778 *valid = TRUE;
3779 /* if (!valid) return 0; */
3780 /*
3781 * shiftstate can be checked to see if various special
3782 * keys were pressed at the same time as the key.
3783 * Currently we are using the ALT & SHIFT & CONTROLS.
3784 *
3785 * RIGHT_ALT_PRESSED, LEFT_ALT_PRESSED,
3786 * RIGHT_CTRL_PRESSED, LEFT_CTRL_PRESSED,
3787 * SHIFT_PRESSED,NUMLOCK_ON, SCROLLLOCK_ON,
3788 * CAPSLOCK_ON, ENHANCED_KEY
3789 *
3790 * are all valid bit masks to use on shiftstate.
3791 * eg. (shiftstate & LEFT_CTRL_PRESSED) is true if the
3792 * left control key was pressed with the keystroke.
3793 */
3794 if (iskeypad(scan)) {
3795 kpad = numberpad ? numpad : keypad;
3796 if (shiftstate & SHIFT_PRESSED) {
3797 ch = kpad[scan - KEYPADLO].shift;

Callers 1

nh340_checkinputFunction · 0.85

Calls 1

fprintfFunction · 0.85

Tested by

no test coverage detected