How to use scc - 10 common examples

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 / tests / test_profile / test_special_actions.py View on Github external
def test_menus(self):
		"""
		Tests if all Menu*Actions are parsed correctly from json.
		"""
		for cls in MENU_CLASSES:
			a_str = "%s('some.menu', LEFT, X, Y, True)" % (cls.COMMAND,)
			a = parser.from_json_data({ 'action' : a_str })
			assert isinstance(a, cls)
			assert a.control_with == HapticPos.LEFT
			assert a.confirm_with == SCButtons.X
			assert a.cancel_with == SCButtons.Y
			assert a.show_with_release == True
github kozec / sc-controller / tests / test_parser / test_macros.py View on Github external
def test_macro(self):
		"""
		Tests if Macro can be converted to string and parsed back to
		same action.
		"""
		assert _parses_as_itself(Macro(
			ButtonAction(Keys.BTN_LEFT),
			ButtonAction(Keys.BTN_RIGHT),
			ButtonAction(Keys.BTN_MIDDLE)
		))
github kozec / sc-controller / tests / test_parser / test_actions.py View on Github external
def test_dpad(self):
		"""
		Tests if DPadAction can be converted to string and
		parsed back to same action.
		"""
		# Default diagonal rage
		assert _parses_as_itself(DPadAction(
			ButtonAction(Keys.BTN_LEFT),
			ButtonAction(Keys.BTN_RIGHT),
			ButtonAction(Keys.BTN_MIDDLE),
			ButtonAction(Keys.KEY_A)
		))
		# Modified diagonal rage
		assert _parses_as_itself(DPadAction(33,
			ButtonAction(Keys.BTN_RIGHT),
			ButtonAction(Keys.KEY_A),
			ButtonAction(Keys.BTN_LEFT),
			ButtonAction(Keys.BTN_MIDDLE),
		))
github kozec / sc-controller / tests / test_parser / test_modifiers.py View on Github external
def test_feedback(self):
		"""
		Tests if FeedbackModifier can be converted to string and parsed
		back to same.
		"""
		# TODO: Here, with actual tests
		assert _parses_as_itself(FeedbackModifier(HapticPos.BOTH, MouseAction()))
		assert _parses_as_itself(FeedbackModifier(HapticPos.BOTH, 10, MouseAction()))
		assert _parses_as_itself(FeedbackModifier(HapticPos.BOTH, 10, 8, MouseAction()))
		assert _parses_as_itself(FeedbackModifier(HapticPos.BOTH, 10, 8, 512, MouseAction()))
		# Bellow was failing in past
		assert _parses_as_itself(FeedbackModifier(HapticPos.LEFT, MouseAction()))
		assert _parses_as_itself(FeedbackModifier(HapticPos.RIGHT, MouseAction()))
github kozec / sc-controller / tests / test_parser / test_actions.py View on Github external
def test_mouse(self):
		"""
		Tests if MouseAction can be converted to string and parsed back to
		same action.
		"""
		# With axis specified
		assert _parses_as_itself(MouseAction(Rels.REL_WHEEL))
		# Without axis (when used as trackbal)
		assert _parses_as_itself(MouseAction())
github kozec / sc-controller / scc / gui / ae / menu_action.py View on Github external
model.append((None, None))	# Separator
				i += 1
		if self.allow_globals:
			for f in menus:
				key = f.get_basename()
				name = key
				if name.startswith("."): continue
				if "." in name:
					name = _("%s (global)" % (name.split(".")[0]))
				model.append((name, key))
				if self._current_menu == key:
					current_index = i
				i += 1
		if i > 0:
			model.append((None, None))	# Separator
		model.append(( _("New Menu..."), "" ))
		
		self._recursing = True
		cb.set_active(current_index)
		self._recursing = False
		name = self.get_selected_menu()
		if name:
			self.builder.get_object("btEditMenu").set_sensitive(name not in MenuEditor.OPEN)
github kozec / sc-controller / scc / gui / ae / trigger.py View on Github external
def set_action(self, mode, action):
		self.half, self.full, self.analog = NoAction(), NoAction(), NoAction()
		sucess, half, full, analog = TriggerComponent._split(action)
		if sucess:
			self._recursing = True
			self.half, self.full, self.analog = (TriggerComponent._strip_trigger(x) for x in (half, full, analog))
			if half:
				self.builder.get_object("sclPartialLevel").set_value(half.press_level)
				self.builder.get_object("cbReleasePartially").set_active(half.release_level < TRIGGER_MAX)
			if full:
				self.builder.get_object("sclFullLevel").set_value(full.press_level)
			if isinstance(analog, TriggerAction):
				self.builder.get_object("sclARangeStart").set_value(analog.press_level)
				self.builder.get_object("sclARangeEnd").set_value(analog.release_level)
			
			self._recursing = False
		self.update()
github kozec / sc-controller / python / scc / gui / ae / __init__.py View on Github external
def describe_action(mode, cls, v):
	"""
	Returns action description with 'v' as parameter, unless unless v is None.
	Returns "not set" if v is None
	"""
	if v is None:
		return _('(not set)')
	elif isinstance(v, Action):
		dsc = v.describe(Action.AC_STICK if cls == XYAction else Action.AC_BUTTON)
		if "\n" in dsc:
			dsc = "<small>" + "\n".join(dsc.split("\n")[0:2]) + "</small>"
		return dsc
	else:
		return (cls(v)).describe(mode)
github kozec / sc-controller / scc / modifiers.py View on Github external
def __init__(self, *params):
		Action.__init__(self, *params)
		params = list(params)
		for p in params:
			if isinstance(p, Action):
				self.action = p
				params.remove(p)
				break
		else:
			self.action = NoAction()
		self._mod_init(*params)
github kozec / sc-controller / scc / gui / controller_image.py View on Github external
def _fill_button_images(self, buttons):
		e = self.edit()
		SVGEditor.update_parents(e)
		target = SVGEditor.get_element(e, "controller")
		target_x, target_y = SVGEditor.get_translation(target)
		for i in xrange(len(ControllerImage.BUTTONS_WITH_IMAGES)):
			b = nameof(ControllerImage.BUTTONS_WITH_IMAGES[i])
			try:
				elm = SVGEditor.get_element(e, "AREA_%s" % (b,))
				if elm is None:
					log.warning("Area for button %s not found", b)
					continue
				x, y = SVGEditor.get_translation(elm)
				scale = 1.0
				if "scc-button-scale" in elm.attrib:
					w, h = SVGEditor.get_size(elm)
					scale = float(elm.attrib['scc-button-scale'])
					tw, th = w * scale, h * scale
					if scale &lt; 1.0:
						x += (w - tw) * 0.5
						y += (h - th) * 0.5
					else:
						x -= (tw - w) * 0.25