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

Function process_keystroke2

sys/windows/consoletty.c:3500–3565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3498}
3499
3500int
3501process_keystroke2(
3502 HANDLE hConIn,
3503 INPUT_RECORD *ir,
3504 boolean *valid)
3505{
3506 /* Use these values for the numeric keypad */
3507 static const char keypad_nums[] = "789-456+1230.";
3508
3509 unsigned char ch;
3510 int vk;
3511 unsigned short int scan;
3512 unsigned long shiftstate;
3513 int altseq;
3514 DWORD count;
3515
3516 ch = ir->Event.KeyEvent.uChar.AsciiChar;
3517 vk = ir->Event.KeyEvent.wVirtualKeyCode;
3518 scan = ir->Event.KeyEvent.wVirtualScanCode;
3519 shiftstate = ir->Event.KeyEvent.dwControlKeyState;
3520
3521 if (scan == 0 && vk == 0) {
3522 /* It's the bogus_key */
3523 ReadConsoleInput(hConIn, ir, 1, &count);
3524 *valid = FALSE;
3525 return 0;
3526 }
3527
3528 altseq = is_altseq(shiftstate);
3529 if (ch || (iskeypad(scan)) || altseq)
3530 *valid = TRUE;
3531 /* if (!valid) return 0; */
3532 /*
3533 * shiftstate can be checked to see if various special
3534 * keys were pressed at the same time as the key.
3535 * Currently we are using the ALT & SHIFT & CONTROLS.
3536 *
3537 * RIGHT_ALT_PRESSED, LEFT_ALT_PRESSED,
3538 * RIGHT_CTRL_PRESSED, LEFT_CTRL_PRESSED,
3539 * SHIFT_PRESSED,NUMLOCK_ON, SCROLLLOCK_ON,
3540 * CAPSLOCK_ON, ENHANCED_KEY
3541 *
3542 * are all valid bit masks to use on shiftstate.
3543 * eg. (shiftstate & LEFT_CTRL_PRESSED) is true if the
3544 * left control key was pressed with the keystroke.
3545 */
3546 if (iskeypad(scan) && !altseq) {
3547 ReadConsoleInput(hConIn, ir, 1, &count);
3548 ch = keypad_nums[scan - KEYPADLO];
3549 } else if (ch < 32 && !isnumkeypad(scan)) {
3550 /* Control code; ReadConsole seems to filter some of these,
3551 * including ESC */
3552 ReadConsoleInput(hConIn, ir, 1, &count);
3553 }
3554 /* Attempt to work better with international keyboards. */
3555 else {
3556 CHAR ch2;
3557 ReadConsole(hConIn, &ch2, 1, &count, NULL);

Callers 1

ray_checkinputFunction · 0.85

Calls 1

is_altseqFunction · 0.85

Tested by

no test coverage detected