From 281bcbd542aba2db135f8779e9bbde980af03727 Mon Sep 17 00:00:00 2001 From: Harold De Armas Date: Tue, 3 Aug 2021 11:47:42 -0700 Subject: [PATCH 1/3] Add hotkey 'list' support to send concurrent keycodes To better support multiple key macros in a row. Rather than needing to send +key.a, +key.b, -key.a, -key.b, +key.1, +key.2, etc. specifying up and down for each, you can define the chords more simply: [[key.a, key.b], [key.1, key.2]] The macro definition is simpler, and less error prone (see win-edge.py, was pressing control and releasing command). Also shorthands multiple presses in a row: [[Keycode.ENTER], [Keycode.ENTER], [Keycode.ENTER]] will press and release enter 3x in a row. --- Macropad_Hotkeys/code.py | 2 ++ Macropad_Hotkeys/macros/linux-firefox.py | 4 ++-- Macropad_Hotkeys/macros/mac-safari.py | 6 +++--- Macropad_Hotkeys/macros/win-edge.py | 6 +++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Macropad_Hotkeys/code.py b/Macropad_Hotkeys/code.py index 4d5e2622b..3c5c61aa0 100755 --- a/Macropad_Hotkeys/code.py +++ b/Macropad_Hotkeys/code.py @@ -137,6 +137,8 @@ def switch(self): MACROPAD.keyboard.press(item) else: MACROPAD.keyboard.release(item) + if isinstance(item, list): + MACROPAD.keyboard.send(*item) else: MACROPAD.keyboard_layout.write(item) else: diff --git a/Macropad_Hotkeys/macros/linux-firefox.py b/Macropad_Hotkeys/macros/linux-firefox.py index 36aa871b3..b4d5491e2 100644 --- a/Macropad_Hotkeys/macros/linux-firefox.py +++ b/Macropad_Hotkeys/macros/linux-firefox.py @@ -19,10 +19,10 @@ (0x000040, 'Home', [Keycode.CONTROL, 'h']), (0x000040, 'Private', [Keycode.CONTROL, Keycode.SHIFT, 'p']), # 4th row ---------- - (0x101010, 'Ada', [Keycode.CONTROL, 't', -Keycode.CONTROL, + (0x101010, 'Ada', [[Keycode.CONTROL, KEYCODE.N], 'www.adafruit.com\n']), # adafruit.com in a new tab (0x000040, 'Dev Mode', [Keycode.F12]), # dev mode - (0x101010, 'Digi', [Keycode.CONTROL, 't', -Keycode.CONTROL, + (0x101010, 'Digi', [[Keycode.CONTROL, KEYCODE.N], 'digikey.com\n']), # digikey in a new tab # Encoder button --- (0x000000, '', [Keycode.CONTROL, 'w']) # Close window/tab diff --git a/Macropad_Hotkeys/macros/mac-safari.py b/Macropad_Hotkeys/macros/mac-safari.py index 7b96e96c6..0aec9a9d4 100755 --- a/Macropad_Hotkeys/macros/mac-safari.py +++ b/Macropad_Hotkeys/macros/mac-safari.py @@ -19,11 +19,11 @@ (0x000040, 'Home', [Keycode.COMMAND, 'H']), (0x000040, 'Private', [Keycode.COMMAND, 'N']), # 4th row ---------- - (0x000000, 'Ada', [Keycode.COMMAND, 'n', -Keycode.COMMAND, + (0x000000, 'Ada', [[Keycode.COMMAND, KEYCODE.N], 'www.adafruit.com\n']), # Adafruit in new window - (0x800000, 'Digi', [Keycode.COMMAND, 'n', -Keycode.COMMAND, + (0x800000, 'Digi', [[Keycode.COMMAND, KEYCODE.N], 'www.digikey.com\n']), # Digi-Key in new window - (0x101010, 'Hacks', [Keycode.COMMAND, 'n', -Keycode.COMMAND, + (0x101010, 'Hacks', [[Keycode.COMMAND, KEYCODE.N], 'www.hackaday.com\n']), # Hack-a-Day in new win # Encoder button --- (0x000000, '', [Keycode.COMMAND, 'w']) # Close window/tab diff --git a/Macropad_Hotkeys/macros/win-edge.py b/Macropad_Hotkeys/macros/win-edge.py index 7941df7ee..5e9cc10de 100755 --- a/Macropad_Hotkeys/macros/win-edge.py +++ b/Macropad_Hotkeys/macros/win-edge.py @@ -19,11 +19,11 @@ (0x000040, 'Home', [Keycode.ALT, Keycode.HOME]), (0x000040, 'Private', [Keycode.CONTROL, 'N']), # 4th row ---------- - (0x000000, 'Ada', [Keycode.CONTROL, 'n', -Keycode.COMMAND, + (0x000000, 'Ada', [[Keycode.CONTROL, KEYCODE.N], 'www.adafruit.com\n']), # Adafruit in new window - (0x800000, 'Digi', [Keycode.CONTROL, 'n', -Keycode.COMMAND, + (0x800000, 'Digi', [[Keycode.CONTROL, KEYCODE.N], 'www.digikey.com\n']), # Digi-Key in new window - (0x101010, 'Hacks', [Keycode.CONTROL, 'n', -Keycode.COMMAND, + (0x101010, 'Hacks', [[Keycode.CONTROL, KEYCODE.N], 'www.hackaday.com\n']), # Hack-a-Day in new win # Encoder button --- (0x000000, '', [Keycode.CONTROL, 'w']) # Close tab From 4c60e45c3906f67c938f48e683f1f4d10c0aa038 Mon Sep 17 00:00:00 2001 From: Harold De Armas Date: Tue, 3 Aug 2021 11:55:27 -0700 Subject: [PATCH 2/3] if -> elif --- Macropad_Hotkeys/code.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Macropad_Hotkeys/code.py b/Macropad_Hotkeys/code.py index 3c5c61aa0..72f16b126 100755 --- a/Macropad_Hotkeys/code.py +++ b/Macropad_Hotkeys/code.py @@ -137,7 +137,7 @@ def switch(self): MACROPAD.keyboard.press(item) else: MACROPAD.keyboard.release(item) - if isinstance(item, list): + elif isinstance(item, list): MACROPAD.keyboard.send(*item) else: MACROPAD.keyboard_layout.write(item) From 1bf534dfc7c33d9febe52e66414f90ed50d4c270 Mon Sep 17 00:00:00 2001 From: Harold De Armas Date: Tue, 3 Aug 2021 22:59:44 -0700 Subject: [PATCH 3/3] Fix copypasta error Oops, fixed one copy paste error only to introduce another. Now both are fixed. --- Macropad_Hotkeys/macros/linux-firefox.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Macropad_Hotkeys/macros/linux-firefox.py b/Macropad_Hotkeys/macros/linux-firefox.py index b4d5491e2..3dfd63ba2 100644 --- a/Macropad_Hotkeys/macros/linux-firefox.py +++ b/Macropad_Hotkeys/macros/linux-firefox.py @@ -19,10 +19,10 @@ (0x000040, 'Home', [Keycode.CONTROL, 'h']), (0x000040, 'Private', [Keycode.CONTROL, Keycode.SHIFT, 'p']), # 4th row ---------- - (0x101010, 'Ada', [[Keycode.CONTROL, KEYCODE.N], + (0x101010, 'Ada', [[Keycode.CONTROL, KEYCODE.T], 'www.adafruit.com\n']), # adafruit.com in a new tab (0x000040, 'Dev Mode', [Keycode.F12]), # dev mode - (0x101010, 'Digi', [[Keycode.CONTROL, KEYCODE.N], + (0x101010, 'Digi', [[Keycode.CONTROL, KEYCODE.T], 'digikey.com\n']), # digikey in a new tab # Encoder button --- (0x000000, '', [Keycode.CONTROL, 'w']) # Close window/tab