bool InputState::Update() { bool result = false; _backspacePressed = false; _text = ""; _wheelAmount = 0; SDL_Event e; while (SDL_PollEvent(&e) != 0) { if (e.type == SDL_QUIT) result = true; else if (e.type == SDL_MOUSEBUTTONDOWN) HandleMouseButtonDown(e); else if (e.type == SDL_MOUSEBUTTONUP) HandleMouseButtonUp(e); else if (e.type == SDL_MOUSEWHEEL) HandleMouseWheel(e); else if (e.type == SDL_TEXTINPUT) HandleText(e); else if (e.type == SDL_KEYDOWN) HandleKeyboard(e); } int mousex, mousey; SDL_GetMouseState(&mousex, &mousey); _mousePosition = glm::vec2(float(mousex), _windowSize.y - float(mousey)); return result; }
void CInputManager::Update( DWORD tickCount ) { if (m_pInputModule && m_pInputModule->IsInitialized()) { m_pInputModule->Update(); HandleKeyBindings(); HandleKeyboard(); HandleMouseEvents(); } }
bool GboxInstance::HandleInputEvent(const pp::InputEvent &event) { bool ret = false; // handled? switch (event.GetType()) { case PP_INPUTEVENT_TYPE_KEYDOWN: case PP_INPUTEVENT_TYPE_KEYUP: case PP_INPUTEVENT_TYPE_CHAR: case PP_INPUTEVENT_TYPE_CONTEXTMENU: { pp::KeyboardInputEvent key_event(event); ret = HandleKeyboard(key_event); } break; case PP_INPUTEVENT_TYPE_MOUSEDOWN: case PP_INPUTEVENT_TYPE_MOUSEMOVE: case PP_INPUTEVENT_TYPE_MOUSEUP: case PP_INPUTEVENT_TYPE_MOUSEENTER: case PP_INPUTEVENT_TYPE_MOUSELEAVE: case PP_INPUTEVENT_TYPE_WHEEL: { pp::MouseInputEvent mouse_event(event); ret = HandleMouse(mouse_event); } break; case PP_INPUTEVENT_TYPE_UNDEFINED: case PP_INPUTEVENT_TYPE_RAWKEYDOWN: ret = false; default: break; } #if 1 if (!ret && sca() == 0x3) theLog.info("_Input Event: (%s a) et:%d handled:%d count:%d", kVersion, event.GetType(), ret, ++m_mc); #endif return ret; }
bool CGUIHorizontalScrollBar::WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ){ if(!m_bEnabled) return false; if(!m_bButtonDown && (m_pLeft->WndProc(hWnd, uMsg, wParam, lParam) || m_pRight->WndProc(hWnd, uMsg, wParam, lParam))){ OnMouseLeave(); return true; } switch(uMsg){ // Keyboard messages case WM_KEYDOWN: case WM_SYSKEYDOWN: case WM_KEYUP: case WM_SYSKEYUP: return HandleKeyboard( uMsg, wParam, lParam ); //Mouse Messages case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_MBUTTONDOWN: case WM_MBUTTONUP: case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_XBUTTONDOWN: case WM_XBUTTONUP: case WM_LBUTTONDBLCLK: case WM_MBUTTONDBLCLK: case WM_RBUTTONDBLCLK: case WM_XBUTTONDBLCLK: case WM_MOUSEWHEEL: return HandleMouse( uMsg, wParam, lParam ); default: return false; } }
//***************************************************************************** // // Periodic Functions that need to be called. Should go in main loop // //***************************************************************************** void ScreenPeriodic(void) { // // Handle screen movements. // HandleMovement(); // // Handle button animation. // AnimateButtons(true); // // Handle keyboard entry if it is open. // HandleKeyboard(); // // If nothing has happened for awhile, then move to a new city. // if(g_ui32ScreenSaver == 0) { // // Reset the timeout for 10s to update the screen more often. // g_ui32ScreenSaver = 10 * SYSTEM_TICK_S; // // Trigger a left swipe. // g_sSwipe.eMovement = iSwipeLeft; } WidgetMessageQueueProcess(); }
bool CGUITextBox::WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ){ if(!m_bEnabled) return false; if(!m_bButtonDown && ((m_pVSB && m_pVSB->WndProc(hWnd, uMsg, wParam, lParam)) || (m_pHSB && m_pHSB->WndProc(hWnd, uMsg, wParam, lParam)))) return true; switch(uMsg){ // Keyboard messages case WM_KEYDOWN: case WM_CHAR: case WM_SYSKEYDOWN: case WM_KEYUP: case WM_SYSKEYUP: return HandleKeyboard( uMsg, wParam, lParam ); //Mouse Messages case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_MBUTTONDOWN: case WM_MBUTTONUP: case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_XBUTTONDOWN: case WM_XBUTTONUP: case WM_LBUTTONDBLCLK: case WM_MBUTTONDBLCLK: case WM_RBUTTONDBLCLK: case WM_XBUTTONDBLCLK: case WM_MOUSEWHEEL: return HandleMouse( uMsg, wParam, lParam ); default: return false; } }
void InputManager::Update() { HandleKeyboard(); HandleMouse(); }
int main() { // Variables Initialization: p_player.teleport = false; p_player.p_size = 4; p_player.a_state_size = p_player.p_size; srand(time(NULL)); MapCreation(m_map); SetEnterTeleport(§or); SetExitTeleport(); // Game Loop: while(!over){ tl_start = GetTickCount(); // Updates: HandleKeyboard(); //Wall in face? if(m_map[p_player.x-1][p_player.y] == '|') over = true; //Teleporter in face? if(m_map[p_player.x-1][p_player.y] == 'O'){ m_map[t_enter.x][t_enter.y] = '|'; p_player.teleport = true; p_player.old_x = p_player.x; p_player.old_y = p_player.y; switch(sector){ case 1: points += 20; break; case 2: points += 5; break; case 3: points += 10; break; } //Display points: SetCursorPosition(25,16); printf("Pts:["); SetConsoleTextColor(2); printf("%d", points); SetConsoleTextColor(7); printf("]"); SetEnterTeleport(§or); } //Teleport? if(p_player.teleport){ if(p_player.a_state_size != 0){ m_map[p_player.old_x + p_player.a_state_size - 1][p_player.old_y] = '-'; p_player.a_state_size--; } if(p_player.a_state_size == 0){ p_player.teleport = false; p_player.a_state_size = p_player.p_size; m_map[t_exit.x][t_exit.y] = '|'; SetExitTeleport(); } } //Display: for(j = 0; j < mapYsize; j++){ for(i = 0; i < mapXsize; i++){ if(map_buffer[i][j] != m_map[i][j]){ SetCursorPosition(i, j); if(m_map[i][j] == 'O'){ SetConsoleTextColor(9); }else if(m_map[i][j] == 167){ SetConsoleTextColor(11); } printf("%c", m_map[i][j]); SetConsoleTextColor(7); } } } //FPS Timer: tl_end = GetTickCount(); tl_elapsed = ( tl_end - tl_start ); //If we need we stop a moment the Fps: if(tl_elapsed < fps) Sleep(fps - tl_elapsed); MapBuffering(map_buffer, m_map); } system("cls"); printf("Game over: You got %d pts\n", points); system("pause"); return 0; }