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

Function ray_processkeystroke

sys/windows/consoletty.c:3381–3498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3379}
3380
3381int ray_processkeystroke(
3382 HANDLE hConIn,
3383 INPUT_RECORD *ir,
3384 boolean *valid,
3385 uchar numberpad,
3386 int portdebug)
3387{
3388 int keycode, vk;
3389 unsigned char ch, pre_ch;
3390 unsigned short int scan;
3391 unsigned long shiftstate;
3392 int altseq = 0;
3393 const struct pad *kpad;
3394 DWORD count;
3395
3396#ifdef QWERTZ_SUPPORT
3397 if (numberpad & 0x10) {
3398 numberpad &= ~0x10;
3399 qwertz = TRUE;
3400 } else {
3401 qwertz = FALSE;
3402 }
3403#endif
3404 shiftstate = 0L;
3405 ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar;
3406 scan = ir->Event.KeyEvent.wVirtualScanCode;
3407 vk = ir->Event.KeyEvent.wVirtualKeyCode;
3408 keycode = MapVirtualKey(vk, 2);
3409 shiftstate = ir->Event.KeyEvent.dwControlKeyState;
3410 if (scan == 0 && vk == 0) {
3411 /* It's the bogus_key */
3412 ReadConsoleInput(hConIn, ir, 1, &count);
3413 *valid = FALSE;
3414 return 0;
3415 }
3416
3417 if (is_altseq(shiftstate)) {
3418 if (ch || inmap(keycode, vk))
3419 altseq = 1;
3420 else
3421 altseq = -1; /* invalid altseq */
3422 }
3423 if (ch || (iskeypad(scan)) || (altseq > 0))
3424 *valid = TRUE;
3425 /* if (!valid) return 0; */
3426 /*
3427 * shiftstate can be checked to see if various special
3428 * keys were pressed at the same time as the key.
3429 * Currently we are using the ALT & SHIFT & CONTROLS.
3430 *
3431 * RIGHT_ALT_PRESSED, LEFT_ALT_PRESSED,
3432 * RIGHT_CTRL_PRESSED, LEFT_CTRL_PRESSED,
3433 * SHIFT_PRESSED,NUMLOCK_ON, SCROLLLOCK_ON,
3434 * CAPSLOCK_ON, ENHANCED_KEY
3435 *
3436 * are all valid bit masks to use on shiftstate.
3437 * eg. (shiftstate & LEFT_CTRL_PRESSED) is true if the
3438 * left control key was pressed with the keystroke.

Callers 1

ray_checkinputFunction · 0.85

Calls 2

is_altseqFunction · 0.85
fprintfFunction · 0.85

Tested by

no test coverage detected