mirror of
https://github.com/whscullin/apple2js.git
synced 2024-01-12 14:14:38 +00:00
Fix preact apple keys
This commit is contained in:
parent
9686eda3a8
commit
6f804758f1
@ -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) {
|
||||
|
@ -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:
|
||||
|
@ -1,5 +1,6 @@
|
||||
.keyboard {
|
||||
margin-left: 15px;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
:global(.apple2e) .keyboard {
|
||||
|
Loading…
Reference in New Issue
Block a user