Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()
def on_btAdd_clicked(self, *a):
""" Handler for "Add Item" button """
tvItems = self.builder.get_object("tvItems")
model = tvItems.get_model()
o = GObject.GObject()
o.condition = Condition()
o.action = NoAction()
iter = model.append((o, o.condition.describe(), "None"))
tvItems.get_selection().select_iter(iter)
self.on_tvItems_cursor_changed()
self.btEdit_clicked_cb()
def __init__(self, doubleclickaction, normalaction=None, time=None):
Modifier.__init__(self)
HapticEnabledAction.__init__(self)
self.action = doubleclickaction
self.normalaction = normalaction or NoAction()
self.holdaction = NoAction()
self.actions = ( self.action, self.normalaction, self.holdaction )
self.timeout = time or DoubleclickModifier.DEAFAULT_TIMEOUT
self.waiting_task = None
self.pressed = False
self.active = None
if n_set and a_set:
action = MultiAction(GyroAction(*normal), GyroAbsAction(*absolute))
elif n_set:
action = GyroAction(*normal)
elif a_set:
action = GyroAbsAction(*absolute)
else:
action = NoAction()
if item and action:
what = getattr(SCButtons, item)
if item in TRIGGERS:
what = RangeOP(what, ">=", sclSoftLevel.get_value())
if cbInvertGyro.get_active():
action = ModeModifier(what, NoAction(), action)
else:
action = ModeModifier(what, action)
self.editor.set_action(action)
if self.axes[i] is not None:
if self.cbs[i].get_active():
absolute[i] = Axes(self.axes[i])
a_set = True
else:
normal[i] = Axes(self.axes[i])
n_set = True
if n_set and a_set:
action = MultiAction(GyroAction(*normal), GyroAbsAction(*absolute))
elif n_set:
action = GyroAction(*normal)
elif a_set:
action = GyroAbsAction(*absolute)
else:
action = NoAction()
if item and action:
what = getattr(SCButtons, item)
# TODO: Restore this
#if item in TRIGGERS:
# what = RangeOP(what, ">=", sclSoftLevel.get_value())
if cbInvertGyro.get_active():
action = ModeModifier(what, NoAction(), action)
else:
action = ModeModifier(what, action)
self.editor.set_action(action)
def _save_modemod(self, index):
""" Generates ModeModifier from page in Notebook """
pars = []
# TODO: Other pages
for button, action, l, b, clearb in self.actions[index]:
pars += [ button, action ]
if self.nomods[index]:
pars += [ self.nomods[index] ]
action = ModeModifier(*pars)
if len(pars) == 0:
# No action is actually set
action = NoAction()
elif len(pars) == 1:
# Only default action left
action = self.nomods[index]
return action
def on_btClearCircularAxis_clicked(self, *a):
btCircularAxis = self.builder.get_object("btCircularAxis")
self.circular_axis = NoAction()
btCircularAxis.set_label(self.circular_axis.describe(Action.AC_PAD))
self.editor.set_action(self.make_circular_action())
def clear(self):
""" Clears all actions and adds default menu action on center button """
self.buttons = { x : NoAction() for x in SCButtons }
self.buttons[SCButtons.C] = HoldModifier(
MenuAction("Default.menu"),
MenuAction("Default.menu")
)
self.menus = {}
self.stick = NoAction()
self.is_template = False
self.triggers = { Profile.LEFT : NoAction(), Profile.RIGHT : NoAction() }
self.pads = { Profile.LEFT : NoAction(),
Profile.RIGHT : NoAction(), Profile.CPAD : NoAction() }
self.gyro = NoAction()
# Stick & gyro
self.stick = self.parser.from_json_data(data, "stick")
self.gyro = self.parser.from_json_data(data, "gyro")
if "triggers" in data:
# Old format
# Triggers
self.triggers = ({
x : self.parser.from_json_data(data["triggers"], x) for x in Profile.TRIGGERS
})
# Pads
self.pads = {
Profile.LEFT : self.parser.from_json_data(data, "left_pad"),
Profile.RIGHT : self.parser.from_json_data(data, "right_pad"),
Profile.CPAD : NoAction()
}
else:
# New format
# Triggers
self.triggers = {
Profile.LEFT : self.parser.from_json_data(data, "trigger_left"),
Profile.RIGHT : self.parser.from_json_data(data, "trigger_right"),
}
# Pads
self.pads = {
Profile.LEFT : self.parser.from_json_data(data, "pad_left"),
Profile.RIGHT : self.parser.from_json_data(data, "pad_right"),
Profile.CPAD : self.parser.from_json_data(data, "cpad"),
}
def __init__(self, app, editor):
AEComponent.__init__(self, app, editor)
BindingEditor.__init__(self, app)
self._recursing = False
self.half = NoAction()
self.full = NoAction()
self.analog = NoAction()