Browse Source

Added hacky Curses-based keyboard input test

Polling for keypresses in python is a PITA.
I also added a convenience build system that will probably only work for me
master
Macoy Madson 4 years ago
parent
commit
9b1657646b
2 changed files with 32 additions and 5 deletions
  1. +10
    -3
      project/keykey.sublime-project
  2. +22
    -2
      sequencer.py

+ 10
- 3
project/keykey.sublime-project View File

@ -10,15 +10,22 @@
],
"build_systems":
[
// For galavant/, use
// "working_dir": "$project_path/../../.."
// For keykey/, use
// "working_dir": "$project_path/.."
// Not sure why, but Sublime will actually keep going up across builds if you just do ../ first
//guake -n MyTabName -e "command args"
{
"name": "Sequencer Run",
"shell_cmd": "guake -n KeyKey -e \"(cd Development/code/repositories/keykey && exec python3 -c 'import sequencer; sequencer.main()')\"",
"working_dir": "$project_path/.."
},
// Misc. Commands
{
"name": "List",
"shell_cmd": "ls -l",
"working_dir": "$project_path"
"working_dir": "$project_path/.."
},
]
}

+ 22
- 2
sequencer.py View File

@ -1,5 +1,6 @@
import mido
import time
import curses
"""
mido.get_input_names()
@ -169,7 +170,26 @@ def simpleSequencer():
http://mido.readthedocs.io/en/latest/ports.html?highlight=reset """
# synthOut.panic()
if __name__ == '__main__':
# Note that key repeats mean that key holding is fucking weird
def testKeyInput(stdscr):
# Make getch() nonblocking
stdscr.nodelay(1)
while True:
inputChar = stdscr.getch()
if inputChar == ord('f'):
stdscr.addstr("This is a test")
elif inputChar == ord('q'):
break
time.sleep(0.05)
def main():
# testOutput()
# testIO()
simpleSequencer()
# Put in curses.wrapper so that the curses shit is cleaned up on close/exception
curses.wrapper(testKeyInput)
#simpleSequencer()
if __name__ == '__main__':
main()

Loading…
Cancel
Save