How to use the scc.actions.Action 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 / 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 / actions.py View on Github external
def get_compatible_modifiers(self):
		return (Action.MOD_CLICK | Action.MOD_ROTATE
			| Action.MOD_DEADZONE | Action.MOD_FEEDBACK )
github kozec / sc-controller / scc / modifiers.py View on Github external
def get_compatible_modifiers(self):
		return ( Action.MOD_FEEDBACK | Action.MOD_SENSITIVITY | Action.MOD_ROTATE
			| Modifier.get_compatible_modifiers(self) )
github kozec / sc-controller / scc / gui / ae / axis_action.py View on Github external
from scc.osd.area import Area
from scc.gui.parser import GuiActionParser, InvalidAction
from scc.gui.simple_chooser import SimpleChooser
from scc.gui.controller_widget import STICKS
from scc.gui.ae import AEComponent

import os, logging, math
log = logging.getLogger("AE.AxisAction")

__all__ = [ 'AxisActionComponent' ]


class AxisActionComponent(AEComponent, TimerManager):
	GLADE = "ae/axis_action.glade"
	NAME = "axis_action"
	CTXS = Action.AC_STICK | Action.AC_PAD
	PRIORITY = 3
	
	def __init__(self, app, editor):
		AEComponent.__init__(self, app, editor)
		TimerManager.__init__(self)
		self._recursing = False
		self.relative_area = False
		self.osd_area_instance = None
		self.on_wayland = False
		self.circular_axis = MouseAction(Rels.REL_WHEEL)
		self.circular_buttons = [ None, None ]
		self.button = None
		self.parser = GuiActionParser()
	
	
	def load(self):
github kozec / sc-controller / python / scc / gui / action_editor.py View on Github external
# Strip defaults from feedback values
				feedback = [] + self.feedback
				while len(feedback) > 0 and feedback[-1] == self.feedback_widgets[len(feedback)-1][-1]:
					feedback = feedback[0:-1]
				
				cbFeedbackSide = self.builder.get_object("cbFeedbackSide")
				cbFeedback = self.builder.get_object("cbFeedback")
				grFeedback = self.builder.get_object("grFeedback")
				if from_custom or (cbFeedback.get_active() and grFeedback.get_sensitive()):
					# Build FeedbackModifier arguments
					feedback = [ FEEDBACK_SIDES[cbFeedbackSide.get_active()] ] + feedback
					feedback += [ action ]
					# Create modifier
					action = FeedbackModifier(*feedback)
		
		if (cm & Action.AF_MOD_SMOOTH) != 0:
			if self.smoothing != None:
				action = SmoothModifier(*( list(self.smoothing) + [ action ]))
		
		if (cm & Action.AF_MOD_DEADZONE) != 0:
			if self.deadzone_mode is not None:
				action = DeadzoneModifier(self.deadzone_mode, self.deadzone[0], self.deadzone[1], action)
		
		if (cm & Action.AF_MOD_ROTATE) != 0:
			if self.rotation_angle != 0.0:
				action = RotateInputModifier(self.rotation_angle, action)
		
		if (cm & Action.AF_MOD_OSD) != 0:
			if self.osd:
				action = OSDAction(action)
		
		if (cm & Action.AF_MOD_CLICK) != 0:
github kozec / sc-controller / scc / gui / ae / custom.py View on Github external
from gi.repository import Gtk, Gdk, GLib
from scc.gui.parser import GuiActionParser, InvalidAction
from scc.gui.ae import AEComponent
from scc.actions import Action

import os, logging
log = logging.getLogger("AE.Custom")

__all__ = [ 'CustomActionComponent' ]

class CustomActionComponent(AEComponent):
	GLADE = "ae/custom.glade"
	NAME = "custom"
	PRIORITY = -1
	CTXS = Action.AC_ALL
	
	def __init__(self, app, editor):
		AEComponent.__init__(self, app, editor)
		self.parser = GuiActionParser()
	
	
	def handles(self, mode, action):
		# Custom Action Editor handles all actions
		return isinstance(action, Action)
	
	
	def get_button_title(self):
		return _("Custom Action")
	
	
	def load(self):
