def generate(self, menuhandler): rv = [] for p in menuhandler.config['recent_profiles']: filename = find_profile(p) if filename: menuitem = MenuItem("generated", p) menuitem.filename = filename menuitem.callback = ProfileListMenuGenerator.callback rv.append(menuitem) if len(rv) >= self.rows: break return rv
def generate(self, menuhandler): rv = [] for p in menuhandler.config['recent_profiles']: filename = find_profile(p) if filename: menuitem = MenuItem("generated", p) menuitem.filename = filename menuitem.callback = ProfileListMenuGenerator.callback rv.append(menuitem) if len(rv) >= self.rows: break return rv
def generate(self, menuhandler): if GameListMenuGenerator._games is None: GameListMenuGenerator._games = [] id = 0 for x in Gio.AppInfo.get_all(): if x.get_categories(): if "Game" in x.get_categories().split(";"): menuitem = MenuItem(str(id), x.get_display_name(), icon = x.get_icon()) menuitem.callback = GameListMenuGenerator.callback menuitem._desktop_file = x GameListMenuGenerator._games.append(menuitem) return GameListMenuGenerator._games
def generate(self, menuhandler): if GameListMenuGenerator._games is None: GameListMenuGenerator._games = [] id = 0 for x in Gio.AppInfo.get_all(): if x.get_categories(): if "Game" in x.get_categories().split(";"): menuitem = MenuItem(str(id), x.get_display_name(), icon = x.get_icon()) menuitem.callback = GameListMenuGenerator.callback menuitem._desktop_file = x GameListMenuGenerator._games.append(menuitem) return GameListMenuGenerator._games
def generate(self, menuhandler): # TODO: Cannot load directory content asynchronously here and I'm # TODO: not happy about it rv, all_profiles = [], {} for d in (get_default_profiles_path(), get_profiles_path()): for x in os.listdir(d): if x.endswith(".sccprofile") and not x.startswith("."): all_profiles[x] = os.path.join(d, x) for p in sorted(all_profiles, key=lambda s: s.lower()): menuitem = MenuItem("generated", p[0:-11]) # strips ".sccprofile" menuitem.filename = all_profiles[p] menuitem.callback = self.callback rv.append(menuitem) return rv
def generate(self, menuhandler): # TODO: Cannot load directory content asynchronously here and I'm # TODO: not happy about it rv, all_profiles = [], {} for d in (get_default_profiles_path(), get_profiles_path()): for x in os.listdir(d): if x.endswith(".sccprofile") and not x.startswith("."): all_profiles[x] = os.path.join(d, x) for p in sorted(all_profiles, key=lambda s: s.lower()): menuitem = MenuItem("generated", p[0:-11]) # strips ".sccprofile" menuitem.filename = all_profiles[p] menuitem.callback = self.callback rv.append(menuitem) return rv
def generate(self, menuhandler): rv = [] dpy = X.Display(hash(GdkX11.x11_get_default_xdisplay())) # Magic root = X.get_default_root_window(dpy) count, wlist = X.get_window_prop(dpy, root, "_NET_CLIENT_LIST", 1024) skip_taskbar = X.intern_atom(dpy, "_NET_WM_STATE_SKIP_TASKBAR", True) wlist = cast(wlist, POINTER(X.XID))[0:count] for win in wlist: if not skip_taskbar in X.get_wm_state(dpy, win): title = X.get_window_title(dpy, win)[0:self.MAX_LENGHT] menuitem = MenuItem(str(win), title) menuitem.callback = WindowListMenuGenerator.callback rv.append(menuitem) return rv
def generate(self, menuhandler): rv = [] dpy = X.Display(hash(GdkX11.x11_get_default_xdisplay())) # Magic root = X.get_default_root_window(dpy) count, wlist = X.get_window_prop(dpy, root, "_NET_CLIENT_LIST", 1024) skip_taskbar = X.intern_atom(dpy, "_NET_WM_STATE_SKIP_TASKBAR", True) wlist = cast(wlist, POINTER(X.XID))[0:count] for win in wlist: if not skip_taskbar in X.get_wm_state(dpy, win): title = X.get_window_title(dpy, win)[0:self.MAX_LENGHT] menuitem = MenuItem(str(win), title) menuitem.callback = WindowListMenuGenerator.callback rv.append(menuitem) return rv
def _make_mi_instance(index): """ Helper method used by on_cbMI_toggled and load_cbMIs """ # label, class, icon, *init_parameters label, order, cls, icon, parameter = GlobalSettings.DEFAULT_MENU_OPTIONS[ index] if cls == MenuItem: instance = MenuItem("item_i%s" % (index, ), label, parameter, icon=icon) elif cls == Submenu: instance = Submenu(parameter, label, icon=icon) else: instance = cls(parameter) instance.icon = icon instance.label = label return instance
def on_btAddItem_clicked(self, *a): """ Handler for "Add Action" button and menu item """ item = MenuItem(None, NoAction().describe(Action.AC_OSD), NoAction()) self._add_menuitem(item) self.btEdit_clicked_cb()
def parse_group(self, group, side): """ Parses output (group) from vdf profile. Returns Action. """ if not "mode" in group: raise ParseError("Group without mode") mode = group["mode"] inputs = VDFProfile.get_inputs(group) settings = group["settings"] if "settings" in group else {} for o in ("output_trigger", "output_joystick"): if o in settings: if int(settings[o]) <= 1: side = Profile.LEFT else: side = Profile.RIGHT if mode == "dpad": keys = [] for k in ("dpad_north", "dpad_south", "dpad_east", "dpad_west"): if k in inputs: keys.append(self.parse_button(inputs[k])) else: keys.append(NoAction()) action = DPadAction(*keys) elif mode == "four_buttons": keys = [] for k in ("button_y", "button_a", "button_x", "button_b"): if k in inputs: keys.append(self.parse_button(inputs[k])) else: keys.append(NoAction()) action = DPadAction(*keys) elif mode == "joystick_move": if side == Profile.LEFT: # Left action = XYAction(AxisAction(Axes.ABS_X), AxisAction(Axes.ABS_Y)) else: # Right action = XYAction(AxisAction(Axes.ABS_RX), AxisAction(Axes.ABS_RY)) elif mode == "joystick_camera": output_joystick = 0 if 'output_joystick' in settings: output_joystick = int(settings['output_joystick']) if output_joystick == 0: action = BallModifier( XYAction(AxisAction(Axes.ABS_X), AxisAction(Axes.ABS_Y))) elif output_joystick == 1: action = BallModifier( XYAction(AxisAction(Axes.ABS_RX), AxisAction(Axes.ABS_RY))) else: # TODO: Absolute mouse? Doesn't seems to do anything in Steam action = BallModifier( SensitivityModifier(0.1, 0.1, MouseAction())) elif mode == "mouse_joystick": action = BallModifier( XYAction(AxisAction(Axes.ABS_RX), AxisAction(Axes.ABS_RY))) elif mode == "scrollwheel": action = BallModifier( XYAction(MouseAction(Rels.REL_HWHEEL), MouseAction(Rels.REL_WHEEL))) elif mode == "touch_menu": # Touch menu is converted to GridMenu items = [] next_item_id = 1 for k in inputs: action = self.parse_button(inputs[k]) items.append( MenuItem("item_%s" % (next_item_id, ), action.describe(Action.AC_BUTTON), action)) next_item_id += 1 # Menu is stored in profile, with generated ID menu_id = "menu_%s" % (self.next_menu_id, ) self.next_menu_id += 1 self.menus[menu_id] = MenuData(*items) action = GridMenuAction( menu_id, 'LEFT' if side == Profile.LEFT else 'RIGHT', SCButtons.LPAD if side == Profile.LEFT else SCButtons.RPAD) elif mode == "absolute_mouse": if "click" in inputs: if side == Profile.LEFT: self.add_by_binding(SCButtons.LPAD, self.parse_button(inputs["click"])) else: self.add_by_binding(SCButtons.RPAD, self.parse_button(inputs["click"])) if "gyro_axis" in settings: if int(settings["gyro_axis"]) == 1: action = MouseAction(ROLL) else: action = MouseAction(YAW) else: action = MouseAction() elif mode == "mouse_wheel": action = BallModifier( XYAction(MouseAction(Rels.REL_HWHEEL), ouseAction(Rels.REL_WHEEL))) elif mode == "trigger": actions = [] if "click" in inputs: actions.append( TriggerAction(TRIGGER_CLICK, self.parse_button(inputs["click"]))) if side == Profile.LEFT: actions.append(AxisAction(Axes.ABS_Z)) else: actions.append(AxisAction(Axes.ABS_RZ)) action = MultiAction.make(*actions) elif mode == "mouse_region": # Read value and assume dafaults scale = float(settings["scale"]) if "scale" in settings else 100.0 x = float( settings["position_x"]) if "position_x" in settings else 50.0 y = float( settings["position_y"]) if "position_y" in settings else 50.0 w = float(settings["sensitivity_horiz_scale"] ) if "sensitivity_horiz_scale" in settings else 100.0 h = float(settings["sensitivity_vert_scale"] ) if "sensitivity_vert_scale" in settings else 100.0 # Apply scale w = w * scale / 100.0 h = h * scale / 100.0 # Convert to (0, 1) range x, y = x / 100.0, 1.0 - (y / 100.0) w, h = w / 100.0, h / 100.0 # Convert to rectangle x1 = max(0.0, x - (w * VDFProfile.REGION_IMPORT_FACTOR)) x2 = min(1.0, x + (w * VDFProfile.REGION_IMPORT_FACTOR)) y1 = max(0.0, y - (h * VDFProfile.REGION_IMPORT_FACTOR)) y2 = min(1.0, y + (h * VDFProfile.REGION_IMPORT_FACTOR)) action = RelAreaAction(x1, y1, x2, y2) else: raise ParseError("Unknown mode: '%s'" % (group["mode"], )) action = VDFProfile.parse_modifiers(group, action, side) return action