コード例 #1
0
ファイル: system_win32.c プロジェクト: 10n1/Riot
static LRESULT CALLBACK MainWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    static system_t*    s_system = NULL;
    CREATESTRUCT*       createStruct;
    int                 width;
    int                 height;
    switch (message) 
    {
    case WM_CREATE:
        createStruct = ((CREATESTRUCT*)lParam);
        s_system = createStruct->lpCreateParams;
        return 0;
    /* Keyboard input */
    case WM_KEYDOWN:
    case WM_SYSKEYDOWN:
        SetKeyState(s_system, (uint8_t)wParam, 1);
        // Handle Alt-F4 here. TODO: Support disabling it
        if(GetKeyState(kSysKeyF4) && GetKeyState(kSysKeyAlt))
            PostQuitMessage(0);
        return 0;
    case WM_KEYUP:
    case WM_SYSKEYUP:
        SetKeyState(s_system, (uint8_t)wParam, 0);
        // Handle Alt-F4 here. TODO: Support disabling it
        if(GetKeyState(kSysKeyF4) && GetKeyState(kSysKeyAlt))
            PostQuitMessage(0);
        return 0;
    case WM_SIZE:
        if(s_system->resizeCallback)
        {
            width = LOWORD(lParam);
            height = HIWORD(lParam);
            s_system->resizeCallback(width, height);
        }
        return 0;
    
    /* Mouse input */
    case WM_MOUSEMOVE:
        {
            POINTS pos = MAKEPOINTS(lParam);
            MouseMove(s_system, pos.x, pos.y);
        }
    case WM_LBUTTONDOWN:
    case WM_RBUTTONDOWN:
    case WM_MBUTTONDOWN:
    case WM_LBUTTONUP:
    case WM_RBUTTONUP:
    case WM_MBUTTONUP:
        SetMouseState(s_system, (int)wParam);
        return 0;
    }

    return DefWindowProc(hWnd, message, wParam, lParam);
}
コード例 #2
0
ファイル: input.cpp プロジェクト: mikearmstrong001/script
void ResetKeys()
{
	for (int i=0; i<KEY_MAX; i++)
	{
		SetKeyState( i, 0 );
	}
}
コード例 #3
0
void GLAnimationCanvas::OnKeyUp( wxKeyEvent& event )
{
    if (m_bRightDown)
    {
        int iKet = event.GetKeyCode();
        SetKeyState(iKet , false);
    }
}
コード例 #4
0
ファイル: input.cpp プロジェクト: dreamsxin/choria
// Handle events
bool _Input::OnEvent(const irr::SEvent &TEvent) {
	if(Game.GetManagerState() != _Game::STATE_UPDATE)
		return false;

	bool Processed = false;

	switch(TEvent.EventType) {
		case irr::EET_KEY_INPUT_EVENT:

			// Send key press events
			if(TEvent.KeyInput.PressedDown && !GetKeyState(TEvent.KeyInput.Key))
				Processed = Game.GetState()->HandleKeyPress(TEvent.KeyInput.Key);
			else if(!TEvent.KeyInput.PressedDown)
				Processed = Game.GetState()->HandleKeyRelease(TEvent.KeyInput.Key);

			// Set the current key state
			SetKeyState(TEvent.KeyInput.Key, TEvent.KeyInput.PressedDown);

			return Processed;
		break;
		case irr::EET_MOUSE_INPUT_EVENT:

			switch(TEvent.MouseInput.Event) {
				case irr::EMIE_LMOUSE_PRESSED_DOWN:
				case irr::EMIE_RMOUSE_PRESSED_DOWN:
				case irr::EMIE_MMOUSE_PRESSED_DOWN:
					SetMouseState(TEvent.MouseInput.Event, true);
					return Game.GetState()->HandleMousePress(TEvent.MouseInput.Event, TEvent.MouseInput.X, TEvent.MouseInput.Y);
				break;
				case irr::EMIE_LMOUSE_LEFT_UP:
				case irr::EMIE_RMOUSE_LEFT_UP:
				case irr::EMIE_MMOUSE_LEFT_UP:
					SetMouseState(TEvent.MouseInput.Event - MOUSE_COUNT, false);
					Game.GetState()->HandleMouseRelease(TEvent.MouseInput.Event - MOUSE_COUNT, TEvent.MouseInput.X, TEvent.MouseInput.Y);
				break;
				case irr::EMIE_MOUSE_MOVED:
					MousePosition.X = TEvent.MouseInput.X;
					MousePosition.Y = TEvent.MouseInput.Y;
					Game.GetState()->HandleMouseMotion(MousePosition.X, MousePosition.Y);
				break;
				case irr::EMIE_MOUSE_WHEEL:
					Game.GetState()->HandleMouseWheel(TEvent.MouseInput.Wheel);
				break;
				default:
				break;
			}

			return false;
		break;
		case irr::EET_GUI_EVENT:
			Game.GetState()->HandleGUI(TEvent.GUIEvent.EventType, TEvent.GUIEvent.Caller);
		break;
		default:
		break;
	}

	return false;
}