bool LWEnvelope::Init(LWChannelID Channel)
{
EnvChannel=Channel;
Envelope=Lightwave3D::chaninfo->channelEnvelope(Channel);
IsDeleted=false;
UpdateKeyTable();
return true;
}
Beispiel #2
0
bool Input::FilterMessage (HWND hwnd_, UINT uMsg_, WPARAM wParam_, LPARAM lParam_)
{
    static int nLastX, nLastY;
    static WPARAM wLastKey;

    switch (uMsg_)
    {
        case WM_MOUSEMOVE:
        {
            int nNewX = GET_X_LPARAM(lParam_), nNewY = GET_Y_LPARAM(lParam_);

            if (nNewX < 0) nNewX++;
            if (nNewY < 0) nNewY++;

            int nX = nNewX - nLastX, nY = nNewY - nLastY;
            nLastX = nNewX, nLastY = nNewY;

            // Has it moved at all?
            if (nX || nY)
            {
                nY = -nY;

                if (GetOption(fullscreen))
                {
                    // Landscape left, the WinCE inverted Y coords require is to invert X
                    if (1)
                        nX = -nX;

                    swap(nX, nY);
                }

                Mouse::Move(nX, nY);
            }
            break;
        }

        case WM_LBUTTONDOWN:
        case WM_LBUTTONDBLCLK:
        {
            nLastX = GET_X_LPARAM(lParam_);
            nLastY = GET_Y_LPARAM(lParam_);
            POINT pt = { nLastX, nLastY };

            if (uMsg_ == WM_LBUTTONDBLCLK)
            {
                RECT rect;
                if (GetOption(fullscreen))
                    SetRect(&rect, (g_gxdp.cxWidth-SCREEN_LINES)/2, (g_gxdp.cyHeight-SCREEN_PIXELS)/2, SCREEN_LINES, SCREEN_PIXELS);
                else
                    SetRect(&rect, 0, (g_gxdp.cyHeight-SIP_HEIGHT-SCREEN_LINES)/2, 240, SCREEN_LINES);

                // Offset the width+height to give a screen rectangle
                rect.right += rect.left-1;
                rect.bottom += rect.top-1;

                // If the mouse is enabled and the double-tap was on the main screen, treat it as a SAM mouse click
                // Otherwise toggle between portrait and landscape modes
                if (GetOption(mouse) && PtInRect(&rect, pt))
                    Mouse::SetButton(1);
                else
                    Action::Do(actToggleFullscreen);
            }

            SetCapture(hwnd_);
            break;
        }

        case WM_LBUTTONUP:
            // If we captured to catch the release, release it now
            if (GetCapture() == hwnd_)
                ReleaseCapture();

            Mouse::SetButton(1, false);
            break;

        case WM_CHAR:
        {
            int nSym = wParam_&0xff, nKey = wLastKey&0xff, nShifts = 0;
            if (GetKeyState(VK_SHIFT)    < 0) nShifts |= MOD_SHIFT;
            if (GetKeyState(VK_LCONTROL) < 0) nShifts |= MOD_LCTRL;
            if (GetKeyState(VK_LMENU)    < 0) nShifts |= MOD_LALT;
            if (GetKeyState(VK_RMENU)    < 0) nShifts |= MOD_RALT;

            // Ignore symbols on the keypad
            if (nKey >= VK_NUMPAD0 && nKey <= VK_DIVIDE)
                nSym = 0;

            if (nSym && !UpdateKeyTable(asSamKeys, nSym, nKey, nShifts))
            {
                // The table we update depends on the key mapping being used
                switch (GetOption(keymapping))
                {
                    case 1: UpdateKeyTable(asSamSymbols, nSym, nKey, nShifts);      break;
                    case 2: UpdateKeyTable(asSpectrumSymbols, nSym, nKey, nShifts); break;
                }
            }

            fSipDirty = true;
            break;
        }

        case WM_SYSKEYDOWN:
        case WM_KEYDOWN:
            // Eat key repeats
            if (lParam_ & 0x40000000)
                return true;

            // Fall through...
            wLastKey = wParam_;

        case WM_SYSKEYUP:
        case WM_KEYUP:
        {
            bool fPressed = !(uMsg_ & 1);
            WORD wKey = static_cast<WORD>(wParam_);

            // In fullscreen more we rotate the pad to match the screen orientation
            if (GetOption(fullscreen))
            {
                switch (wKey)
                {
                    case VK_LEFT:  wKey = VK_UP;	break;
                    case VK_RIGHT: wKey = VK_DOWN;	break;
                    case VK_UP:	   wKey = VK_RIGHT;	break;
                    case VK_DOWN:  wKey = VK_LEFT;	break;
                }
            }

            TRACE("%#02X %s\n", wKey, fPressed?"pressed":"released");
            afKeys[wKey & 0xff] = fPressed;

            switch (wKey)
            {
                case VK_SHIFT:
                    afKeys[VK_LSHIFT] = GetKeyState(VK_LSHIFT) < 0;
                    afKeys[VK_RSHIFT] = GetKeyState(VK_RSHIFT) < 0;
                    break;

                case VK_CONTROL:
                    afKeys[VK_LCONTROL] = GetKeyState(VK_LCONTROL) < 0;
                    afKeys[VK_RCONTROL] = GetKeyState(VK_RCONTROL) < 0;
                    break;

                case VK_MENU:
                    afKeys[VK_LMENU] = GetKeyState(VK_LMENU) < 0;
                    afKeys[VK_RMENU] = GetKeyState(VK_RMENU) < 0;
                    break;

                case VK_CAPITAL:
                case VK_LWIN:
                case VK_APPS:
                    afKeys[VK_SHIFT] = 0;
                    break;

                default:
                    break;
            }

            fSipDirty = true;
            break;
		}
    }

    // Message not processed
    return false;
}