diff --git a/src/component/internal/control.ts b/src/component/internal/control.ts index 8b6f1d7d..b84cb2c1 100644 --- a/src/component/internal/control.ts +++ b/src/component/internal/control.ts @@ -45,16 +45,28 @@ export class NekoControl extends EventEmitter { this._connection.websocket.send(EVENT.CONTROL_SCROLL, { x, y } as message.ControlPos) } - public keyPress(keysym: number) { - this._connection.websocket.send(EVENT.CONTROL_KEYPRESS, { keysym } as message.ControlKey) + public buttonPress(code: number, x?: number, y?: number) { + this._connection.websocket.send(EVENT.CONTROL_BUTTONPRESS, { code, x, y } as message.ControlButton) } - public keyDown(keysym: number) { - this._connection.websocket.send(EVENT.CONTROL_KEYDOWN, { keysym } as message.ControlKey) + public buttonDown(code: number, x?: number, y?: number) { + this._connection.websocket.send(EVENT.CONTROL_BUTTONDOWN, { code, x, y } as message.ControlButton) } - public keyUp(keysym: number) { - this._connection.websocket.send(EVENT.CONTROL_KEYUP, { keysym } as message.ControlKey) + public buttonUp(code: number, x?: number, y?: number) { + this._connection.websocket.send(EVENT.CONTROL_BUTTONUP, { code, x, y } as message.ControlButton) + } + + public keyPress(keysym: number, x?: number, y?: number) { + this._connection.websocket.send(EVENT.CONTROL_KEYPRESS, { keysym, x, y } as message.ControlKey) + } + + public keyDown(keysym: number, x?: number, y?: number) { + this._connection.websocket.send(EVENT.CONTROL_KEYDOWN, { keysym, x, y } as message.ControlKey) + } + + public keyUp(keysym: number, x?: number, y?: number) { + this._connection.websocket.send(EVENT.CONTROL_KEYUP, { keysym, x, y } as message.ControlKey) } public cut() { diff --git a/src/component/types/events.ts b/src/component/types/events.ts index 414a8aad..6de9c222 100644 --- a/src/component/types/events.ts +++ b/src/component/types/events.ts @@ -25,6 +25,9 @@ export const CONTROL_REQUEST = 'control/request' // mouse export const CONTROL_MOVE = 'control/move' export const CONTROL_SCROLL = 'control/scroll' +export const CONTROL_BUTTONPRESS = 'control/buttonpress' +export const CONTROL_BUTTONDOWN = 'control/buttondown' +export const CONTROL_BUTTONUP = 'control/buttonup' // keyboard export const CONTROL_KEYPRESS = 'control/keypress' export const CONTROL_KEYDOWN = 'control/keydown' diff --git a/src/component/types/messages.ts b/src/component/types/messages.ts index ce3dc32a..37691ad9 100644 --- a/src/component/types/messages.ts +++ b/src/component/types/messages.ts @@ -113,7 +113,11 @@ export interface ControlPos { y: number } -export interface ControlKey { +export interface ControlButton extends Partial { + code: number +} + +export interface ControlKey extends Partial { keysym: number }