Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
_CONSOLEINPUT is blocking
#9
(01-18-2025, 12:24 PM)mdijkens Wrote: I've now also created a cKeyhit that can be used in a console and returns the same keycodes as _KEYHIT 
Code: (Select All)
int32 cKeyhit() {
#ifdef QB64_WINDOWS
    HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
    INPUT_RECORD irInputRecord;
    DWORD dwEventsRead, fdwMode, dwMode;
    CONSOLE_SCREEN_BUFFER_INFO cl_bufinfo;

    GetConsoleMode(hStdin, (LPDWORD)&dwMode);
    fdwMode = ENABLE_EXTENDED_FLAGS;
    SetConsoleMode(hStdin, fdwMode);
    fdwMode = dwMode | ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT;
    SetConsoleMode(hStdin, fdwMode);

    DWORD numEvents = 0;
    GetNumberOfConsoleInputEvents(hStdin, &numEvents);
    if (numEvents) {
        ReadConsoleInputA(hStdin, &irInputRecord, 1, &dwEventsRead);
        switch (irInputRecord.EventType) {
        case KEY_EVENT:
          if (!irInputRecord.Event.KeyEvent.bKeyDown)
            return 0;
          int32 uc = int(wchar_t(irInputRecord.Event.KeyEvent.uChar.UnicodeChar));
if (uc != 0)
return uc;
          switch (irInputRecord.Event.KeyEvent.wVirtualScanCode) {
case 42: return 100304; // LSHIFT
case 54: return 100303; // RSHIFT
case 29: return 100306; // LCTRL (+RCTRL)
case 56: return 100308; // LALT (+RALT)
case 59: return 15104;  // F1
case 60: return 15360;  // F2
case 61: return 15616;  // F3
case 62: return 15872;  // F4
case 63: return 16128;  // F5
case 64: return 16384;  // F6
case 65: return 16640;  // F7
case 66: return 16896;  // F8
case 67: return 17152;  // F9
case 68: return 17408;  // F10
case 87: return 34048;  // F11
case 88: return 34304;  // F12
case 82: return 20992;  // INSERT
case 83: return 21248;  // DELETE
case 71: return 18176;  // HOME
case 79: return 20224;  // END
case 73: return 18688;  // PAGEUP
case 81: return 20736;  // PAGEDOWN
case 75: return 19200;  // LEFT
case 77: return 19712;  // RIGHT
case 72: return 18432;  // UP
case 80: return 20480;  // DOWN
}
return 256 + irInputRecord.Event.KeyEvent.wVirtualScanCode;
        }
    }
#endif
    return 0;
}
(cpp novice)

Well done all on finding the issue and fixing!

Question - how would you use your c stuff in QB64? DECLARELIBRARY ?

Could you post an example for us?
grymmjack (gj!)
GitHubYouTube | Soundcloud | 16colo.rs
Reply


Messages In This Thread
_CONSOLEINPUT is blocking - by mdijkens - 01-17-2025, 02:21 PM
RE: _CONSOLEINPUT is blocking - by SMcNeill - 01-17-2025, 03:08 PM
RE: _CONSOLEINPUT is blocking - by RhoSigma - 01-17-2025, 03:43 PM
RE: _CONSOLEINPUT is blocking - by mdijkens - 01-17-2025, 04:18 PM
RE: _CONSOLEINPUT is blocking - by DSMan195276 - 01-17-2025, 04:16 PM
RE: _CONSOLEINPUT is blocking - by RhoSigma - 01-17-2025, 06:13 PM
RE: _CONSOLEINPUT is blocking - by mdijkens - 01-17-2025, 06:26 PM
RE: _CONSOLEINPUT is blocking - by mdijkens - 01-18-2025, 12:24 PM
RE: _CONSOLEINPUT is blocking - by grymmjack - 01-20-2025, 10:50 PM
RE: _CONSOLEINPUT is blocking - by SMcNeill - 01-20-2025, 10:56 PM
RE: _CONSOLEINPUT is blocking - by mdijkens - Yesterday, 08:35 AM
RE: _CONSOLEINPUT is blocking - by SMcNeill - Yesterday, 08:42 AM
RE: _CONSOLEINPUT is blocking - by mdijkens - Yesterday, 08:54 AM



Users browsing this thread: 6 Guest(s)