Skip to content

Commit

Permalink
Fix windows keyboard and mouse (#53)
Browse files Browse the repository at this point in the history
* Added CODE (#45)

* Added CODE

CODE function used to execute shell commands

* Update scripts.py

* Update scripts.py

* Update scripts.py

* Use master relase for LP.py

* Fix error handling for commands

* Change name for minimk3

* Add missing keys to windows keyboard (#48)

* Add missing keys to windows keyboard

* Fix mouse support

Co-authored-by: Silencx <[email protected]>
  • Loading branch information
duncte123 and Silencx authored Jul 16, 2020
1 parent 995b8f5 commit d183ddf
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion INSTALL/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ python3-xlib==0.15
PyTweening==1.0.3
six==1.14.0
tkcolorpicker==2.1.3
-e git+git://github.com/FMMT666/launchpad.py.git@3e3fc3b2589d9ced80bc6c9b218dd90c8a2dd485#egg=launchpad-py
-e git+git://github.com/FMMT666/launchpad.py.git@master#egg=launchpad-py
3 changes: 3 additions & 0 deletions kb.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@


def sp(name):
if "mouse_" in name:
return name

return keyboard_api.sp(name)


Expand Down
13 changes: 10 additions & 3 deletions scripts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import threading, webbrowser, os
import threading, webbrowser, os, subprocess
from time import sleep
from functools import partial
import lp_events, lp_colors, kb, sound, ms
Expand All @@ -10,7 +10,7 @@

import files

VALID_COMMANDS = ["@ASYNC", "@SIMPLE", "@LOAD_LAYOUT", "STRING", "DELAY", "TAP", "PRESS", "RELEASE", "WEB", "WEB_NEW", "SOUND", "WAIT_UNPRESSED", "M_MOVE", "M_SET", "M_SCROLL", "M_LINE", "M_LINE_MOVE", "M_LINE_SET", "LABEL", "IF_PRESSED_GOTO_LABEL", "IF_UNPRESSED_GOTO_LABEL", "GOTO_LABEL", "REPEAT_LABEL", "IF_PRESSED_REPEAT_LABEL", "IF_UNPRESSED_REPEAT_LABEL", "M_STORE", "M_RECALL", "M_RECALL_LINE", "OPEN", "RELEASE_ALL", "RESET_REPEATS"]
VALID_COMMANDS = ["@ASYNC", "@SIMPLE", "@LOAD_LAYOUT", "STRING", "DELAY", "TAP", "PRESS", "RELEASE", "WEB", "WEB_NEW", "CODE", "SOUND", "WAIT_UNPRESSED", "M_MOVE", "M_SET", "M_SCROLL", "M_LINE", "M_LINE_MOVE", "M_LINE_SET", "LABEL", "IF_PRESSED_GOTO_LABEL", "IF_UNPRESSED_GOTO_LABEL", "GOTO_LABEL", "REPEAT_LABEL", "IF_PRESSED_REPEAT_LABEL", "IF_UNPRESSED_REPEAT_LABEL", "M_STORE", "M_RECALL", "M_RECALL_LINE", "OPEN", "RELEASE_ALL", "RESET_REPEATS"]
ASYNC_HEADERS = ["@ASYNC", "@SIMPLE"]

threads = [[None for y in range(9)] for x in range(9)]
Expand Down Expand Up @@ -217,6 +217,13 @@ def main_logic(idx):
link = "http://" + link
print("[scripts] " + coords + " Open website " + link + " in default browser, try to make a new window")
webbrowser.open_new(link)
elif split_line[0] == "CODE":
args = " ".join(split_line[1:])
print("[scripts] " + coords + " Running code: " + args)
try:
subprocess.run(args)
except Exception as e:
print("[scripts] " + coords + " Error with running code: " + str(e))
elif split_line[0] == "SOUND":
if len(split_line) > 2:
print("[scripts] " + coords + " Play sound file " + split_line[1] + " at volume " + str(split_line[2]))
Expand Down Expand Up @@ -638,7 +645,7 @@ def validate_script(script_str):
return ("Headers must only be used on the first line of a script.", line)
if split_line[0] not in VALID_COMMANDS:
return ("Command '" + split_line[0] + "' not valid.", line)
if split_line[0] in ["STRING", "DELAY", "TAP", "PRESS", "RELEASE", "WEB", "WEB_NEW", "SOUND", "M_MOVE", "M_SET", "M_SCROLL", "OPEN"]:
if split_line[0] in ["STRING", "DELAY", "TAP", "PRESS", "RELEASE", "WEB", "WEB_NEW", "CODE", "SOUND", "M_MOVE", "M_SET", "M_SCROLL", "OPEN"]:
if len(split_line) < 2:
return ("Too few arguments for command '" + split_line[0] + "'.", line)
if split_line[0] in ["WAIT_UNPRESSED", "RELEASE_ALL", "RESET_REPEATS"]:
Expand Down
12 changes: 10 additions & 2 deletions system_apis/keyboard_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def release_key(hexKeyCode):


# List of all codes for keys:
# # msdn.microsoft.com/en-us/library/dd375731
# https://msdn.microsoft.com/en-us/library/dd375731
key_map = {
"alt": 0x12,
"alt_gr": 0x12, # TODO: find a way to send two keys
Expand Down Expand Up @@ -212,10 +212,18 @@ def release_key(hexKeyCode):
"y": 0x59,
"z": 0x5A,

"+": 0xBB,
"+": 0x6B,
"-": 0xBD,
"=": 0xBB,
".": 0xBE,
",": 0xBC,
"*": 0x6A,
"]": 0xDD,
"[": 0xDB,
";": 0xBA,
"'": 0xDE,
"\\": 0xDC,
"`": 0xC0,
}


Expand Down
8 changes: 4 additions & 4 deletions utils/launchpad_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

MK2_NAME = "Launchpad MK2"
# MK3MINI_NAME = "LPMiniMK3"
MK3MINI_NAME = "mk3"
MK3MINI_NAME = "minimk3"
PRO_NAME = "Launchpad Pro"
LPX_NAME = "lpx"
CTRL_XL_NAME = "control xl"
Expand All @@ -12,14 +12,14 @@
PAD_MODES = {
launchpad.Launchpad: "Mk1",
launchpad.LaunchpadMk2: "Mk2",
launchpad.LaunchpadMk3: "Mk3",
launchpad.LaunchpadMiniMk3: "Mk3",
launchpad.LaunchpadPro: "Pro",
launchpad.LaunchpadLPX: "Mk3"
}
PAD_TEXT = {
launchpad.Launchpad: "Classic/Mini/S",
launchpad.LaunchpadMk2: "MkII",
launchpad.LaunchpadMk3: "Mk3",
launchpad.LaunchpadMiniMk3: "Mk3",
launchpad.LaunchpadPro: "Pro (BETA)",
launchpad.LaunchpadLPX: "LPX"
}
Expand All @@ -32,7 +32,7 @@ def get_launchpad():
return launchpad.LaunchpadMk2()
# the MK3 has two midi devices, we need the second one
if lp.Check(1, MK3MINI_NAME):
return launchpad.LaunchpadMk3()
return launchpad.LaunchpadMiniMk3()
if lp.Check(0, PRO_NAME):
return launchpad.LaunchpadPro()
if lp.Check(1, LPX_NAME):
Expand Down

0 comments on commit d183ddf

Please sign in to comment.