2018-09-03 05:06:53 +02:00
|
|
|
class Keymap:
|
|
|
|
def __init__(self, map):
|
|
|
|
self.map = map
|
|
|
|
self.state = [
|
|
|
|
[False for _ in row]
|
|
|
|
for row in self.map
|
|
|
|
]
|
|
|
|
|
|
|
|
def parse(self, matrix):
|
|
|
|
for ridx, row in enumerate(matrix):
|
|
|
|
for cidx, col in enumerate(row):
|
|
|
|
if col != self.state[ridx][cidx]:
|
2018-09-03 12:22:11 +02:00
|
|
|
yield '{}: {}'.format(
|
2018-09-03 05:06:53 +02:00
|
|
|
'KEYDOWN' if col else 'KEYUP',
|
|
|
|
self.map[ridx][cidx],
|
2018-09-03 12:22:11 +02:00
|
|
|
)
|
2018-09-03 05:06:53 +02:00
|
|
|
|
|
|
|
self.state = matrix
|