langel / vixxen20

Commodore VIC 20 simulation environment
Other
8 stars 2 forks source link

handle input using different keyboard layouts #47

Closed argarak closed 3 years ago

argarak commented 3 years ago

this implementation is somewhat of a compromise as it means that all key commands are all the same physical keys as on a qwerty keyboard, this is actually something that renoise does as well.

this works by taking in the e.code value in the main input event callback function, converting the e.code value into the numeric keyCode of the physical key and returning a different key_state, thereby making this possible without replacing every use of a key command in the code. all codes that contain Key or Digit and some select punctuation keys are translated (as seen in the keyCodeLookUp object) and the rest of the keys are unaffected, like arrow keys, home, end etc.

for string inputs, I added a new field to key_state objects called inputKey, which shows the actual key pressed taking the layout into account, making it actually possible to type in the song metadata.

hopefully this shouldn't affect usage on a normal qwerty keyboard at all! (but please test and let me know if there's any problems so i can amend the commit!) i have tested all the possible keyboard shortcuts written in the documentation, but i couldn't test the ~ button to insert an "end song" and i also couldn't get the pal/ntsc key command to work. though it seems that i can change the pal/ntsc settings by pressing ctrl and backtick, but it also inserts a "song next"? i think this is a different bug heh.