You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
650 B
30 lines
650 B
from pynput import mouse
|
|
from AppKit import NSScreen
|
|
import rtmidi
|
|
|
|
midiout = rtmidi.MidiOut()
|
|
available_ports = midiout.get_ports()
|
|
|
|
i = 0
|
|
for port in available_ports:
|
|
if "IAC Driver" in port:
|
|
midiout.open_port(i)
|
|
break
|
|
i+=1
|
|
|
|
def get_screen_size():
|
|
screen = NSScreen.mainScreen()
|
|
frame = screen.frame()
|
|
width = int(frame.size.width)
|
|
height = int(frame.size.height)
|
|
return width, height
|
|
|
|
|
|
def on_move(x, y):
|
|
w, h = get_screen_size()
|
|
midiout.send_message([0xB0, 16, 127-(127*y/h)])
|
|
midiout.send_message([0xB0, 17, 127*x/w])
|
|
|
|
with mouse.Listener(on_move=on_move) as listener:
|
|
listener.join()
|