Пример #1
0
void
EventManager::clear()
{
    ILOG_TRACE_F(ILX_EVENTMANAGER);
    if (_focusedWidget)
    {
        _focusedWidget->_state = (WidgetState) (_focusedWidget->_state & ~FocusedState);
        _focusedWidget->focusOutEvent();
        _focusedWidget->sigStateChanged(_focusedWidget, _focusedWidget->_state);
        _focusedWidget = NULL;
    }

    if (_exposedWidget)
    {
        _exposedWidget->_state = (WidgetState) (_exposedWidget->_state & ~ExposedState);
        _exposedWidget->_state = (WidgetState) (_exposedWidget->_state & ~PressedState);
        _exposedWidget->leaveEvent(PointerEvent());
        _exposedWidget->sigStateChanged(_exposedWidget, _exposedWidget->_state);
        _exposedWidget = NULL;
    }

    if (_grabbedWidget)
    {
        _grabbedWidget->pointerReleaseEvent(PointerEvent());
        _grabbedWidget = NULL;
    }

}
Пример #2
0
int HandleWsEvent(_THIS, const TWsEvent& aWsEvent)
{
    switch (aWsEvent.Type())
		{    
		case EEventSwitchOff:
			SDL_PrivateQuit();
			return 0;
    	case EEventPointerBufferReady:
    	    return PointerBufferReadyEvent(_this/*, aWsEvent.Time()*/);
        case EEventPointer: /* Mouse pointer events */
            return PointerEvent(_this, aWsEvent);
        case EEventKeyDown: /* Key events */
            return KeyDownEvent(_this, aWsEvent);
        case EEventKeyUp: /* Key events */
            return KeyUpEvent(_this, aWsEvent);
        case EEventFocusGained: /* SDL window got focus */
            return FocusGainedEvent(_this);	   
        case EEventFocusLost: /* SDL window lost focus */
        	return FocusLostEvent(_this);
        case EEventModifiersChanged: 
            return ModifiersChangedEvent(aWsEvent);         
    	case EEventScreenDeviceChanged:
    	    return ScreenDeviceChanged();
    	case ESDLWsEvent:
    	    return InternalEvent(aWsEvent);
        default:            
            return 0;
		} 
    }
Пример #3
0
PointerEvent ParabolaPointer::buildPointerEvent(const PickedObject& target, const PickResultPointer& pickResult, const std::string& button, bool hover) {
    QUuid pickedID;
    glm::vec3 intersection, surfaceNormal, origin, velocity, acceleration;
    auto parabolaPickResult = std::static_pointer_cast<ParabolaPickResult>(pickResult);
    if (parabolaPickResult) {
        intersection = parabolaPickResult->intersection;
        surfaceNormal = parabolaPickResult->surfaceNormal;
        const QVariantMap& parabola = parabolaPickResult->pickVariant;
        origin = vec3FromVariant(parabola["origin"]);
        velocity = vec3FromVariant(parabola["velocity"]);
        acceleration = vec3FromVariant(parabola["acceleration"]);
        pickedID = parabolaPickResult->objectID;
    }

    if (pickedID != target.objectID) {
        intersection = findIntersection(target, origin, velocity, acceleration);
    }
    glm::vec2 pos2D = findPos2D(target, intersection);

    // If we just started triggering and we haven't moved too much, don't update intersection and pos2D
    TriggerState& state = hover ? _latestState : _states[button];
    float sensorToWorldScale = DependencyManager::get<AvatarManager>()->getMyAvatar()->getSensorToWorldScale();
    float deadspotSquared = TOUCH_PRESS_TO_MOVE_DEADSPOT_SQUARED * sensorToWorldScale * sensorToWorldScale;
    bool withinDeadspot = usecTimestampNow() - state.triggerStartTime < POINTER_MOVE_DELAY && glm::distance2(pos2D, state.triggerPos2D) < deadspotSquared;
    if ((state.triggering || state.wasTriggering) && !state.deadspotExpired && withinDeadspot) {
        pos2D = state.triggerPos2D;
        intersection = state.intersection;
        surfaceNormal = state.surfaceNormal;
    }
    if (!withinDeadspot) {
        state.deadspotExpired = true;
    }

    return PointerEvent(pos2D, intersection, surfaceNormal, velocity);
}