Ejemplo n.º 1
0
static void OnArrow(void *wnd, int action)
{
  GEM_WINDOW *gwnd = (GEM_WINDOW *) wnd ;
  HEX_DUMP   *hex_dump = (HEX_DUMP *) gwnd->Extension ;
  long       old_xcursor, old_ycursor, old_ystart ;

  old_xcursor = hex_dump->xcursor ;
  old_ycursor = hex_dump->ycursor ;
  old_ystart  = hex_dump->ystart ;

  switch( action )
  {
    case WA_UPPAGE : OnKeyPressed( wnd, CURSOR_SUP ) ;
                     break ;

    case WA_DNPAGE : OnKeyPressed( wnd, CURSOR_SDN ) ;
                     break ;

    case WA_UPLINE : if ( hex_dump->ystart > 0 ) hex_dump->ystart-- ;
                     break ;

    case WA_DNLINE : if ( hex_dump->ystart < hex_dump->total_nb_lines - hex_dump->nb_lines_on_window ) hex_dump->ystart++ ;
                     break ;
  }

  CheckValid( hex_dump ) ;

  if ( ( old_xcursor != hex_dump->xcursor ) || ( old_ycursor != hex_dump->ycursor ) ) SmartInfos( gwnd ) ;
  if ( old_ystart != hex_dump->ystart ) SmartRePaint( gwnd, old_ystart ) ;
}
Ejemplo n.º 2
0
BOOL CBaseScreen::OnWndProc(void* /*pi*/, AEEEvent eCode , uint16 wParam , uint32 dwParam) // 窗口主消息处理函数
{
	BOOL bRet = FALSE;
	switch (eCode)
	{
	case EVT_KEY_PRESS:
		{
			bRet = OnKeyPressed(wParam);
		}
		break;
	case EVT_KEY_RELEASE:
		{
			bRet = OnKeyReleased(wParam);
		}
		break;
	case EVT_KEY_HELD:
		{
			//注意这条消息没有处理
		}
		break;
	case EVT_APP_SUSPEND:
		{
			bRet = OnSuspend();
		}
		break;
	case EVT_APP_RESUME:
		{
			bRet = OnResume();
		}
		break;
	case EVT_EXT_PEN_PRESS:
		{
			
			bRet = OnPointerPressed((int)wParam, (int)dwParam);
		}
		break;
	case EVT_EXT_PEN:
		{
			bRet = OnPointerDragged((int)wParam, (int)dwParam);
		}
		break;
	case EVT_EXT_PEN_RELEASE:
		{
			bRet = OnPointerReleased((int)wParam, (int)dwParam);
		}
		break;
	default:
		break;
	}
	return bRet;
}
Ejemplo n.º 3
0
		virtual void CallEvent(FKeyboardEvent& e)
		{
			switch (e.type())
			{
			case fevents::kKeyPress:
				OnKeyPressed(e);
				break;
			case fevents::kKeyRelease:
				OnKeyReleased(e);
				break;
			default:
				break;
			}
		}
Ejemplo n.º 4
0
void InputEventController::ProcessInputEvent(const SDL_Event &evt)
{
	switch (evt.type) {
		case SDL_KEYDOWN: OnKeyPressed(evt.key); break;
		case SDL_KEYUP: OnKeyReleased(evt.key); break;
		case SDL_TEXTINPUT: OnTextInput(evt.text); break;

		case SDL_MOUSEMOTION: OnMouseMoved(evt.motion); break;
		case SDL_MOUSEBUTTONDOWN: OnMousePressed(evt.button); break;
		case SDL_MOUSEBUTTONUP: OnMouseReleased(evt.button); break;
		case SDL_MOUSEWHEEL: OnMouseWheel(evt.wheel); break;

		default:
			HR_LOG(info) << "Unhandled input event type: " << evt.type;
	}
}
Ejemplo n.º 5
0
	void Input::OnAlt2CursorPressed(const Vec2F& pos)
	{
		OnKeyPressed(-2);
		OnCursorMoved(pos);
	}
