control add button and optionally pos.

This commit is contained in:
Miroslav Šedivý 2022-07-23 00:42:12 +02:00
parent 3382126f40
commit 3180102006
3 changed files with 26 additions and 7 deletions

View File

@ -45,16 +45,28 @@ export class NekoControl extends EventEmitter<NekoControlEvents> {
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() {

View File

@ -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'

View File

@ -113,7 +113,11 @@ export interface ControlPos {
y: number
}
export interface ControlKey {
export interface ControlButton extends Partial<ControlPos> {
code: number
}
export interface ControlKey extends Partial<ControlPos> {
keysym: number
}