github kozec / sc-controller / scc / special_actions.py View on Github external
return self.action.trigger(mapper, position, old_position)
	
	def axis(self, mapper, position, what):
		if self.action:
			return self.action.axis(mapper, position, what)
	
	def pad(self, mapper, position, what):
		if self.action:
			return self.action.pad(mapper, position, what)
	
	def whole(self, mapper, x, y, what):
		if self.action:
			return self.action.whole(mapper, x, y, what)


class ClearOSDAction(Action, SpecialAction):
	"""
	Clears all windows from OSD layer. Cancels all menus, clears all messages,
	etc, etc.
	"""
	SA = COMMAND = "clearosd"
	
	def describe(self, context):
		return _("Hide all OSD Menus and Messages")
	
	
	def button_press(self, mapper):
		self.execute(mapper)


class MenuAction(Action, SpecialAction, HapticEnabledAction):
	"""
github kozec / sc-controller / generate_svg.py View on Github external
box_left = Box(self.PADDING, self.PADDING, Align.LEFT | Align.TOP, "left",
			min_height = self.full_height * 0.5,
			min_width = self.full_width * 0.2)
		box_left.add("LEFT", Action.AC_TRIGGER, profile.triggers.get(profile.LEFT))
		box_left.add("LB", Action.AC_BUTTON, profile.buttons.get(SCButtons.LB))
		box_left.add("LGRIP", Action.AC_BUTTON, profile.buttons.get(SCButtons.LGRIP))
		box_left.add("LPAD", Action.AC_PAD, profile.pads.get(profile.LEFT))
		boxes.append(box_left)
		
		
		box_right = Box(self.PADDING, self.PADDING, Align.RIGHT | Align.TOP, "right",
			min_height = self.full_height * 0.5,
			min_width = self.full_width * 0.2)
		box_right.add("RIGHT", Action.AC_TRIGGER, profile.triggers.get(profile.RIGHT))
		box_right.add("RB", Action.AC_BUTTON, profile.buttons.get(SCButtons.RB))
		box_right.add("RGRIP", Action.AC_BUTTON, profile.buttons.get(SCButtons.RGRIP))
		box_right.add("RPAD", Action.AC_PAD, profile.pads.get(profile.RIGHT))
		boxes.append(box_right)
		
		
		box_abxy = Box(4 * self.PADDING, self.PADDING, Align.RIGHT | Align.BOTTOM, "abxy")
		box_abxy.add("A", Action.AC_BUTTON, profile.buttons.get(SCButtons.A))
		box_abxy.add("B", Action.AC_BUTTON, profile.buttons.get(SCButtons.B))
		box_abxy.add("X", Action.AC_BUTTON, profile.buttons.get(SCButtons.X))
		box_abxy.add("Y", Action.AC_BUTTON, profile.buttons.get(SCButtons.Y))
		boxes.append(box_abxy)
		
		
		box_stick = Box(4 * self.PADDING, self.PADDING, Align.LEFT | Align.BOTTOM, "stick")
		box_stick.add("STICK", Action.AC_STICK, profile.stick)
github kozec / sc-controller / scc / gui / ae / trigger_ab.py View on Github external
from scc.actions import TRIGGER_HALF, TRIGGER_CLICK
from scc.gui.ae import AEComponent, describe_action
from scc.gui.area_to_action import action_to_area
from scc.gui.simple_chooser import SimpleChooser
from scc.gui.parser import InvalidAction

import os, logging
log = logging.getLogger("AE.TriggerAB")

__all__ = [ 'TriggerABComponent' ]


class TriggerABComponent(AEComponent):
	GLADE = "ae/trigger_ab.glade"
	NAME = "trigger_ab"
	CTXS = Action.AC_TRIGGER
	
	def __init__(self, app, editor):
		AEComponent.__init__(self, app, editor)
		self.half = None
		self.full = None
	
	
	def handles(self, mode, action):
		# Handles only None and ButtonAction
		return isinstance(action, (ButtonAction, NoAction, InvalidAction))
	
	
	def get_button_title(self):
		return _("Key or Button")