Пример #1
0
    public iPhoneTouch touchWithEvent(BBTouchEvent anEvent)
    {
        iPhoneTouch newTouch = new iPhoneTouch();

        newTouch.fingerId        = (int)anEvent.eventID;
        newTouch.position.x      = anEvent.screenPosition.x;
        newTouch.position.y      = anEvent.screenPosition.y;
        newTouch.deltaPosition.x = anEvent.screenPosition.x - anEvent.lastScreenPosition.x;
        newTouch.deltaPosition.y = anEvent.screenPosition.y - anEvent.lastScreenPosition.y;
        newTouch.deltaTime       = anEvent.touchTime - anEvent.lastTouchTime;
        newTouch.tapCount        = 1;  // no tap recog yet
        if (anEvent.eventState == BBTouchEventState.Began)
        {
            newTouch.phase = iPhoneTouchPhase.Began;
        }
        if (anEvent.eventState == BBTouchEventState.Moved)
        {
            newTouch.phase = iPhoneTouchPhase.Moved;
        }
        if (anEvent.eventState == BBTouchEventState.Stationary)
        {
            newTouch.phase = iPhoneTouchPhase.Stationary;
        }
        if (anEvent.eventState == BBTouchEventState.Ended)
        {
            newTouch.phase = iPhoneTouchPhase.Ended;
        }
        return(newTouch);
    }
Пример #2
0
    // Cursor down is for new touch events. we take the TUIO cursor object and convert it
    // into a touch event, and add it to our active list of events
    public virtual void cursorDown(TuioCursor cursor)
    {
        // first, make a new BBTouchEvent, tag it with the unique touch id
        BBTouchEvent newEvent = new BBTouchEvent(cursor.getSessionID());

        // set the initial information
        newEvent.screenPosition = new Vector3(cursor.getX() * cameraPixelWidth, (1.0f - cursor.getY()) * cameraPixelHeight, 0.3f);
        newEvent.eventState     = BBTouchEventState.Began;
        newEvent.didChange      = true;
        // set all the rest of the info
        updateEvent(newEvent, cursor);

        // add it to our active event dictionary so we can retireve it based on it's unique ID
        // some times badness happens and we get an error adding one here for some reason
        // it should not ever be the case that the ID is already there.
        // if it is, then we need to behave
        if (activeEvents.ContainsKey(cursor.getSessionID()))
        {
            // then something is not right.. remove the old one and add a new one
            activeEvents.Remove(cursor.getSessionID());
        }
        activeEvents.Add(cursor.getSessionID(), newEvent);
        // queue it up for processing
        lock (eventQueueLock) eventQueue.Add(newEvent);
    }
Пример #3
0
 private void updateEvent(BBTouchEvent anEvent, TuioCursor cursor)
 {
     anEvent.lastScreenPosition = anEvent.screenPosition;
     anEvent.tuioPosition       = new Vector2(cursor.getX(), (1.0f - cursor.getY()));
     anEvent.screenPosition     = new Vector3(cursor.getX() * cameraPixelWidth, (1.0f - cursor.getY()) * cameraPixelHeight, 0.3f);
     anEvent.lastTouchTime      = anEvent.touchTime;
     anEvent.touchTime          = Time.time;
 }
Пример #4
0
    public virtual void cursorUp(TuioCursor cursor)
    {
        // find the matching event object, set the state to 'ended'
        // and remove it from our actives
        if (!activeEvents.ContainsKey(cursor.getSessionID()))
        {
            return;
        }
        BBTouchEvent anEvent = activeEvents[cursor.getSessionID()];

        anEvent.eventState = BBTouchEventState.Ended;
        lock (eventQueueLock) eventQueue.Add(anEvent);
        activeEvents.Remove(cursor.getSessionID());
    }
Пример #5
0
    public virtual void cursorMove(TuioCursor cursor)
    {
        // find the matching event object, set th state to 'moved'
        // and update it with the new position info
        if (!activeEvents.ContainsKey(cursor.getSessionID()))
        {
            return;
        }
        BBTouchEvent anEvent = activeEvents[cursor.getSessionID()];

        updateEvent(anEvent, cursor);
        anEvent.eventState = BBTouchEventState.Moved;
        lock (eventQueueLock) eventQueue.Add(anEvent);
    }
Пример #6
0
 public iPhoneTouch touchWithEvent(BBTouchEvent anEvent)
 {
     iPhoneTouch newTouch = new iPhoneTouch();
     newTouch.fingerId = (int)anEvent.eventID;
     newTouch.position.x = anEvent.screenPosition.x;
     newTouch.position.y = anEvent.screenPosition.y;
     newTouch.deltaPosition.x = anEvent.screenPosition.x - anEvent.lastScreenPosition.x;
     newTouch.deltaPosition.y = anEvent.screenPosition.y - anEvent.lastScreenPosition.y;
     newTouch.deltaTime = anEvent.touchTime - anEvent.lastTouchTime;
     newTouch.tapCount = 1; // no tap recog yet
     if (anEvent.eventState == BBTouchEventState.Began) newTouch.phase = iPhoneTouchPhase.Began;
     if (anEvent.eventState == BBTouchEventState.Moved) newTouch.phase = iPhoneTouchPhase.Moved;
     if (anEvent.eventState == BBTouchEventState.Stationary) newTouch.phase = iPhoneTouchPhase.Stationary;
     if (anEvent.eventState == BBTouchEventState.Ended) newTouch.phase = iPhoneTouchPhase.Ended;
     return newTouch;
 }
Пример #7
0
    // Cursor down is for new touch events. we take the TUIO cursor object and convert it
    // into a touch event, and add it to our active list of events
    public virtual void cursorDown(TuioCursor cursor)
    {
        // first, make a new BBTouchEvent, tag it with the unique touch id
        BBTouchEvent newEvent = new BBTouchEvent(cursor.getSessionID());
        // set the initial information
        newEvent.screenPosition = new Vector3(cursor.getX() * cameraPixelWidth,(1.0f - cursor.getY()) * cameraPixelHeight,0.3f);
        newEvent.eventState = BBTouchEventState.Began;
        // set all the rest of the info
        updateEvent(newEvent,cursor);

        // add it to our active event dictionary so we can retireve it based on it's unique ID
        // some times badness happens and we get an error adding one here for some reason
        // it should not ever be the case that the ID is already there.
        // if it is, then we need to behave
        if (activeEvents.ContainsKey(cursor.getSessionID())) {
            // then something is not right.. remove the old one and add a new one
            activeEvents.Remove(cursor.getSessionID());
        }
        activeEvents.Add( cursor.getSessionID(), newEvent );
        // queue it up for processing
        lock (eventQueueLock) eventQueue.Add(newEvent);
    }
 private void updateEvent(BBTouchEvent anEvent, TuioCursor cursor)
 {
     anEvent.lastScreenPosition = anEvent.screenPosition;
     anEvent.tuioPosition = new Vector2(cursor.getX(),(1.0f - cursor.getY()));
     anEvent.screenPosition = new Vector3(cursor.getX() * cameraPixelWidth,(1.0f - cursor.getY()) * cameraPixelHeight,0.3f);
     anEvent.lastTouchTime = anEvent.touchTime;
     anEvent.touchTime = Time.time;
     anEvent.didChange = true;
 }