feat: More keyboard shortcuts

This commit is contained in:
Felix Rieseberg 2019-08-21 11:34:55 +02:00
parent c7f765df03
commit ea134d046e
3 changed files with 38 additions and 1 deletions

View file

@ -18,7 +18,8 @@ export const IPC_COMMANDS = {
MACHINE_RESTART: 'MACHINE_RESTART',
MACHINE_STOP: 'MACHINE_STOP',
MACHINE_RESET: 'MACHINE_RESET',
MACHINE_ALTF4: 'MACHINE_ALTF4',
MACHINE_ALT_F4: 'MACHINE_ALT_F4',
MACHINE_ALT_ENTER: 'MACHINE_ALT_ENTER',
MACHINE_CTRL_ALT_DEL: 'MACHINE_CTRL_ALT_DEL',
// Machine events
MACHINE_STARTED: 'MACHINE_STARTED',

View file

@ -111,6 +111,16 @@ async function createMenu({ isRunning } = { isRunning: false }) {
click: () => send(IPC_COMMANDS.MACHINE_CTRL_ALT_DEL),
enabled: isRunning
},
{
label: "Send Alt+F4",
click: () => send(IPC_COMMANDS.MACHINE_ALT_F4),
enabled: isRunning
},
{
label: "Send Alt+Enter",
click: () => send(IPC_COMMANDS.MACHINE_ALT_ENTER),
enabled: isRunning
},
{
type: "separator"
},

View file

@ -119,6 +119,32 @@ export class Emulator extends React.Component<{}, EmulatorState> {
}
});
ipcRenderer.on(IPC_COMMANDS.MACHINE_ALT_F4, () => {
if (this.state.emulator && this.state.isRunning) {
this.state.emulator.keyboard_send_scancodes([
0x38, // alt
0x3E, // f4
// break codes
0x38 | 0x80,
0x3E | 0x80
]);
}
});
ipcRenderer.on(IPC_COMMANDS.MACHINE_ALT_ENTER, () => {
if (this.state.emulator && this.state.isRunning) {
this.state.emulator.keyboard_send_scancodes([
0x38, // alt
0, // enter
// break codes
0x38 | 0x80,
0 | 0x80
]);
}
});
ipcRenderer.on(IPC_COMMANDS.MACHINE_STOP, this.stopEmulator);
ipcRenderer.on(IPC_COMMANDS.MACHINE_RESET, this.resetEmulator);
ipcRenderer.on(IPC_COMMANDS.MACHINE_START, this.startEmulator);