Esempio n. 1
0
bool DonghaiConverter::handleInput(struct input_event *input) {
    switch (input->type) {
        case EV_MSC:
            return handleMscInput(input);
        case EV_KEY:
            return handleKeyInput(input);
        case EV_SYN:
            return handleSynInput(input);
        default:
            addOutput(input, false);
            break;
    }
    return true;
}
Esempio n. 2
0
    void Gui::Logic()
    {
        if (mTop == NULL)
        {
            throw GCN_EXCEPTION("No top widget set");
        }

        handleModalFocus();
        handleModalMouseInputFocus();

        if (mInput != NULL)
        {
            mInput->_pollInput();

            handleKeyInput();
            handleMouseInput();
 
        } // end if

        mTop->Logic();
    }
Esempio n. 3
0
    static pascal OSStatus WindowEventHandler (EventHandlerCallRef myHandler, EventRef event, void* userData)
    {
        WindowRef			window = NULL;
        OSStatus			result = eventNotHandledErr;
        UInt32 				msgClass = GetEventClass (event);
        UInt32 				kind = GetEventKind (event);
        OSXWindowData *oW = (OSXWindowData*)userData;
        
        WindowBase *wB = oW->WindowBaseOwner;
        window = wB->GetWindowHandle();
        ::Rect rectPort;
        
        switch (msgClass) {
            case kEventClassMouse:
                {
                    EventMouseButton button;
                    GetEventParameter (event, kEventParamMouseButton, typeMouseButton, 
                                       NULL, sizeof(EventMouseButton), NULL, &button);
                
                    HIPoint location;
                    GetEventParameter (event, kEventParamWindowMouseLocation, typeHIPoint, 
                                       NULL, sizeof(HIPoint), NULL, &location);

                    UInt32 clickCount;
                    GetEventParameter (event, kEventParamClickCount, typeUInt32, 
                                       NULL, sizeof(UInt32), NULL, &clickCount);

                    if(kind == kEventMouseDown || kind == kEventMouseUp)
                    {
                        MouseButton mB;
                        switch(button)
                        {
                            case kEventMouseButtonPrimary:
                                mB = MOUSE_LEFT;
                                break;
                            case kEventMouseButtonSecondary:
                                mB = MOUSE_MIDDLE;
                                break;
                            case kEventMouseButtonTertiary:
                                mB = MOUSE_RIGHT;
                                break;
                        }
                        wB->EventMouseButton((int)location.x,(int)location.y, mB, clickCount);
                    }
                    else
                        wB->EventMouseMove((int)location.x,(int)location.y);
                }
                break;
            case kEventClassKeyboard:
                switch (kind) {
                    case kEventRawKeyDown:
                        result = handleKeyInput  (myHandler, event, true, oW);
                        break;
                    case kEventRawKeyUp:
                        result = handleKeyInput  (myHandler, event, false, oW);
                        break;
                }
                break;
            case kEventClassWindow:
                GetEventParameter(event, kEventParamDirectObject, typeWindowRef, 
                                  NULL, sizeof(WindowRef), NULL, &window);
                switch (kind) {
                    case kEventWindowDeactivated:
                        wB->EventFocus(false);
                        break;
                    case kEventWindowActivated:
                        wB->EventFocus(true);
                        break;
                    case kEventWindowDrawContent:
                        wB->EventDraw();
                        break;
                    case kEventWindowBoundsChanged:
                    {
                        Rect rect = wB->GetWindowRect();
                        wB->EventSize(rect.width, rect.height);
                        break;                        
                    }
                    case kEventWindowClose:
                        wB->EventClose();
                        wB->DisableEvent();
                        break;
                    // WARNING: This is not called if windows is unminimized!
                    case kEventWindowShown:
                        SetUserFocusWindow (window);
                        GetWindowPortBounds (window, &rectPort);
                        InvalWindowRect (window, &rectPort);
                        wB->EventMain();
                        break;
                }
                break;
        }
        return result;
    }