UNPKG

pixelstream-cn

Version:

基于虚幻引擎的像素流平台

42 lines (36 loc) 1.24 kB
import base from "./base.js"; import messageType from "./messageType.js"; class axisMove extends base{ constructor(controllerIndex,axisIndex,analogValue){ super(); this.data = new DataView(new ArrayBuffer(11)); this.data.setUint8(0, messageType.GamepadAnalog); this.data.setUint8(1, controllerIndex); this.data.setUint8(2, axisIndex); this.data.setFloat64(3, analogValue, true); } } class ButtonPressed extends base{ constructor(controllerIndex, buttonIndex, isRepeat){ super(); this.data = new DataView(new ArrayBuffer(4)); this.data.setUint8(0, messageType.GamepadButtonPressed); this.data.setUint8(1, controllerIndex); this.data.setUint8(2, buttonIndex); this.data.setUint8(3, isRepeat); } } class ButtonReleased extends base{ constructor(controllerIndex, buttonIndex) { super(); this.data = new DataView(new ArrayBuffer(3)); this.data.setUint8(0, messageType.GamepadButtonReleased); this.data.setUint8(1, controllerIndex); this.data.setUint8(2, buttonIndex); } } export default { axisMove, ButtonPressed, ButtonReleased }