Skip to content

Commit 37c5642

Browse files
committed
Adds unicode keyboard reading, blocks events after display.init
1 parent 0a1cd75 commit 37c5642

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
- Fixes bug where audio files could not be loaded because mixer.init was not
33
allowing the data to be modified to suit the hardware needs
44
- 1, 2, and 4 channel wave files now supported
5+
- Fixes bug where keyboard files were read as ascii instead of unicode
6+
- Fixes bug where blocked audio device events were showing up in the queues
57

68
## 2.0.0
79
- Add qwerty keyboard layout and defaults to using it

Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ testpypi:
2222
then \
2323
echo "\nNot publishing"; exit 1; \
2424
fi
25-
make dist
2625
python -m twine upload --repository testpypi dist/*
2726

2827
pypi:
@@ -31,5 +30,4 @@ pypi:
3130
then \
3231
echo "\nNot publishing"; exit 1; \
3332
fi
34-
make dist
3533
twine upload dist/*

pianoputer/pianoputer.py

100755100644
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22

33
import argparse
4+
import codecs
45
import pygame
56
import warnings
67
import librosa
@@ -136,7 +137,7 @@ def __get_black_key_indices(key_name: str) -> set:
136137
return black_key_indices
137138

138139
def get_keyboard_info(keyboard_file: str):
139-
with open(keyboard_file, 'r') as k_file:
140+
with codecs.open(keyboard_file, encoding='utf-8') as k_file:
140141
lines = k_file.readlines()
141142
keys = []
142143
anchor_index = -1
@@ -206,6 +207,10 @@ def configure_pygame_audio_and_set_ui(
206207
pygame.display.init()
207208
pygame.display.set_caption('pianoputer')
208209

210+
# block events that we don't want, this must be after display.init
211+
pygame.event.set_blocked(None)
212+
pygame.event.set_allowed(list(ALLOWED_EVENTS))
213+
209214
# fonts
210215
pygame.font.init()
211216

@@ -216,10 +221,6 @@ def configure_pygame_audio_and_set_ui(
216221
allowedchanges=AUDIO_ALLOWED_CHANGES_HARDWARE_DETERMINED
217222
)
218223

219-
# block events that we don't want
220-
pygame.event.set_blocked(None)
221-
pygame.event.set_allowed(list(ALLOWED_EVENTS))
222-
223224
screen_width = 50
224225
screen_height = 50
225226
if 'qwerty' in keyboard_arg:

0 commit comments

Comments
 (0)