| 3829 | } |
| 3830 | |
| 3831 | int |
| 3832 | nh340_kbhit( |
| 3833 | HANDLE hConIn, |
| 3834 | INPUT_RECORD *ir) |
| 3835 | { |
| 3836 | int done = 0; /* true = "stop searching" */ |
| 3837 | int retval; /* true = "we had a match" */ |
| 3838 | DWORD count; |
| 3839 | unsigned short int scan; |
| 3840 | unsigned char ch; |
| 3841 | unsigned long shiftstate; |
| 3842 | int altseq = 0, keycode, vk; |
| 3843 | done = 0; |
| 3844 | retval = 0; |
| 3845 | while (!done) { |
| 3846 | count = 0; |
| 3847 | PeekConsoleInput(hConIn, ir, 1, &count); |
| 3848 | if (count > 0) { |
| 3849 | if (ir->EventType == KEY_EVENT && ir->Event.KeyEvent.bKeyDown) { |
| 3850 | ch = ir->Event.KeyEvent.uChar.AsciiChar; |
| 3851 | scan = ir->Event.KeyEvent.wVirtualScanCode; |
| 3852 | shiftstate = ir->Event.KeyEvent.dwControlKeyState; |
| 3853 | vk = ir->Event.KeyEvent.wVirtualKeyCode; |
| 3854 | keycode = MapVirtualKey(vk, 2); |
| 3855 | if (shiftstate & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) { |
| 3856 | if (ch || inmap(keycode, vk)) |
| 3857 | altseq = 1; |
| 3858 | else |
| 3859 | altseq = -1; /* invalid altseq */ |
| 3860 | } |
| 3861 | if (ch || iskeypad(scan) || altseq) { |
| 3862 | done = 1; /* Stop looking */ |
| 3863 | retval = 1; /* Found what we sought */ |
| 3864 | } else { |
| 3865 | /* Strange Key event; let's purge it to avoid trouble */ |
| 3866 | ReadConsoleInput(hConIn, ir, 1, &count); |
| 3867 | } |
| 3868 | |
| 3869 | } else if ((ir->EventType == MOUSE_EVENT |
| 3870 | && (ir->Event.MouseEvent.dwButtonState |
| 3871 | & MOUSEMASK))) { |
| 3872 | done = 1; |
| 3873 | retval = 1; |
| 3874 | } |
| 3875 | |
| 3876 | else /* Discard it, it's an insignificant event */ |
| 3877 | ReadConsoleInput(hConIn, ir, 1, &count); |
| 3878 | } else /* There are no events in console event queue */ { |
| 3879 | done = 1; /* Stop looking */ |
| 3880 | retval = 0; |
| 3881 | } |
| 3882 | } |
| 3883 | return retval; |
| 3884 | } |
| 3885 | |
| 3886 | int |
| 3887 | nh340_checkinput( |
nothing calls this directly
no outgoing calls
no test coverage detected