Fix preact apple keys

This commit is contained in:
Will Scullin 2022-06-10 19:53:03 -07:00
parent 9686eda3a8
commit 6f804758f1
No known key found for this signature in database
GPG Key ID: 26DCD1042C6638CD
3 changed files with 8 additions and 6 deletions

View File

@ -421,8 +421,8 @@ export default class Apple2IO implements MemoryPages, Restorable<Apple2IOState>
this._keyDown = false;
}
buttonDown(b: button) {
this._button[b] = true;
buttonDown(b: button, state = true) {
this._button[b] = state;
}
buttonUp(b: button) {

View File

@ -145,9 +145,10 @@ export const Keyboard = ({ apple2, e }: KeyboardProps) => {
const toggleActive = (key: string) => {
if (!active.includes(key)) {
setActive([...active, key]);
} else {
setActive(active.filter(x => x !== key));
return true;
}
setActive(active.filter(x => x !== key));
return false;
};
const io = apple2.getIO();
@ -171,11 +172,11 @@ export const Keyboard = ({ apple2, e }: KeyboardProps) => {
apple2.reset();
break;
case 'OPEN_APPLE':
io.ioSwitch(0, io.ioSwitch(0) ? 0 : 1);
io.buttonDown(0, toggleActive(key));
toggleActive(key);
break;
case 'CLOSED_APPLE':
io.ioSwitch(1, io.ioSwitch(1) ? 0 : 1);
io.buttonDown(1, toggleActive(key));
toggleActive(key);
break;
default:

View File

@ -1,5 +1,6 @@
.keyboard {
margin-left: 15px;
user-select: none;
}
:global(.apple2e) .keyboard {