Esempio n. 1
0
    def _get_all_macros(self, profile=None, macro_list=None, macro_keys=None, mapped_to_key=False, state=None):
        """
        Get all macros, including those in parent profiles. By default, the
        "root" is the active profile
        
        Keyword argumentsL
        profile        -- root profile or None for active profile
        macro_list     -- list to append macros to.
        mapped_to_key  -- boolean indicator whether to only find UINPUT type macros
        """
        if profile is None:
            profile = g15profile.get_active_profile(self.__screen.device)
        if macro_list is None:
            macro_list = []
        if macro_keys is None:
            macro_keys = []

        if state == None:
            state = g15driver.KEY_STATE_UP

        bank = self.__screen.get_memory_bank()
        for m in profile.macros[state][bank - 1]:
            if not m.key_list_key in macro_keys:
                if (not mapped_to_key and not m.is_uinput()) or (mapped_to_key and m.is_uinput()):
                    macro_list.append(m)
                    macro_keys.append(m.key_list_key)
        if profile.base_profile is not None:
            profile = g15profile.get_profile(self.__screen.device, profile.base_profile)
            if profile is not None:
                self._get_all_macros(profile, macro_list, macro_keys, mapped_to_key, state)
        return macro_list
Esempio n. 2
0
 def _reload_macro_instance(self, macro):
     p = g15profile.get_profile(macro.profile.device, macro.profile.id)
     if p:
         return p.get_macro(macro.activate_on, macro.memory, macro.keys)
     logger.warning("Could not reload macro %s, using old instance.",
                    macro.name)
     return macro
Esempio n. 3
0
    def _build_macros(self,
                      profile=None,
                      macro_keys=None,
                      held_macro_keys=None,
                      down_macro_keys=None):
        if profile is None:
            profile = g15profile.get_active_profile(self.__screen.device)
        if macro_keys is None:
            macro_keys = []
        if held_macro_keys is None:
            held_macro_keys = []
        if down_macro_keys is None:
            down_macro_keys = []

        bank = self.__screen.get_memory_bank()
        for m in profile.macros[g15driver.KEY_STATE_UP][bank - 1]:
            if not m.key_list_key in macro_keys:
                if m.is_uinput():
                    self.__uinput_macros.append(m)
                else:
                    self.__normal_macros.append(m)
                macro_keys.append(m.key_list_key)

        for m in profile.macros[g15driver.KEY_STATE_DOWN][bank - 1]:
            if not m.key_list_key in down_macro_keys:
                if m.is_uinput():
                    self.__uinput_macros.append(m)
                else:
                    self.__normal_macros.append(m)
                down_macro_keys.append(m.key_list_key)

        for m in profile.macros[g15driver.KEY_STATE_HELD][bank - 1]:
            if not m.key_list_key in held_macro_keys:
                if not m.is_uinput():
                    self.__normal_held_macros.append(m)
                held_macro_keys.append(m.key_list_key)

        if profile.base_profile is not None:
            profile = g15profile.get_profile(self.__screen.device,
                                             profile.base_profile)
            if profile is not None:
                self._build_macros(profile, macro_keys, held_macro_keys,
                                   down_macro_keys)
Esempio n. 4
0
    def _get_all_macros(self,
                        profile=None,
                        macro_list=None,
                        macro_keys=None,
                        mapped_to_key=False,
                        state=None):
        """
        Get all macros, including those in parent profiles. By default, the
        "root" is the active profile
        
        Keyword argumentsL
        profile        -- root profile or None for active profile
        macro_list     -- list to append macros to.
        mapped_to_key  -- boolean indicator whether to only find UINPUT type macros
        """
        if profile is None:
            profile = g15profile.get_active_profile(self.__screen.device)
        if macro_list is None:
            macro_list = []
        if macro_keys is None:
            macro_keys = []

        if state == None:
            state = g15driver.KEY_STATE_UP

        bank = self.__screen.get_memory_bank()
        for m in profile.macros[state][bank - 1]:
            if not m.key_list_key in macro_keys:
                if ( not mapped_to_key and not m.is_uinput() ) or \
                    ( mapped_to_key and m.is_uinput() ):
                    macro_list.append(m)
                    macro_keys.append(m.key_list_key)
        if profile.base_profile is not None:
            profile = g15profile.get_profile(self.__screen.device,
                                             profile.base_profile)
            if profile is not None:
                self._get_all_macros(profile, macro_list, macro_keys,
                                     mapped_to_key, state)
        return macro_list
Esempio n. 5
0
    def _build_macros(self, profile=None, macro_keys=None, held_macro_keys=None, down_macro_keys=None):
        if profile is None:
            profile = g15profile.get_active_profile(self.__screen.device)
        if macro_keys is None:
            macro_keys = []
        if held_macro_keys is None:
            held_macro_keys = []
        if down_macro_keys is None:
            down_macro_keys = []

        bank = self.__screen.get_memory_bank()
        for m in profile.macros[g15driver.KEY_STATE_UP][bank - 1]:
            if not m.key_list_key in macro_keys:
                if m.is_uinput():
                    self.__uinput_macros.append(m)
                else:
                    self.__normal_macros.append(m)
                macro_keys.append(m.key_list_key)

        for m in profile.macros[g15driver.KEY_STATE_DOWN][bank - 1]:
            if not m.key_list_key in down_macro_keys:
                if m.is_uinput():
                    self.__uinput_macros.append(m)
                else:
                    self.__normal_macros.append(m)
                down_macro_keys.append(m.key_list_key)

        for m in profile.macros[g15driver.KEY_STATE_HELD][bank - 1]:
            if not m.key_list_key in held_macro_keys:
                if not m.is_uinput():
                    self.__normal_held_macros.append(m)
                held_macro_keys.append(m.key_list_key)

        if profile.base_profile is not None:
            profile = g15profile.get_profile(self.__screen.device, profile.base_profile)
            if profile is not None:
                self._build_macros(profile, macro_keys, held_macro_keys, down_macro_keys)
Esempio n. 6
0
 def _reload_macro_instance(self, macro):
     p = g15profile.get_profile(macro.profile.device, macro.profile.id)
     if p:
         return p.get_macro(macro.activate_on, macro.memory, macro.keys)
     logger.warning("Could not reload macro %s, using old instance.", macro.name)
     return macro