예제 #1
0
                     macropad.consumer_control.press(code)
                 if isinstance(code, float):
                     time.sleep(code)
         elif isinstance(item, dict):
             if 'buttons' in item:
                 if item['buttons'] >= 0:
                     macropad.mouse.press(item['buttons'])
                 else:
                     macropad.mouse.release(-item['buttons'])
             macropad.mouse.move(item['x'] if 'x' in item else 0,
                                 item['y'] if 'y' in item else 0,
                                 item['wheel'] if 'wheel' in item else 0)
             if 'tone' in item:
                 if item['tone'] > 0:
                     macropad.stop_tone()
                     macropad.start_tone(item['tone'])
                 else:
                     macropad.stop_tone()
             elif 'play' in item:
                 macropad.play_file(item['play'])
 else:
     # Release any still-pressed keys, consumer codes, mouse buttons
     # Keys and mouse buttons are individually released this way (rather
     # than release_all()) because pad supports multi-key rollover, e.g.
     # could have a meta key or right-mouse held down by one macro and
     # press/release keys/buttons with others. Navigate popups, etc.
     for item in sequence:
         if isinstance(item, int):
             if item >= 0:
                 macropad.keyboard.release(item)
         elif isinstance(item, dict):
예제 #2
0
            # ... light up the pressed key with a color from the rainbow.
            macropad.pixels[key_event.key_number] = colorwheel(
                int(255 / 12) * key_event.key_number)

            # If it's a Keycode...
            if "KC" in shortcut_keys["macros"][key_event.key_number][2]:
                # ... send the associated key command or sequence of key commands.
                for key in keys[key_event.key_number]:
                    macropad.keyboard.press(key)
                macropad.keyboard.release_all()

            # If it's a ConsumerControlCode...
            if "CC" in shortcut_keys["macros"][key_event.key_number][2]:
                # ... send the associated consumer control code.
                for key in keys[key_event.key_number]:
                    macropad.consumer_control.send(key)

            sounds = key_sounds[
                key_event.key_number]  # Assign the tones/wavs to the keys.
            if isinstance(sounds, int):  # If the sound is a tone in Hz...
                macropad.start_tone(
                    sounds)  # ... play the tone while the key is pressed.
            if isinstance(
                    sounds,
                    str):  # If the sound is a wav file name as a string...
                macropad.play_file(sounds)  # ... play the wav file.
        else:
            # Otherwise, turn off the NeoPixels and stop the tone.
            macropad.pixels.fill(0)
            macropad.stop_tone()