本文整理汇总了C++中GetNumberOfConsoleInputEvents函数的典型用法代码示例。如果您正苦于以下问题:C++ GetNumberOfConsoleInputEvents函数的具体用法?C++ GetNumberOfConsoleInputEvents怎么用?C++ GetNumberOfConsoleInputEvents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetNumberOfConsoleInputEvents函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: getch2_enable
void getch2_enable(void)
{
DWORD retval;
in = GetStdHandle(STD_INPUT_HANDLE);
if(!GetNumberOfConsoleInputEvents(in,&retval))
{
printf("getch2: %i can't get number of input events [disabling console input]\n",GetLastError());
getch2_status = 0;
}
else getch2_status=1;
}
开发者ID:HermiG,项目名称:mplayer2,代码行数:11,代码来源:getch2-win.c
示例2: FD_ZERO
bool Utils::input_pending(void) {
#ifdef HAVE_SELECT
fd_set read_fds;
struct timeval timeout;
FD_ZERO(&read_fds);
FD_SET(0,&read_fds);
timeout.tv_sec = timeout.tv_usec = 0;
select(1,&read_fds,NULL,NULL,&timeout);
if (FD_ISSET(0,&read_fds)) {
return true;
} else {
return false;
}
#else
static int init = 0, pipe;
static HANDLE inh;
DWORD dw;
if (!init) {
init = 1;
inh = GetStdHandle(STD_INPUT_HANDLE);
pipe = !GetConsoleMode(inh, &dw);
if (!pipe) {
SetConsoleMode(inh, dw & ~(ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT));
FlushConsoleInputBuffer(inh);
}
}
if (pipe) {
if (!PeekNamedPipe(inh, NULL, 0, NULL, &dw, NULL)) {
myprintf("Nothing at other end - exiting\n");
exit(EXIT_FAILURE);
}
if (dw) {
return true;
} else {
return false;
}
} else {
if (!GetNumberOfConsoleInputEvents(inh, &dw)) {
myprintf("Nothing at other end - exiting\n");
exit(EXIT_FAILURE);
}
if (dw <= 1) {
return false;
} else {
return true;
}
}
return false;
#endif
}
开发者ID:dzungcamlang,项目名称:leela-zero,代码行数:54,代码来源:Utils.cpp
示例3: GetNumberOfConsoleInputEvents
DWORD CInput::GetInput(){
GetNumberOfConsoleInputEvents(hIn, &read);
if(read){
ReadConsoleInput(hIn, &input, 1, &read);
if(input.EventType == KEY_EVENT && input.Event.KeyEvent.bKeyDown == true){
FlushConsoleInputBuffer(hIn);
read = 0;
return input.Event.KeyEvent.wVirtualKeyCode;
}
}
return 0;
}
开发者ID:Rubiks14,项目名称:ASCII,代码行数:12,代码来源:Input.cpp
示例4: _kbhit_nolock
extern "C" int __cdecl _kbhit_nolock()
{
// If a character has been pushed back, return TRUE:
if (chbuf != -1)
return TRUE;
if (__dcrt_lowio_console_input_handle == -2)
__dcrt_lowio_initialize_console_input();
if (__dcrt_lowio_console_input_handle == -1)
return FALSE;
HANDLE const console_handle = reinterpret_cast<HANDLE>(__dcrt_lowio_console_input_handle);
// Peek at all pending console events:
DWORD num_pending;
if (GetNumberOfConsoleInputEvents(console_handle, &num_pending) == 0)
return FALSE;
if (num_pending == 0)
return FALSE;
__crt_scoped_stack_ptr<INPUT_RECORD> const input_buffer(_malloca_crt_t(INPUT_RECORD, num_pending));
if (input_buffer.get() == nullptr)
return FALSE;
DWORD num_peeked;
if (PeekConsoleInput(console_handle, input_buffer.get(), num_pending, &num_peeked) == 0)
return FALSE;
if (num_peeked == 0 || num_peeked > num_pending)
return FALSE;
// Scan all of the peeked events to determine if any is a key event
// that should be recognized:
for (INPUT_RECORD* p = input_buffer.get(); num_peeked > 0; --num_peeked, ++p)
{
if (p->EventType != KEY_EVENT)
continue;
if (!p->Event.KeyEvent.bKeyDown)
continue;
if (p->Event.KeyEvent.uChar.AsciiChar == 0 &&
_getextendedkeycode(&p->Event.KeyEvent) == nullptr)
continue;
return TRUE;
}
return FALSE;
}
开发者ID:DinrusGroup,项目名称:DinrusUcrtBased,代码行数:52,代码来源:getch.cpp
示例5: console_isch
bool console_isch (void)
{
if (console_buffer) {
return 0;
} else if (realconsole) {
return false;
} else if (consoleopen < 0) {
DWORD events = 0;
GetNumberOfConsoleInputEvents (stdinput, &events);
return events > 0;
}
return false;
}
开发者ID:jorditorrentsguillen,项目名称:WinUAE,代码行数:13,代码来源:writelog.cpp
示例6: getEvents
DWORD getEvents(INPUT_RECORD **record)
{
HANDLE rHnd= GetStdHandle(STD_INPUT_HANDLE);
DWORD numEvents=0;
DWORD numEventsRead=0;
GetNumberOfConsoleInputEvents(rHnd, &numEvents);
if(numEvents)
{
*record=new INPUT_RECORD[numEvents];
ReadConsoleInput(rHnd, *record, numEvents, &numEventsRead);
}
return numEventsRead;
}
开发者ID:lordseanington,项目名称:ASCII-Graphics,代码行数:13,代码来源:input.cpp
示例7: GetNumberOfConsoleInputEvents
BOOL THardwareInfo::getKeyEvent( TEvent& event )
{
if( !pendingEvent )
{
GetNumberOfConsoleInputEvents( consoleHandle[cnInput], &pendingEvent );
if( pendingEvent )
ReadConsoleInput( consoleHandle[cnInput], &irBuffer, 1, &pendingEvent );
}
if( pendingEvent )
{
if( irBuffer.EventType == KEY_EVENT && irBuffer.Event.KeyEvent.bKeyDown )
{
event.what = evKeyDown;
event.keyDown.charScan.scanCode = irBuffer.Event.KeyEvent.wVirtualScanCode;
event.keyDown.charScan.charCode = irBuffer.Event.KeyEvent.uChar.AsciiChar;
event.keyDown.controlKeyState = irBuffer.Event.KeyEvent.dwControlKeyState;
/* Convert NT style virtual scan codes to PC BIOS codes.
*/
if( (event.keyDown.controlKeyState & (kbShift | kbAltShift | kbCtrlShift)) != 0 )
{
uchar index = irBuffer.Event.KeyEvent.wVirtualScanCode;
if ((event.keyDown.controlKeyState & kbShift) && ShiftCvt[index] != 0)
event.keyDown.keyCode = ShiftCvt[index];
else if ((event.keyDown.controlKeyState & kbCtrlShift) && CtrlCvt[index] != 0)
event.keyDown.keyCode = CtrlCvt[index];
else if ((event.keyDown.controlKeyState & kbAltShift) && AltCvt[index] != 0)
event.keyDown.keyCode = AltCvt[index];
}
/* Set/Reset insert flag.
*/
if( event.keyDown.keyCode == kbIns )
insertState = !insertState;
if( insertState )
event.keyDown.controlKeyState |= kbInsState;
pendingEvent = 0;
return True;
}
// Ignore all events except mouse events. Pending mouse events will
// be read on the next polling loop.
else if( irBuffer.EventType != MOUSE_EVENT )
pendingEvent = 0;
}
return False;
}
开发者ID:gdobra,项目名称:tvision,代码行数:51,代码来源:HARDWRVR.cpp
示例8: GetStdHandle
// @author Andre Allan Ponce
// @author Computergeek01 (for the keyboard input stuff)
// @author Duoas (for more keyboard input stuff)
// url: http://www.cplusplus.com/forum/beginner/75529/
// url: http://www.cplusplus.com/forum/articles/7312/#msg33734
void Game::runGame(){
bool running = true;
HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE);
DWORD NumInputs = 0;
DWORD InputsRead = 0;
INPUT_RECORD irInput;
GetNumberOfConsoleInputEvents(hInput, &NumInputs);
int old_state = 0;
clock_t startTime = clock();
while(running){
//printGame();
switch(state){
case STATE_PRE_GAME:{
createWorld();
preGameInit();
state = STATE_LEVEL_ONE;
break;
}
case STATE_GAME_FINISH:{
break;
}
case STATE_WAIT:{
if(clock() - startTime > 20){ // it was too fast at one point
state = old_state;
}
//*/
//Sleep(1*1000);
//state = old_state;
break;
}
default:{
printGame();
do ReadConsoleInput( hInput, &irInput, 1, &InputsRead );
while ((irInput.EventType != KEY_EVENT) || irInput.Event.KeyEvent.bKeyDown);
//ReadConsoleInput(hInput, &irInput, 1, &InputsRead);
startTime = clock();
Location* thisRoom = world[currX][currY];
getKeyInput(irInput.Event.KeyEvent.wVirtualKeyCode, thisRoom);
switch(state){
case STATE_LEVEL_ONE:{
old_state = STATE_LEVEL_ONE;
state = STATE_WAIT;
break;
}
}
break;
}
}
}
}
开发者ID:suhhmin,项目名称:comp-projects-1,代码行数:56,代码来源:game.cpp
示例9: WinStatCon
Bool TERMWINDOWMEMBER WinStatCon(void)
{
if (TermWindowCollection.InFocus(this))
{
DWORD Number;
if (GetNumberOfConsoleInputEvents(hConsoleInput, &Number))
{
return (!!Number);
}
}
return (FALSE);
}
开发者ID:dylancarlson,项目名称:citplus,代码行数:14,代码来源:outwin.cpp
示例10: read_input
static void read_input(void)
{
DWORD retval;
HANDLE in = GetStdHandle(STD_INPUT_HANDLE);
/*check if there are input events*/
if (!GetNumberOfConsoleInputEvents(in, &retval))
return;
if (!retval)
return;
/*read all events*/
INPUT_RECORD eventbuffer[128];
if (!ReadConsoleInput(in, eventbuffer, MP_ARRAY_SIZE(eventbuffer), &retval))
return;
/*filter out keyevents*/
for (int i = 0; i < retval; i++) {
switch (eventbuffer[i].EventType) {
case KEY_EVENT: {
KEY_EVENT_RECORD *record = &eventbuffer[i].Event.KeyEvent;
/*only a pressed key is interesting for us*/
if (record->bKeyDown) {
UINT vkey = record->wVirtualKeyCode;
bool ext = record->dwControlKeyState & ENHANCED_KEY;
int mpkey = mp_w32_vkey_to_mpkey(vkey, ext);
if (mpkey) {
mp_input_put_key(input_ctx, mpkey);
} else {
/*only characters should be remaining*/
int c = record->uChar.UnicodeChar;
if (c > 0)
mp_input_put_key(input_ctx, c);
}
}
break;
}
case MOUSE_EVENT:
case WINDOW_BUFFER_SIZE_EVENT:
case FOCUS_EVENT:
case MENU_EVENT:
default:
break;
}
}
return;
}
开发者ID:AddictXQ,项目名称:mpv,代码行数:49,代码来源:terminal-win.c
示例11: check_input
int check_input()
{
DWORD dw_events, dw_bytes;
if (console) {
GetNumberOfConsoleInputEvents(input, &dw_events);
return dw_events > 1;
} else if (bytes_left > 0) {
return 1;
} else if (PeekNamedPipe(input, NULL, 0, NULL, &dw_bytes, NULL)) {
bytes_left = dw_bytes;
return bytes_left > 0;
} else {
return 1;
}
}
开发者ID:Chaozz,项目名称:happygg,代码行数:15,代码来源:pipe.cpp
示例12: defined
void Keyboard::Flush()
{
#if defined(_MSC_VER)
int nNumberOfEvents = 0;
GetNumberOfConsoleInputEvents(this->m_hStdIn, (LPDWORD)&nNumberOfEvents);
for (int i = 0; i < nNumberOfEvents; i++)
{
INPUT_RECORD buffer = {};
DWORD nNumberOfEventsRead = 0;
ReadConsoleInput(this->m_hStdIn, &buffer, 1, &nNumberOfEventsRead);
}
#endif
}
开发者ID:saber2014,项目名称:MathGame,代码行数:15,代码来源:keyboard.cpp
示例13: PreReadConsoleInput
// Helper function
void PreReadConsoleInput(HANDLE hConIn, DWORD nFlags/*enum CEReadConsoleInputFlags*/, CESERVER_CONSOLE_APP_MAPPING** ppAppMap = NULL)
{
#if defined(_DEBUG) && defined(PRE_PEEK_CONSOLE_INPUT)
INPUT_RECORD ir = {}; DWORD nRead = 0, nBuffer = 0;
BOOL bNumGot = GetNumberOfConsoleInputEvents(hConIn, &nBuffer);
BOOL bConInPeek = nBuffer ? PeekConsoleInputW(hConIn, &ir, 1, &nRead) : FALSE;
#endif
if (gbPowerShellMonitorProgress)
{
CheckPowershellProgressPresence();
}
if (gbCurDirChanged)
{
gbCurDirChanged = false;
if (ghConEmuWndDC)
{
if (gFarMode.cbSize
&& gFarMode.OnCurDirChanged
&& !IsBadCodePtr((FARPROC)gFarMode.OnCurDirChanged))
{
gFarMode.OnCurDirChanged();
}
else
{
CEStr szDir;
if (GetDirectory(szDir) > 0)
{
// Sends CECMD_STORECURDIR into RConServer
SendCurrentDirectory(ghConWnd, szDir);
}
}
}
}
if (!(nFlags & rcif_Peek))
{
// On the one hand - there is a problem with unexpected Enter/Space keypress
// github#19: After executing php.exe from command prompt (it runs by Enter KeyDown)
// the app gets in its input queue unexpected Enter KeyUp
// On the other hand - application must be able to understand if the key was released
// Powershell's 'get-help Get-ChildItem -full | out-host -paging' or Issue 1927 (jilrun.exe)
CESERVER_CONSOLE_APP_MAPPING* pAppMap = UpdateAppMapFlags(nFlags);
if (pAppMap && ppAppMap) *ppAppMap = pAppMap;
}
}
开发者ID:1833183060,项目名称:ConEmu,代码行数:49,代码来源:hkConsoleInput.cpp
示例14: terminal_setup_getch
void terminal_setup_getch(struct input_ctx *ictx)
{
assert(!running);
HANDLE in = GetStdHandle(STD_INPUT_HANDLE);
if (GetNumberOfConsoleInputEvents(in, &(DWORD){0})) {
input_ctx = ictx;
death = CreateEvent(NULL, TRUE, FALSE, NULL);
if (!death)
return;
if (pthread_create(&input_thread, NULL, input_thread_fn, NULL)) {
CloseHandle(death);
return;
}
running = true;
}
}
开发者ID:AddictXQ,项目名称:mpv,代码行数:17,代码来源:terminal-win.c
示例15: FlushMouseEvents
void FlushMouseEvents()
{
if (ghConWnd)
{
HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
DWORD nTotal = 0;
if (GetNumberOfConsoleInputEvents(h, &nTotal) && nTotal)
{
INPUT_RECORD *pr = (INPUT_RECORD*)calloc(nTotal, sizeof(*pr));
if (pr && PeekConsoleInput(h, pr, nTotal, &nTotal) && nTotal)
{
bool bHasMouse = false;
DWORD j = 0;
for (DWORD i = 0; i < nTotal; i++)
{
if (pr[i].EventType == MOUSE_EVENT)
{
bHasMouse = true;
continue;
}
else
{
if (i > j)
pr[j] = pr[i];
j++;
}
}
// Если были мышиные события - сбросить их
if (bHasMouse)
{
if (FlushConsoleInputBuffer(h))
{
// Но если были НЕ мышиные - вернуть их в буфер
if (j > 0)
{
WriteConsoleInput(h, pr, j, &nTotal);
}
}
}
}
}
}
}
开发者ID:alexlav,项目名称:conemu,代码行数:44,代码来源:Entry.cpp
示例16: GetNumberOfConsoleInputEvents
void cgMouse::updateMouse()
{
_isDown.reset();
_isUp.reset();
_scroll = CG_MOUSE_SCROLL_NONE;
DWORD numEvents;
DWORD numEventsRead;
GetNumberOfConsoleInputEvents( cgWindow::inputHandle, &numEvents);
if( numEvents != 0 )
{
INPUT_RECORD *eventBuffer = new INPUT_RECORD[numEvents];
ReadConsoleInput(cgWindow::inputHandle, eventBuffer, numEvents, &numEventsRead);
if(eventBuffer[0].EventType == MOUSE_EVENT)
{
if( eventBuffer[0].Event.MouseEvent.dwEventFlags & MOUSE_MOVED )
{
_position.x = eventBuffer[0].Event.MouseEvent.dwMousePosition.X;
_position.y = eventBuffer[0].Event.MouseEvent.dwMousePosition.Y;
}
if( eventBuffer[0].Event.MouseEvent.dwEventFlags & MOUSE_WHEELED )
{
int state = eventBuffer[0].Event.MouseEvent.dwButtonState;
_scroll = (0<state) - (state<0);
}
_lastState = _isPressed;
for( int a(0); a<3; a++ )
{
_isPressed[a] = eventBuffer[0].Event.MouseEvent.dwButtonState & (1<<a);
}
_isDown = ( _isPressed & (~_lastState) );
_isUp = ( (~_isPressed) & _lastState );
}
delete[] eventBuffer;
}
}
开发者ID:kojotek,项目名称:OpenCoyoteGraphics,代码行数:43,代码来源:cgMouse.cpp
示例17: pipe_read_avail_console
// returns the number of keypress events in the console input queue,
// or -1 if there is an error (don't forget this!!)
static int pipe_read_avail_console(Q_PIPE_ID pipe)
{
DWORD count, i;
INPUT_RECORD *rec;
int n, icount, total;
// how many events are there?
if(!GetNumberOfConsoleInputEvents(pipe, &count))
return -1;
// peek them all
rec = (INPUT_RECORD *)malloc(count * sizeof(INPUT_RECORD));
BOOL ret;
#if QT_VERSION >= 0x050000
ret = PeekConsoleInputW(pipe, rec, count, &i);
#else
QT_WA(
ret = PeekConsoleInputW(pipe, rec, count, &i);
,
开发者ID:Esf-Software,项目名称:qca,代码行数:21,代码来源:qpipe.cpp
示例18: kbhit
int kbhit(void)
{
INPUT_RECORD inp;
DWORD nread, nevents;
HANDLE hin;
if (_cFlag) /* has a character been ungetch'd? */
return (1);
hin = GetStdHandle(STD_INPUT_HANDLE);
/* Discard console events until we come to a keydown event,
* or the event queue is empty.
*/
while (GetNumberOfConsoleInputEvents(hin, &nevents) == TRUE && nevents > 0)
{
/* Take a look at the first input event in the queue.
* If we can't peek at it, something bad happened.
*/
if (PeekConsoleInput(hin, &inp, 1, &nread) != TRUE)
break;
/* If the event is a key-down, a key has been hit.
*/
if ((inp.EventType & KEY_EVENT) != 0 &&
inp.Event.KeyEvent.bKeyDown != 0)
{
dwControlKeyState = inp.Event.KeyEvent.dwControlKeyState;
return (1);
}
/* It's not a key-down event, discard it.
* NOTE: this discards all other console input events, including
* mouse events! Thus, kbhit() should not be used in programs
* that track the mouse or window resizing.
*/
if (ReadConsoleInput(hin, &inp, 1, &nread) != TRUE)
break;
}
return (0);
}
开发者ID:OS2World,项目名称:UTIL-FILEMANAGER-OnScreen2,代码行数:41,代码来源:osgetch.cpp
示例19: GetStdHandle
KB_INPUT WindowsInputController::keys_pressed() {
HANDLE hStdin = GetStdHandle( STD_INPUT_HANDLE );
if( hStdin == INVALID_HANDLE_VALUE )
return K_NO_INPUT;
DWORD num_read, num_avail = 0;
if( !GetNumberOfConsoleInputEvents( hStdin, &num_avail ) || !num_avail )
return K_NO_INPUT;
INPUT_RECORD irInBuf[128];
if( !ReadConsoleInput( hStdin, irInBuf, 128, &num_read ) ) // number of records read
return K_NO_INPUT;
for( DWORD i = 0; i < num_read; i++ )
{
switch(irInBuf[i].EventType)
{
case KEY_EVENT:
{
KEY_EVENT_RECORD rec = irInBuf[i].Event.KeyEvent;
if( rec.bKeyDown && map_virtual_key_code( rec.wVirtualKeyCode ) != K_NO_INPUT )
return map_virtual_key_code( rec.wVirtualKeyCode );
break;
}
case MOUSE_EVENT: break;
case WINDOW_BUFFER_SIZE_EVENT: break;
case FOCUS_EVENT: break;
case MENU_EVENT: break;
default:
return K_NO_INPUT;
break;
}
}
return K_NO_INPUT;
}
开发者ID:TomaszSakrejda,项目名称:musiqcWashington,代码行数:40,代码来源:input.cpp
示例20: input_waiting
bool input_waiting()
{
#ifndef WIN32
fd_set readfds;
struct timeval tv;
FD_ZERO(&readfds);
FD_SET(fileno(stdin), &readfds);
tv.tv_sec = 0;
tv.tv_usec = 0;
select(16, &readfds, nullptr, nullptr, &tv);
return (FD_ISSET(fileno(stdin), &readfds));
#else
static int init = 0, pipe;
static HANDLE inh;
DWORD dw;
if(!init)
{
init = 1;
inh = GetStdHandle(STD_INPUT_HANDLE);
pipe = !GetConsoleMode(inh, &dw);
if(!pipe)
{
SetConsoleMode(inh, dw & ~(ENABLE_MOUSE_INPUT|ENABLE_WINDOW_INPUT));
FlushConsoleInputBuffer(inh);
}
}
if(pipe)
{
if(!PeekNamedPipe(inh, NULL, 0, NULL, &dw, NULL)) return 1;
return dw;
}
else
{
GetNumberOfConsoleInputEvents(inh, &dw);
return dw <= 1 ? 0 : dw;
}
#endif // WIN32
}
开发者ID:ServerTech,项目名称:cortex,代码行数:40,代码来源:misc.cpp
注:本文中的GetNumberOfConsoleInputEvents函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论