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

Function default_processkeystroke

sys/windows/consoletty.c:2919–3031  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2917}
2918
2919int
2920default_processkeystroke(
2921 HANDLE hConIn UNUSED,
2922 INPUT_RECORD *ir,
2923 boolean *valid,
2924 uchar numberpad,
2925 int portdebug)
2926{
2927 int k = 0;
2928 int keycode, vk;
2929 unsigned char ch, pre_ch;
2930 unsigned short int scan;
2931 unsigned long shiftstate;
2932 int altseq = 0;
2933 const struct pad *kpad;
2934
2935#ifdef QWERTZ_SUPPORT
2936 if (numberpad & 0x10) {
2937 numberpad &= ~0x10;
2938 qwertz = TRUE;
2939 } else {
2940 qwertz = FALSE;
2941 }
2942#endif
2943 shiftstate = 0L;
2944 ch = pre_ch = ir->Event.KeyEvent.uChar.AsciiChar;
2945 scan = ir->Event.KeyEvent.wVirtualScanCode;
2946 vk = ir->Event.KeyEvent.wVirtualKeyCode;
2947 keycode = MapVirtualKey(vk, 2);
2948 shiftstate = ir->Event.KeyEvent.dwControlKeyState;
2949 KeyState[VK_SHIFT] = (shiftstate & SHIFT_PRESSED) ? 0x81 : 0;
2950 KeyState[VK_CONTROL] =
2951 (shiftstate & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) ? 0x81 : 0;
2952 KeyState[VK_CAPITAL] = (shiftstate & CAPSLOCK_ON) ? 0x81 : 0;
2953
2954 if (shiftstate & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) {
2955 if (ch || inmap(keycode, vk))
2956 altseq = 1;
2957 else
2958 altseq = -1; /* invalid altseq */
2959 }
2960 if (ch || (iskeypad(scan)) || (altseq > 0))
2961 *valid = TRUE;
2962 /* if (!valid) return 0; */
2963 /*
2964 * shiftstate can be checked to see if various special
2965 * keys were pressed at the same time as the key.
2966 * Currently we are using the ALT & SHIFT & CONTROLS.
2967 *
2968 * RIGHT_ALT_PRESSED, LEFT_ALT_PRESSED,
2969 * RIGHT_CTRL_PRESSED, LEFT_CTRL_PRESSED,
2970 * SHIFT_PRESSED,NUMLOCK_ON, SCROLLLOCK_ON,
2971 * CAPSLOCK_ON, ENHANCED_KEY
2972 *
2973 * are all valid bit masks to use on shiftstate.
2974 * eg. (shiftstate & LEFT_CTRL_PRESSED) is true if the
2975 * left control key was pressed with the keystroke.
2976 */

Callers 1

default_checkinputFunction · 0.85

Calls 1

fprintfFunction · 0.85

Tested by

no test coverage detected