Ejemplo n.º 6
0
    void OnEvent(SDL_Event* Event)
    {
        /* if(Event->type < SDL_USEREVENT)
        DebugTrace("Event received" << Event->type);*/
        switch(Event->type)
        {
        case SDL_QUIT:
            Running = false;
            break;

        /* On Android, this is triggered when the device orientation changed */
        case SDL_WINDOWEVENT:
            window = SDL_GetWindowFromID(Event->window.windowID);
            int h,w;
            SDL_GetWindowSize(window, &w, &h);
            OnResize(w, h);
            break;

        case SDL_KEYDOWN:
        case SDL_KEYUP:
            OnKeyPressed(Event->key);
            break;

        case SDL_MOUSEMOTION:
            OnMouseMoved(Event->motion);
            break;

        case SDL_MOUSEBUTTONDOWN:
            OnMouseClicked(Event->button);
            break;

        case SDL_MOUSEBUTTONUP:
            {
                Uint32 eventTime = SDL_GetTicks();
                if (eventTime - lastMouseUpTime <= 500)
                {
                    OnMouseDoubleClicked(Event->button);
                }
                else
                {
                    OnMouseClicked(Event->button);
                }
                lastMouseUpTime = eventTime;
            }
            break;

        case SDL_MOUSEWHEEL:
            OnMouseWheel(Event->wheel.x, Event->wheel.y);
            break;

        case SDL_FINGERMOTION:
        case SDL_FINGERDOWN:
        case SDL_FINGERUP:
        	DebugTrace("Finger Up/Down/Motion detected:" );
            OnTouchEvent(Event->tfinger);
            break;

        case SDL_MULTIGESTURE:
            DebugTrace("Multigesture : touchId " << Event->mgesture.touchId
                    << ", x " << Event->mgesture.x
                    << ", y " << Event->mgesture.y
                    << ", dTheta " << Event->mgesture.dTheta
                    << ", dDist " << Event->mgesture.dDist
                    << ", numFingers " << Event->mgesture.numFingers);
            break;

        case SDL_JOYBALLMOTION:
            DebugTrace("Flick gesture detected, x: " << Event->jball.xrel << ", y: " << Event->jball.yrel);
            g_engine->Scroll(Event->jball.xrel, Event->jball.yrel);
            break;
        }
    }
