예제 #1
0
void    FxPlayerTiny::OnMouse(GFxEvent::EventType eventType, UInt button, SInt x, SInt y)
{
    if (pMovie)
    {
        GFxMouseEvent mevent(eventType, button, (Float)x, (Float)y);
        pMovie->HandleEvent(mevent);
    }

	if (pHUD)
    {
        GFxMouseEvent mevent(eventType, button, (Float)x, (Float)y);
        pHUD->HandleEvent(mevent);
    }
}
예제 #2
0
// Helper function that converts Windows VK keyCode values
// to GFxKeyEvents and routes them to GFxPlayer.
void    FxPlayerTiny::HandleKeyEvent(UInt keyCode, bool downFlag)
{
	GFxKey::Code key(GFxKey::VoidSymbol);

	if (keyCode >= 'A' && keyCode <= 'Z')
	{
		key = (GFxKey::Code) ((keyCode - 'A') + GFxKey::A);
	}
	else if (keyCode >= VK_F1 && keyCode <= VK_F15)
	{
		key = (GFxKey::Code) ((keyCode - VK_F1) + GFxKey::F1);
	}
	else if (keyCode >= VK_NUMPAD0 && keyCode <= VK_NUMPAD9)
	{
		key = (GFxKey::Code) ((keyCode - VK_NUMPAD0) + GFxKey::KP_0);
	}
	else
	{
		// Use a look-up table for keys don't correlate in order,.
		struct {
			int          vk;
			GFxKey::Code gs;
		} table[] =
		{
			{ VK_RETURN,    GFxKey::Return },
			{ VK_ESCAPE,    GFxKey::Escape },
			{ VK_LEFT,      GFxKey::Left },
			{ VK_UP,        GFxKey::Up },
			{ VK_RIGHT,     GFxKey::Right },
			{ VK_DOWN,      GFxKey::Down },
			{ VK_SPACE,     GFxKey::Space },
			{ VK_BACK,      GFxKey::Backspace },
			{ VK_DELETE,	  GFxKey::Delete },
			{ VK_INSERT,    GFxKey::Insert },

			// TODO: fill this out some more
			{ 0, GFxKey::VoidSymbol }
		};

		for (int i = 0; table[i].vk != 0; i++)
		{
			if (keyCode == (UInt)table[i].vk)
			{
				key = table[i].gs;
				break;
			}
		}
	}

	if (key != GFxKey::VoidSymbol)
	{
		if (pMovie)
		{
			// Pass Key events to the movie so that can be handled in ActionScript.
			GFxKeyEvent event(downFlag ? GFxEvent::KeyDown : GFxKeyEvent::KeyUp, key);
			pMovie->HandleEvent(event);
		}
	}
}
예제 #3
0
// Window Message handler. Interprets windows messages and dispatches
// mouse/keyboard input to the OnMouse/OnKeyboard functions.
LRESULT FxPlayerTiny::MemberWndProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;

        case WM_SETCURSOR:
            if (LOWORD(lParam)==HTCLIENT)
            {
                ::SetCursor(::LoadCursor(0, IDC_ARROW));
                return 0;
            }
            break;
          
        // *** The following logic is used to route input to GFxPlayer.
        
        case WM_MOUSEMOVE:
            OnMouse(GFxEvent::MouseMove, 0, LOWORD(lParam), HIWORD(lParam));
            return 0;
        case WM_LBUTTONDOWN:
            ::SetCapture(hWnd);
            OnMouse(GFxEvent::MouseDown, 0, LOWORD(lParam), HIWORD(lParam));
            return 0;
        case WM_LBUTTONUP:
            ::ReleaseCapture();
            OnMouse(GFxEvent::MouseUp, 0, LOWORD(lParam), HIWORD(lParam));
            return 0;

        case WM_KEYDOWN:
            OnKey((UInt)wParam, 1);
            return 0;
        case WM_KEYUP:          
            OnKey((UInt)wParam, 0);
            return 0;
        case WM_CHAR:
            {
                UInt32 wcharCode = (UInt32)wParam;
                if (pMovie && wcharCode) 
                {
                    GFxCharEvent event(wcharCode);
                    pMovie->HandleEvent(event);
                }
            }
            break;
    }

    return DefWindowProc(hWnd, msg, wParam, lParam);
}