Exemplo n.º 1
0
	def whole(self, mapper, x, y, what):
		distance = sqrt(x*x + y*y)
		if distance < STICK_PAD_MAX_HALF:
			# Finger lifted or too close to middle
			self.angle = None
		else:
			# Compute current angle
			angle = atan2(x, y) + PI / 4
			# Compute movement
			if self.haptic:
				if self.angle is not None:
					diff = self.angle - angle
					# Ensure we don't wrap from pi to -pi creating a large delta
					if angle > PI:
						# Subtract a full rotation to counter the wrapping
						angle -= 2 * PI
					# And same from -pi to pi
					elif angle < -PI:
						# Add a full rotation to counter the wrapping
						angle += 2 * PI
					if abs(diff) < 6:# Prevents crazy feedback burst when finger cross 360' angle
						WholeHapticAction.change(self, mapper, diff * 10000, 0, what)
				self.angle = angle
			# Apply actual constant
			angle *= STICK_PAD_MAX / PI
			# Set axis on child action
			self.action.axis(mapper, angle * self.speed, 0)
			mapper.force_event.add(FE_PAD)
Exemplo n.º 2
0
 def whole(self, mapper, x, y, what):
     distance = sqrt(x * x + y * y)
     if distance < STICK_PAD_MAX_HALF:
         # Finger lifted or too close to middle
         self.angle = None
     else:
         # Compute current angle
         angle = atan2(x, y) + PI / 4
         # Compute movement
         if self.haptic:
             if self.angle is not None:
                 diff = self.angle - angle
                 # Ensure we don't wrap from pi to -pi creating a large delta
                 if angle > PI:
                     # Subtract a full rotation to counter the wrapping
                     angle -= 2 * PI
                 # And same from -pi to pi
                 elif angle < -PI:
                     # Add a full rotation to counter the wrapping
                     angle += 2 * PI
                 if abs(
                         diff
                 ) < 6:  # Prevents crazy feedback burst when finger cross 360' angle
                     WholeHapticAction.change(self, mapper, diff * 10000, 0)
             self.angle = angle
         # Apply actual constant
         angle *= STICK_PAD_MAX / PI
         # Set axis on child action
         self.action.axis(mapper, angle * self.speed, 0)
         mapper.force_event.add(FE_PAD)
Exemplo n.º 3
0
 def whole(self, mapper, x, y, what):
     distance = sqrt(x * x + y * y)
     if distance < STICK_PAD_MAX_HALF:
         # Finger lifted or too close to middle
         self.angle = None
         self.travelled = 0
     else:
         # Compute current angle
         angle = atan2(x, y)
         # Compute movement
         if self.angle is None:
             # Finger just touched the pad
             self.angle, angle = angle, 0
         else:
             self.angle, angle = angle, self.angle - angle
             # Ensure we don't wrap from pi to -pi creating a large delta
             if angle > PI:
                 # Subtract a full rotation to counter the wrapping
                 angle -= 2 * PI
             # And same from -pi to pi
             elif angle < -PI:
                 # Add a full rotation to counter the wrapping
                 angle += 2 * PI
             if self.haptic:
                 WholeHapticAction.change(self, mapper, angle * 10000, 0)
         # Apply bulgarian constant
         angle *= 10000.0
         # Apply movement to child action
         self.action.change(mapper, -angle * self.speed, 0)
         mapper.force_event.add(FE_PAD)