Skip to content

Windows: Added ReadConsoleInput functionality #98

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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: 32 additions & 0 deletions windows/input_record.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package windows

// InputRecord is the data structure that ReadConsoleInput writes into.
// All Documentation originally provided by Michael Niksa, et al. at Microsoft Corporation
// under CC Attribution 4.0 International
// via https://docs.microsoft.com/en-us/windows/console/input-record-str
type InputRecord struct {
// 0x1: Key event
// 0x2: Will never be read when using ReadConsoleInput
// 0x4: Window buffer size event
// 0x8: Deprecated
// 0x10: Deprecated
// Original source: https://docs.microsoft.com/en-us/windows/console/input-record-str#members
Type uint16
_ [2]byte // discard the next two bytes

// Data contents are:
// If the event is a key event (Type == 1):
// - Data[0] is 0x1 if the key is pressed, 0x0 if the key is released
// - Data[3] is the keycode of the pressed key, see
// https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
// - Data[5] is the ascii or Unicode keycode.
// - Data[6] stores the state of the modifier keys.
// Original source: https://docs.microsoft.com/en-us/windows/console/key-event-record-str
//
// If the event is a window buffer size event (Type == 4):
// - Data[0] is the new amount of character rows
// - Data[1] is the new amount of character columns
// Original source: https://docs.microsoft.com/en-us/windows/console/window-buffer-size-record-str
Data [6]uint16
}

25 changes: 25 additions & 0 deletions windows/zsyscall_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.