Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix _CONSOLEINPUT function #598

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions internal/c/libqb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31364,22 +31364,26 @@ int32 func__getconsoleinput() {
fdwMode = dwMode | ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT;
SetConsoleMode(hStdin, fdwMode);

ReadConsoleInputA(hStdin, &irInputRecord, 1, &dwEventsRead);
switch (irInputRecord.EventType) {
case KEY_EVENT: // keyboard input
consolekey = irInputRecord.Event.KeyEvent.wVirtualScanCode;
if (!irInputRecord.Event.KeyEvent.bKeyDown)
consolekey = -consolekey; // positive/negative return of scan codes.
return 1;
case MOUSE_EVENT: // mouse input
consolemousex = irInputRecord.Event.MouseEvent.dwMousePosition.X + 1;
consolemousey = irInputRecord.Event.MouseEvent.dwMousePosition.Y - cl_bufinfo.srWindow.Top + 1;
consolebutton = irInputRecord.Event.MouseEvent.dwButtonState; // button state for all buttons
// SetConsoleMode(hStdin, dwMode);
return 2;
DWORD numEvents = 0;
GetNumberOfConsoleInputEvents(hStdin, &numEvents);
if (numEvents) {
ReadConsoleInputA(hStdin, &irInputRecord, 1, &dwEventsRead);
switch (irInputRecord.EventType) {
case KEY_EVENT: // keyboard input
consolekey = irInputRecord.Event.KeyEvent.wVirtualScanCode;
if (!irInputRecord.Event.KeyEvent.bKeyDown)
consolekey = -consolekey; // positive/negative return of scan codes.
return 1;
case MOUSE_EVENT: // mouse input
consolemousex = irInputRecord.Event.MouseEvent.dwMousePosition.X + 1;
consolemousey = irInputRecord.Event.MouseEvent.dwMousePosition.Y - cl_bufinfo.srWindow.Top + 1;
consolebutton = irInputRecord.Event.MouseEvent.dwButtonState; // button state for all buttons
// SetConsoleMode(hStdin, dwMode);
return 2;
}
}
#endif
return 0; // in case it's some other odd input
return 0; // no or unhandled input
}

int32 func__cinp(int32 toggle, int32 passed) {
Expand Down