[Bug 59794] New: ReadConsoleInput/PeekConsoleInput does not handle multiple key presses properly with wineconsole/AllocConsole
http://bugs.winehq.org/show_bug.cgi?id=59794 Bug ID: 59794 Summary: ReadConsoleInput/PeekConsoleInput does not handle multiple key presses properly with wineconsole/AllocConsole Product: Wine Version: 11.9 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: cmd Assignee: wine-bugs@list.winehq.org Reporter: barathrk11@gmail.com Distribution: --- Created attachment 81033 --> http://bugs.winehq.org/attachment.cgi?id=81033 Video showing program running in wineconsole and cmd in a win10 VM When running the following program(a slightly modified version of the MSDN code given here: https://learn.microsoft.com/en-us/windows/console/reading-input-buffer-event...) using wine console, or creating a new console using AllocConsole at the start of the main function, multiple key presses(for example, as shown in the attachment, pressing s and d together) cause a '\0' char to be displayed as the key character in the KeyEventProc function. However, the expected output as shown is for both characters to be displayed(again included in the attachment): #include <windows.h> #include <stdio.h> HANDLE hStdin; DWORD fdwSaveOldMode; VOID ErrorExit(LPCSTR); VOID KeyEventProc(KEY_EVENT_RECORD); VOID MouseEventProc(MOUSE_EVENT_RECORD); VOID ResizeEventProc(WINDOW_BUFFER_SIZE_RECORD); int main(VOID) { DWORD cNumRead, fdwMode, i; INPUT_RECORD irInBuf[128]; int counter=0; // Get the standard input handle. hStdin = GetStdHandle(STD_INPUT_HANDLE); if (hStdin == INVALID_HANDLE_VALUE) ErrorExit("GetStdHandle"); // Save the current input mode, to be restored on exit. if (! GetConsoleMode(hStdin, &fdwSaveOldMode) ) ErrorExit("GetConsoleMode"); // Enable the window and mouse input events. // Disable quick edit mode because it interfers with receiving mouse inputs. fdwMode = (ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT | ENABLE_EXTENDED_FLAGS) & ~ENABLE_QUICK_EDIT_MODE; if (! SetConsoleMode(hStdin, fdwMode) ) ErrorExit("SetConsoleMode"); // Loop to read and handle the next 100 input events. while (counter++ <= 10) { // Wait for the events. if (! ReadConsoleInput( hStdin, // input buffer handle irInBuf, // buffer to read into 128, // size of read buffer &cNumRead) ) // number of records read ErrorExit("ReadConsoleInput"); // Dispatch the events to the appropriate handler. for (i = 0; i < cNumRead; i++) { switch(irInBuf[i].EventType) { case KEY_EVENT: // keyboard input KeyEventProc(irInBuf[i].Event.KeyEvent); break; case MOUSE_EVENT: // mouse input MouseEventProc(irInBuf[i].Event.MouseEvent); break; case WINDOW_BUFFER_SIZE_EVENT: // scrn buf. resizing ResizeEventProc( irInBuf[i].Event.WindowBufferSizeEvent ); break; case FOCUS_EVENT: // disregard focus events case MENU_EVENT: // disregard menu events break; default: ErrorExit("Unknown event type"); break; } } } // Restore input mode on exit. SetConsoleMode(hStdin, fdwSaveOldMode); return 0; } VOID ErrorExit (LPCSTR lpszMessage) { fprintf(stderr, "%s\n", lpszMessage); // Restore input mode on exit. SetConsoleMode(hStdin, fdwSaveOldMode); ExitProcess(0); } VOID KeyEventProc(KEY_EVENT_RECORD ker) { printf("Key event: "); if(ker.bKeyDown) printf("key pressed: %c\n", ker.uChar.AsciiChar); else printf("key released: %c\n", ker.uChar.AsciiChar); } VOID MouseEventProc(MOUSE_EVENT_RECORD mer) { #ifndef MOUSE_HWHEELED #define MOUSE_HWHEELED 0x0008 #endif printf("Mouse event: "); switch(mer.dwEventFlags) { case 0: if(mer.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) { printf("left button press \n"); } else if(mer.dwButtonState == RIGHTMOST_BUTTON_PRESSED) { printf("right button press \n"); } else { printf("button press\n"); } break; case DOUBLE_CLICK: printf("double click\n"); break; case MOUSE_HWHEELED: printf("horizontal mouse wheel\n"); break; case MOUSE_MOVED: printf("mouse moved\n"); break; case MOUSE_WHEELED: printf("vertical mouse wheel\n"); break; default: printf("unknown\n"); break; } } VOID ResizeEventProc(WINDOW_BUFFER_SIZE_RECORD wbsr) { printf("Resize event\n"); printf("Console screen buffer is %d columns by %d rows.\n", wbsr.dwSize.X, wbsr.dwSize.Y); } -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59794 Barath Kannan <barathrk11@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Alias| |wineconsole: -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59794 Barath Kannan <barathrk11@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Alias|wineconsole: |wineconsole -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59794 --- Comment #1 from Barath Kannan <barathrk11@gmail.com> --- Note that without wineconsole(running directly on the host terminal with wine or within cmd) the program works fine, but can't detect mouse events. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59794 Eric Pouech <eric.pouech@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |eric.pouech@gmail.com --- Comment #2 from Eric Pouech <eric.pouech@gmail.com> --- do you have an app that depends on this? (AFAICS only second key gets a 0 char on keyup event) -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=59794 --- Comment #3 from Barath Kannan <barathrk11@gmail.com> --- (In reply to Eric Pouech from comment #2)
do you have an app that depends on this? (AFAICS only second key gets a 0 char on keyup event)
None, I just reported it as it seemed like a deviation from windows behaviour. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (1)
-
WineHQ Bugzilla