Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use const from evdev instead of manually checking ... #158

Open
github-actions bot opened this issue Jan 6, 2021 · 0 comments
Open

Use const from evdev instead of manually checking ... #158

github-actions bot opened this issue Jan 6, 2021 · 0 comments
Labels

Comments

@github-actions
Copy link

github-actions bot commented Jan 6, 2021

Use const from evdev instead of manually checking for cleaner code and no magic numbers

# TODO: Use const from evdev instead of manually checking for cleaner code and no magic numbers

        self.last_hotkey = None
    
    
    def apply_mappings(self, maps):
        """
        Applies custom mappings.

        Takes in key/value of key to code and adds to map array.

        NB: The map array hold the mapping of all key codes to the strings used to denoted them in configs.
        """
        for key, code in maps.items():
            logger.debug("Mapped " + key + " as (" + key + ") to code " + str(code))
            self.map[code] = "(" + key + ")"
    
    def watch_keyboard(self):
        """
        Keyboard watcher - watches keyboard for events and triggers hotkeys by sending events to server according to config

        # TODO: Use const from evdev instead of manually checking for cleaner code and no magic numbers
        """
        logger.info("Watching for key presses on " + self.name + "...")
        for event in self.keyboard_device.read_loop():
            # print(categorize(event))
            type = event.type # Event type - only interested in key event (EV_KEY)
            code = event.code # KDB Scan Code
            value = event.value # Value - up, down, hold.
            # We only want event type 1, as that is a key press
            # If key is already pressed, ignore event provided value not 0 (key unpressed)
            if type == evdev.ecodes.EV_KEY:

ddf16bf3c7cfe75abdae271bd57a0adde6695b58

@github-actions github-actions bot added the todo label Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants