How to use the scc.actions.ButtonAction function in scc

To help you get started, we’ve selected a few scc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kozec / sc-controller / scc / gui / ae / axis.py View on Github external
def handles(self, mode, action):
		if isinstance(action, MultiAction) and len(action.actions) == 2:
			# Handles combination of axis + button on fully pressed trigger
			if not isinstance(action.actions[0], ButtonAction):
				return False
			action = action.actions[1]
		return isinstance(action, (AxisAction, MouseAction))
github kozec / sc-controller / scc / gui / ae / dpad.py View on Github external
def update(self):
		cb = self.builder.get_object("cbActionType")
		scl = self.builder.get_object("sclDiagonalRange")
		key = cb.get_model().get_value(cb.get_active_iter(), 1)
		if key == "dpad8":
			# 8-way dpad
			self.editor.set_action(DPad8Action(scl.get_value(), *self.actions))
		elif key == "dpad":
			# 4-way dpad
			self.editor.set_action(DPadAction(scl.get_value(),
				*self.actions[0:4]))
		elif key == "wsad":
			# special case of 4-way dpad
			a = DPadAction(scl.get_value(),
				ButtonAction(Keys.KEY_W), ButtonAction(Keys.KEY_S),
				ButtonAction(Keys.KEY_A), ButtonAction(Keys.KEY_D))
			self.actions = [ NoAction() ] * 8
			self.editor.set_action(a)
			self.update_button_desc(a)
		elif key == "arrows":
			# special case of 4-way dpad
			a = DPadAction(scl.get_value(),
				ButtonAction(Keys.KEY_UP), ButtonAction(Keys.KEY_DOWN),
				ButtonAction(Keys.KEY_LEFT), ButtonAction(Keys.KEY_RIGHT))
			self.actions = [ NoAction() ] * 8
			self.editor.set_action(a)
			self.update_button_desc(a)
		elif key == "actual_dpad":
			# maps to dpad as real gamepad usually has
			a = DPadAction(scl.get_value(),
				HatUpAction(Axes.ABS_HAT0Y), HatDownAction(Axes.ABS_HAT0Y),
github kozec / sc-controller / scc / gui / ae / dpad.py View on Github external
def update(self):
		cb = self.builder.get_object("cbActionType")
		scl = self.builder.get_object("sclDiagonalRange")
		key = cb.get_model().get_value(cb.get_active_iter(), 1)
		if key == "dpad8":
			# 8-way dpad
			self.editor.set_action(DPad8Action(scl.get_value(), *self.actions))
		elif key == "dpad":
			# 4-way dpad
			self.editor.set_action(DPadAction(scl.get_value(),
				*self.actions[0:4]))
		elif key == "wsad":
			# special case of 4-way dpad
			a = DPadAction(scl.get_value(),
				ButtonAction(Keys.KEY_W), ButtonAction(Keys.KEY_S),
				ButtonAction(Keys.KEY_A), ButtonAction(Keys.KEY_D))
			self.actions = [ NoAction() ] * 8
			self.editor.set_action(a)
			self.update_button_desc(a)
		elif key == "arrows":
			# special case of 4-way dpad
			a = DPadAction(scl.get_value(),
				ButtonAction(Keys.KEY_UP), ButtonAction(Keys.KEY_DOWN),
				ButtonAction(Keys.KEY_LEFT), ButtonAction(Keys.KEY_RIGHT))
			self.actions = [ NoAction() ] * 8
			self.editor.set_action(a)
			self.update_button_desc(a)
		elif key == "actual_dpad":
			# maps to dpad as real gamepad usually has
			a = DPadAction(scl.get_value(),
				HatUpAction(Axes.ABS_HAT0Y), HatDownAction(Axes.ABS_HAT0Y),
				HatLeftAction(Axes.ABS_HAT0X), HatRightAction(Axes.ABS_HAT0X))
github kozec / sc-controller / python / scc / gui / ae / dpad.py View on Github external
# 4-way dpad
			self.editor.set_action(DPadAction(scl.get_value(),
				*self.actions[0:4]))
		elif key == "wsad":
			# special case of 4-way dpad
			a = DPadAction(scl.get_value(),
				ButtonAction(Keys.KEY_W), ButtonAction(Keys.KEY_S),
				ButtonAction(Keys.KEY_A), ButtonAction(Keys.KEY_D))
			self.actions = [ NoAction() ] * 8
			self.editor.set_action(a)
			self.update_button_desc(a)
		elif key == "arrows":
			# special case of 4-way dpad
			a = DPadAction(scl.get_value(),
				ButtonAction(Keys.KEY_UP), ButtonAction(Keys.KEY_DOWN),
				ButtonAction(Keys.KEY_LEFT), ButtonAction(Keys.KEY_RIGHT))
			self.actions = [ NoAction() ] * 8
			self.editor.set_action(a)
			self.update_button_desc(a)
		elif key == "actual_dpad":
			# maps to dpad as real gamepad usually has
			a = DPadAction(scl.get_value(),
				HatUpAction(Axes.ABS_HAT0Y), HatDownAction(Axes.ABS_HAT0Y),
				HatLeftAction(Axes.ABS_HAT0X), HatRightAction(Axes.ABS_HAT0X))
			self.actions = [ NoAction() ] * 8
			self.editor.set_action(a)
			self.update_button_desc(a)
		else:
			# Menu
			self.on_cbMenus_changed()
github kozec / sc-controller / python / scc / gui / ae / axis_action.py View on Github external
def make_circular_action(self):
		"""
		Constructs Circular Modifier
		"""
		if self.circular_axis and any(self.circular_buttons):
			return CircularModifier(MultiAction(
				self.circular_axis, ButtonAction(*self.circular_buttons)))
		elif any(self.circular_buttons):
			return CircularModifier(ButtonAction(*self.circular_buttons))
		else:
			return CircularModifier(self.circular_axis)
github kozec / sc-controller / scc / macros.py View on Github external
Action.__init__(self, *parameters)
		self.actions = []
		self.repeat = False
		self.hold_time = Macro.HOLD_TIME
		self._active = False
		self._current = None
		self._release = None
		for p in parameters:
			if type(p) == float and len(self.actions):
				self.actions[-1].delay_after = p
			elif isinstance(p, Macro):
				self.actions += p.actions
			elif isinstance(p, Action):
				self.actions.append(p)
			else:
				self.actions.append(ButtonAction(p))
github kozec / sc-controller / scc / profile.py View on Github external
numbers.append(int(param))
					if len(numbers) == 0:
						# Trigger range was not specified, assume defaults
						numbers = ( TRIGGER_HALF, TRIGGER_CLICK )
					elif len(numbers) == 1:
						# Only lower range was specified, add default upper range
						numbers.append(TRIGGER_CLICK)
					if len(buttons) == 1:
						# If only one button was set, trigger should work like
						# one big button
						n = TriggerAction(numbers[0], ButtonAction(buttons[0]))
					elif len(buttons) == 2:
						# Both buttons were set
						n = MultiAction(
							TriggerAction(numbers[0], numbers[1], ButtonAction(buttons[0])),
							TriggerAction(numbers[1], TRIGGER_MAX, ButtonAction(buttons[1]))
						)
					
					if n:
						log.info("Converted %s to %s",
							self.triggers[p].to_string(), n.to_string())
						self.triggers[p] = n
		if from_version < 1.3:
			# Action format completly changed in v0.4, but profile foramat is same.
			pass
github kozec / sc-controller / scc / gui / ae / axis_action.py View on Github external
actions = action.action.actions
		else:
			actions = [ action.action ]
		
		# Parse that list
		self.circular_axis, self.circular_buttons = NoAction(), [ None, None ]
		for action in actions:
			if isinstance(action, ButtonAction):
				self.circular_buttons = [ action.button, action.button2 ]
			else:
				self.circular_axis = action
		
		# Set labels
		b0, b1 = self.circular_buttons
		btCircularButton0.set_label(ButtonAction.describe_button(b0))
		btCircularButton1.set_label(ButtonAction.describe_button(b1))
		btCircularAxis.set_label(self.circular_axis.describe(Action.AC_PAD))
		
		self.set_cb(cbAxisOutput, "circular", 2)