void CInputManager::Update( DWORD tickCount ) { if (m_pInputModule && m_pInputModule->IsInitialized()) { m_pInputModule->Update(); HandleKeyBindings(); HandleKeyboard(); HandleMouseEvents(); } }
AUI_ERRCODE aui_UI::Process( void ) { Idle(); // Scan human interface devices - when available if (m_mouse) HandleMouseEvents(); if (m_keyboard) HandleKeyboardEvents(); if (m_joystick) HandleJoystickEvents(); HandleActions(); HandleDestructiveActions(); Draw(); return AUI_ERRCODE_OK; }
void SoundParameterGraph::Render( int realX, int realY, bool highlighted, bool clicked ) { InvertedBox::Render( realX, realY, false, false ); glColor4f( 1.0, 1.0, 1.0, 1.0 ); g_editorFont.DrawText2D( realX + m_w/2, realY + m_h - 10, 16, LANGUAGEPHRASE(m_parent->m_name) ); if( m_parameter->m_type == SoundParameter::TypeLinked ) { g_editorFont.DrawText2D( realX + 10, realY + 10, 16, m_parameter->GetLinkName( m_parameter->m_link ) ); } RescaleAxis (); RenderAxis ( realX, realY ); RenderValues ( realX, realY ); RenderOutput ( realX, realY ); HandleMouseEvents(); }
int VideoDriver_SDL::PollEvent() { SDL_Event ev; if (!SDL_CALL SDL_PollEvent(&ev)) return -2; switch (ev.type) { case SDL_MOUSEMOTION: if (_cursor.fix_at) { int dx = ev.motion.x - _cursor.pos.x; int dy = ev.motion.y - _cursor.pos.y; if (dx != 0 || dy != 0) { _cursor.delta.x = dx; _cursor.delta.y = dy; SDL_CALL SDL_WarpMouse(_cursor.pos.x, _cursor.pos.y); } } else { _cursor.delta.x = ev.motion.x - _cursor.pos.x; _cursor.delta.y = ev.motion.y - _cursor.pos.y; _cursor.pos.x = ev.motion.x; _cursor.pos.y = ev.motion.y; _cursor.dirty = true; } HandleMouseEvents(); break; case SDL_MOUSEBUTTONDOWN: if (_rightclick_emulate && SDL_CALL SDL_GetModState() & KMOD_CTRL) { ev.button.button = SDL_BUTTON_RIGHT; } switch (ev.button.button) { case SDL_BUTTON_LEFT: _left_button_down = true; break; case SDL_BUTTON_RIGHT: _right_button_down = true; _right_button_clicked = true; break; case SDL_BUTTON_WHEELUP: _cursor.wheel--; break; case SDL_BUTTON_WHEELDOWN: _cursor.wheel++; break; default: break; } HandleMouseEvents(); break; case SDL_MOUSEBUTTONUP: if (_rightclick_emulate) { _right_button_down = false; _left_button_down = false; _left_button_clicked = false; } else if (ev.button.button == SDL_BUTTON_LEFT) { _left_button_down = false; _left_button_clicked = false; } else if (ev.button.button == SDL_BUTTON_RIGHT) { _right_button_down = false; } HandleMouseEvents(); break; case SDL_ACTIVEEVENT: if (!(ev.active.state & SDL_APPMOUSEFOCUS)) break; if (ev.active.gain) { // mouse entered the window, enable cursor _cursor.in_window = true; } else { UndrawMouseCursor(); // mouse left the window, undraw cursor _cursor.in_window = false; } break; case SDL_QUIT: HandleExitGameRequest(); break; case SDL_KEYDOWN: // Toggle full-screen on ALT + ENTER/F if ((ev.key.keysym.mod & (KMOD_ALT | KMOD_META)) && (ev.key.keysym.sym == SDLK_RETURN || ev.key.keysym.sym == SDLK_f)) { ToggleFullScreen(!_fullscreen); } else { HandleKeypress(ConvertSdlKeyIntoMy(&ev.key.keysym)); } break; case SDL_VIDEORESIZE: { int w = max(ev.resize.w, 64); int h = max(ev.resize.h, 64); CreateMainSurface(w, h); break; } case SDL_VIDEOEXPOSE: { /* Force a redraw of the entire screen. Note * that SDL 1.2 seems to do this automatically * in most cases, but 1.3 / 2.0 does not. */ _num_dirty_rects = MAX_DIRTY_RECTS + 1; break; } } return -1; }
static void PollEvent() { poll_mouse(); bool mouse_action = false; /* Mouse buttons */ static int prev_button_state; if (prev_button_state != mouse_b) { uint diff = prev_button_state ^ mouse_b; while (diff != 0) { uint button = FindFirstBit(diff); ClrBit(diff, button); if (HasBit(mouse_b, button)) { /* Pressed mouse button */ if (_rightclick_emulate && (key_shifts & KB_CTRL_FLAG)) { button = RIGHT_BUTTON; ClrBit(diff, RIGHT_BUTTON); } switch (button) { case LEFT_BUTTON: _left_button_down = true; break; case RIGHT_BUTTON: _right_button_down = true; _right_button_clicked = true; break; default: /* ignore rest */ break; } } else { /* Released mouse button */ if (_rightclick_emulate) { _right_button_down = false; _left_button_down = false; _left_button_clicked = false; } else if (button == LEFT_BUTTON) { _left_button_down = false; _left_button_clicked = false; } else if (button == RIGHT_BUTTON) { _right_button_down = false; } } } prev_button_state = mouse_b; mouse_action = true; } /* Mouse movement */ int dx = mouse_x - _cursor.pos.x; int dy = mouse_y - _cursor.pos.y; if (dx != 0 || dy != 0) { if (_cursor.fix_at) { _cursor.delta.x = dx; _cursor.delta.y = dy; position_mouse(_cursor.pos.x, _cursor.pos.y); } else { _cursor.delta.x = dx; _cursor.delta.y = dy; _cursor.pos.x = mouse_x; _cursor.pos.y = mouse_y; _cursor.dirty = true; } mouse_action = true; } static int prev_mouse_z = 0; if (prev_mouse_z != mouse_z) { _cursor.wheel = (prev_mouse_z - mouse_z) < 0 ? -1 : 1; prev_mouse_z = mouse_z; mouse_action = true; } if (mouse_action) HandleMouseEvents(); poll_keyboard(); if ((key_shifts & KB_ALT_FLAG) && (key[KEY_ENTER] || key[KEY_F])) { ToggleFullScreen(!_fullscreen); } else if (keypressed()) { WChar character; uint keycode = ConvertAllegroKeyIntoMy(&character); HandleKeypress(keycode, character); } }
AUI_ERRCODE aui_UI::HandleMouseEvents( sint32 numEvents, aui_MouseEvent *events ) { AUI_ERRCODE errcode = AUI_ERRCODE_UNHANDLED; if (!m_mouse) return errcode; aui_MouseEvent *curEvent = events; static aui_MouseEvent mouseEvents[ k_MOUSE_MAXINPUT ]; if ( !numEvents && !events ) { numEvents = m_mouse->ManipulateInputs( mouseEvents, FALSE ); curEvent = mouseEvents; } TagMouseEvents( numEvents, curEvent ); for ( sint32 k = numEvents; k; k--, curEvent++ ) { SetWhichSeesMouse( NULL ); ListPos position = m_childList->GetHeadPosition(); for ( sint32 i = m_childList->L(); i; i-- ) { aui_Window *window = (aui_Window *)m_childList->GetNext( position ); if ( !window->IsHidden() && window->Type() != AUI_WINDOW_TYPE_TIP ) { errcode = window->HandleMouseEvent( curEvent, !window->IgnoringEvents() ); if ( m_childListChanged || errcode == AUI_ERRCODE_HANDLEDEXCLUSIVE) { m_childListChanged = FALSE; position = m_childList->GetHeadPosition(); for ( i = m_childList->L(); i; i-- ) { window = (aui_Window *)m_childList->GetNext( position ); if ( !window->IsHidden() && window->Type() != AUI_WINDOW_TYPE_TIP ) { window->HandleMouseEvent( curEvent, FALSE ); } } if ( k > 1 ) return HandleMouseEvents( k - 1, curEvent + 1 ); return errcode; } } } } return errcode; }