Esempio n. 1
0
 def _handle_key_dict(self, d: dict) -> str:
     """
     :param d: dictionary
     :return:
     Takes an configuration for a single key.
     Generates a keycode to to be inserted into KEYMAP macro in keymap.c file.
     As a side effect, prepare macro code and field variables used for insertion.
     """
     p = KeyConfDictParser(d)
     p.assign_id_if_no_id_bound()
     p = self._prepare_macro_code_to_be_inserted(p)
     return p.to_keymap_element()
    def get_keyname(key_conf_dict: dict):
        d = key_conf_dict
        p = KeyConfDictParser(d)
        if p.is_macro():
            return ''  # Macro should use macro_name
        t = p.to_keymap_element()
        # check if keymap_element contains hid_usage_id that
        # needs to be translated.
        #
        if p.special_action != "":
            return KeyConfDictGenerator._line_break_label(p.keyname)

        # Note: when user chooses the keycode to assign to a key from
        # drop down menu, p.hid_usage_id is empty;bad design.
        # todo fix this.
        if p.hid_usage_id != "" and t.index(str(p.hid_usage_id)) > -1:
            t = t.replace(str(p.hid_usage_id), p.keyname)
        else:
            # when user selects input from drop down menu
            t = p.keyname
        return KeyConfDictGenerator._line_break_label(t)