Ejemplo n.º 7
0
void State::OnEvent(const sf::Event::Event &e)
{
	switch (e.Type)
	{
		case sf::Event::KeyPressed:
			OnKeyPressed(e.Key.Code, e.Key.Alt, e.Key.Control, e.Key.Shift);
			break;

		case sf::Event::KeyReleased:
			OnKeyReleased(e.Key.Code, e.Key.Alt, e.Key.Control, e.Key.Shift);
			break;

		case sf::Event::MouseMoved:
			OnMouseMoved(e.MouseMove.X, e.MouseMove.Y);
			break;

		case sf::Event::MouseButtonPressed:
		{
			int x = e.MouseButton.X;
			int y = e.MouseButton.Y;

			switch (e.MouseButton.Button)
			{
				case sf::Mouse::Left:
					OnMouseLeftDown(x, y);
					buttons_[0] = true;
					break;

				case sf::Mouse::Right:
					OnMouseRightDown(x, y);
					buttons_[1] = true;
					break;

				case sf::Mouse::Middle:
					OnMouseMiddleDown(x, y);
					buttons_[2] = true;
					break;
			}

			break;
		}

		case sf::Event::MouseButtonReleased:
		{
			int x = e.MouseButton.X;
			int y = e.MouseButton.Y;

			switch (e.MouseButton.Button)
			{
				case sf::Mouse::Left:
					OnMouseLeftUp(x, y);

					if (buttons_[0])
					{
						buttons_[0] = false;
						OnMouseLeftClick(x, y);
					}

					break;

				case sf::Mouse::Right:
					OnMouseRightUp(x, y);

					if (buttons_[1])
					{
						buttons_[1] = false;
						OnMouseRightClick(x, y);
					}

					break;

				case sf::Mouse::Middle:
					OnMouseMiddleUp(x, y);

					if (buttons_[2])
					{
						buttons_[2] = false;
						OnMouseMiddleClick(x, y);
					}

					break;
			}

			break;
		}

		case sf::Event::MouseEntered:
			OnMouseEntered();
			break;

		case sf::Event::MouseLeft:
			OnMouseExited();
			break;

		case sf::Event::GainedFocus:
			OnGainedFocus();
			break;

		case sf::Event::LostFocus:
			OnLostFocus();
			break;
	}
}
Ejemplo n.º 8
0
void Application::Run()
{
    //
    // keyboard
    //

    if (keyboard_needs_poll())
        poll_keyboard();

    for (int k = 0; k < 256; k++)
    {
        if (key[k])
        {
            OnKeyPress(k);

            if (!prevKeyState[k])
                OnKeyPressed(k);
        }
        else if (!key[k])
        {
            if (prevKeyState[k])
                OnKeyReleased(k);
        }
    }

    memcpy(prevKeyState,(char*)key,256);

    //
    // mouse
    //

    if (mouse_needs_poll())
        poll_mouse();

    for (int button = 0; button < (numMouseButtons); button++)
    {
        if ((mouse_b & (1 << button)) != 0)
        {
            mouseButtons[button] = true;
        }
        else
        {
            mouseButtons[button] = false;
        }

        if (mouseButtons[button] && (!prevMouseButtons[button]))
        {
            OnMousePressed(button, mouse_x, mouse_y);

            mousePressedLocs[button].x = mouse_x;
            mousePressedLocs[button].y = mouse_y;
        }
        else if ((!mouseButtons[button]) && prevMouseButtons[button])
        {
            OnMouseReleased(button, mouse_x, mouse_y);

            if ((mousePressedLocs[button].x == mouse_x) &&
                    (mousePressedLocs[button].y == mouse_y))
            {
                OnMouseClick(button,mouse_x,mouse_y);
            }
        }
    }

    memcpy(prevMouseButtons,mouseButtons,sizeof(bool)*(numMouseButtons+1));

    if ((mouse_x != prevMouseX) || (mouse_y != prevMouseY))
    {
        OnMouseMove(mouse_x,mouse_y);

        prevMouseX = mouse_x;
        prevMouseY = mouse_y;
    }

    // mouse wheel
    if (mouse_z > prevMouseZ)
    {
        OnMouseWheelUp( mouse_x, mouse_y );
        prevMouseZ = mouse_z;
    }
    else if (mouse_z < prevMouseZ)
    {
        OnMouseWheelDown( mouse_x, mouse_y );
        prevMouseZ = mouse_z;
    }

    //
    // run the game
    //

    show_mouse(NULL);
    RunGame();
    show_mouse(canvas);

    //
    // render canvas to the screen
    //

    blit(canvas,screen,0,0,0,0,screen->w,screen->h);

    //
    // sound polling (to ensure sounds currently playing will keep playing)
    //
    SoundOGG::PollSounds();

    //
    // handle timing
    //

    HandleTiming();
}
Ejemplo n.º 9
0
void KeyboardDevice::OnSystemKeyPressed(int32 systemKeyCode)
{
    DVASSERT(systemKeyCode < MAX_KEYS);
    OnKeyPressed(keyTranslator[systemKeyCode]);
}
Ejemplo n.º 10
0
LRESULT D3DApplication::MessageProcedure(UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	// WM_ACTIVATE is sent when the window is activated or deactivated.  
	case WM_ACTIVATE:
		if (LOWORD(wParam) == WA_INACTIVE)
		{
			m_IsPaused = true;
			m_GameTimer.Stop();
		}
		else
		{
			m_IsPaused = false;
			m_GameTimer.Start();
		}
		return 0;

	// WM_SIZE is sent when the user resizes the window.  
	case WM_SIZE:
		// Save the new client area dimensions.
		m_ClientWidth  = LOWORD(lParam);
		m_ClientHeight = HIWORD(lParam);
		if (m_pDevice)
		{
			if (wParam == SIZE_MINIMIZED)
			{
				m_IsPaused		= true;
				m_IsMinimized	= true;
				m_IsMaximized	= false;
			}
			else if (wParam == SIZE_MAXIMIZED)
			{
				m_IsPaused		= false;
				m_IsMinimized	= false;
				m_IsMaximized	= true;

				OnResize();
			}
			else if (wParam == SIZE_RESTORED)
			{
				// Restoring from minimized state?
				if (m_IsMinimized)
				{
					m_IsPaused		= false;
					m_IsMinimized	= false;

					OnResize();
				}
				// Restoring from maximized state?
				else if (m_IsMaximized)
				{
					m_IsPaused		= false;
					m_IsMaximized	= false;

					OnResize();
				}
				else if (m_IsResizing)
				{
					// do nothing
				}
				else // API call such as SetWindowPos or mSwapChain->SetFullscreenState.
				{
					OnResize();
				}
			}
		}

		return 0;

	// WM_EXITSIZEMOVE is sent when the user grabs the resize bars.
	case WM_ENTERSIZEMOVE:
		m_IsPaused		= true;
		m_IsResizing	= true;
		m_GameTimer.Stop();
		return 0;

	// WM_EXITSIZEMOVE is sent when the user releases the resize bars.
	// Here we reset everything based on the new window dimensions.
	case WM_EXITSIZEMOVE:
		m_IsPaused		= false;
		m_IsResizing	= false;
		m_GameTimer.Start();
		OnResize();
		return 0;
 
	// WM_DESTROY is sent when the window is being destroyed.
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;

	// The WM_MENUCHAR message is sent when a menu is active and the user presses 
	// a key that does not correspond to any mnemonic or accelerator key. 
	case WM_MENUCHAR:
		// Don't beep when we alt-enter.
		return MAKELRESULT(0, MNC_CLOSE);

	// Catch this message so to prevent the window from becoming too small.
	case WM_GETMINMAXINFO:
		((MINMAXINFO*)lParam)->ptMinTrackSize.x = 200;
		((MINMAXINFO*)lParam)->ptMinTrackSize.y = 200; 
		return 0;

	case WM_KEYDOWN:
		OnKeyPressed(wParam);
		return 0;
	}

	return DefWindowProc(m_hMainWindow, message, wParam, lParam);
}
Ejemplo n.º 11
0
void ssd_dialog_send_keyboard_event( const char* utf8char, uint32_t flags)
{ OnKeyPressed( utf8char, flags);}
Ejemplo n.º 12
0
void EventHandler::OnEvent (sf::Event* event)
{
	switch (event->type)
	{
		case sf::Event::Closed:
			//Window closed:
			OnClosed();
			break;
		case sf::Event::Resized:
			//Window resized:
			OnWindowResized (event->size);
		case sf::Event::GainedFocus:
			//Window gained focus:
			OnGainedFocus();
			break;
		case sf::Event::LostFocus:
			//Window lost focus:
			OnLostFocus();
			break;
			break;
		case sf::Event::TextEntered:
			//Text entered:
			OnTextEntered (event->text);
			break;
		case sf::Event::KeyPressed:
			//Key pressed:
			OnKeyPressed (event->key);
			break;
		case sf::Event::KeyReleased:
			//Key released:
			OnKeyReleased (event->key);
			break;
		case sf::Event::MouseWheelMoved:
			//Mouse wheel moved:
			OnMouseWheelMoved (event->mouseWheel);
			break;
		case sf::Event::MouseButtonPressed:
			//Mouse button pressed:
			OnMouseButtonPressed (event->mouseButton);
			break;
		case sf::Event::MouseButtonReleased:
			//Mouse button released:
			OnMouseButtonReleased(event->mouseButton);
			break;
		case sf::Event::MouseMoved:
			//Mouse moved:
			OnMouseMoved (event->mouseMove);
			break;
		case sf::Event::MouseEntered:
			//Mouse entered Window bounds:
			OnMouseEntered();
			break;
		case sf::Event::MouseLeft:
			//Mouse left Window bounds:
			OnMouseLeft();
			break;
		case sf::Event::JoystickButtonPressed:
			//Joystick button pressed:
			OnJoystickButtonPressed (event->joystickButton);
			break;
		case sf::Event::JoystickButtonReleased:
			//Joystick button released:
			OnJoystickButtonReleased(event->joystickButton);
			break;
		case sf::Event::JoystickMoved:
			//Joystick moved:
			OnJoystickMoved(event->joystickMove);
			break;
		case sf::Event::JoystickConnected:
			//Joystick connected:
			OnJoystickConnected (event->joystickConnect);
			break;
		case sf::Event::JoystickDisconnected:
			//Joystick disconnected:
			OnJoystickDisconnected (event->joystickConnect);
			break;
		

	}
}