1
0
mirror of https://github.com/mnaberez/py65.git synced 2024-09-27 09:55:23 +00:00

Added Windows support for nonblocking character input.

This commit is contained in:
Mike Naberezny 2009-08-12 16:25:02 -07:00
parent c2c08d62d2
commit b28bbe787a
3 changed files with 46 additions and 27 deletions

View File

@ -1,3 +1,8 @@
Next Release
- When using the monitor, the nonblocking character input at
$F004 should now work on the Microsoft Windows platform.
0.6 (2009-08-11)
- Added monitor shortcut "a" for "assemble".

View File

@ -6,5 +6,3 @@ Instructions needing unit tests:
Better error messages when assembling fails.
Ability to assemble more than one instruction at a time.
Windows support for non-blocking character input.

View File

@ -1,12 +1,28 @@
import sys
if sys.platform[:3] == "win":
import msvcrt
def getch(stdin):
""" Performs a nonblocking read of one byte from the Windows
console and returns its ordinal value. The stdin argument
is for function signature compatibility and is ignored. If
no byte is available, 0 is returned.
"""
if msvcrt.kbhit():
return ord(msvcrt.getch())
return 0
else:
import select
import os
import termios
import fcntl
def getch(stdin):
""" Performs a nonblocking read of one byte from stdin and returns
its ordinal value. If no byte is available, 0 is returned.
"""
import termios
import fcntl
fd = stdin.fileno()