Beispiel #1
0
    def watch_params_in_gesture(self, gesture):
        if len(gesture.hands) > 0:  #FIX hands ?
            gesture_params = {}
            if gesture.type == 1:
                gesture = Leap.SwipeGesture(gesture)

                gesture.direction_name = self.get_direction_name(
                    gesture.direction)

                gesture.current_position_name = self.get_position_name(
                    gesture.hands[0].palm_position)
                gesture.start_position_name = self.get_position_name(
                    gesture.start_position)

                watched_params = GLOBALS['WATCHED_PARAMS_IN_SWIPE']
            if gesture.type == 4:
                gesture = Leap.CircleGesture(gesture)
                if gesture.pointable.direction.angle_to(
                        gesture.normal) <= Leap.PI / 2:
                    gesture.clockwiseness = "clockwise"
                else:
                    gesture.clockwiseness = "counterclockwise"

                gesture.position_name = self.get_position_name(gesture.center)

                watched_params = GLOBALS['WATCHED_PARAMS_IN_CIRCLE']
            if gesture.type == 5:
                gesture.activated = True
                watched_params = GLOBALS['WATCHED_PARAMS_IN_SCREEN_TAP']
            if gesture.type == 6:
                gesture.activated = True
                watched_params = GLOBALS['WATCHED_PARAMS_IN_KEY_TAP']

            for path, api in watched_params.items():
                try:
                    gesture_params[path] = eval('gesture.' + api)
                except:
                    print "%s\t%s not found. Valid api ?" % (path, api)

            if gesture.type == 1:
                self.actor.on_swipe(gesture_params)
            if gesture.type == 4:
                self.actor.on_circle(gesture_params)
            if gesture.type == 5:
                self.actor.on_screen_tap(gesture_params)
            if gesture.type == 6:
                self.actor.on_key_tap(gesture_params)
Beispiel #2
0
    def watch_params_in_gesture(self, gesture):
        if len(gesture.hands) > 0:  #FIX hands ?
            gesture_params = {}
            if gesture.type == 1:
                gesture = Leap.SwipeGesture(gesture)
                d = gesture.direction
                gesture.direction_name = 'not sure'
                if d.x > 0.7: gesture.direction_name = 'right'
                if d.x <= -0.7: gesture.direction_name = 'left'
                if d.y > 0.7: gesture.direction_name = 'top'
                if d.y <= -0.7: gesture.direction_name = 'bottom'
                if d.z > 0.7: gesture.direction_name = 'back'
                if d.z <= -0.7: gesture.direction_name = 'front'

                if circle.pointable.direction.angle_to(
                        circle.normal) <= Leap.PI / 2:
                    gesture.clockwiseness = "clockwise"
                else:
                    gesture.clockwiseness = "counterclockwise"

                watched_params = WATCHED_PARAMS_IN_SWIPE
            if gesture.type == 4:
                gesture = Leap.CircleGesture(gesture)
                watched_params = WATCHED_PARAMS_IN_CIRCLE
            if gesture.type == 5:
                gesture.activated = True
                watched_params = WATCHED_PARAMS_IN_SCREEN_TAP
            if gesture.type == 6:
                gesture.activated = True
                watched_params = WATCHED_PARAMS_IN_KEY_TAP

            for path, api in watched_params.items():
                try:
                    gesture_params[path] = eval('gesture.' + api)
                except:
                    print "%s\t%s not found. Valid api ?" % (path, api)
            self.sender.send_gesture(gesture_params)