UNPKG

node-insim

Version:

An InSim library for NodeJS with TypeScript support

104 lines (103 loc) 4.77 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ButtonFunction = exports.IS_BFN = void 0; var decorators_1 = require("../decorators"); var base_1 = require("./base"); var enums_1 = require("./enums"); var IS_BTN_1 = require("./IS_BTN"); /** * Button FunctioN - delete buttons / receive button requests * * NOTE: {@link BFN_REQUEST} allows the user to bring up buttons with SHIFT+B or SHIFT+I * * - SHIFT+I clears all host buttons if any - or sends a {@link BFN_REQUEST} to host instances * - SHIFT+B is the same but for local buttons and local instances */ var IS_BFN = /** @class */ (function (_super) { __extends(IS_BFN, _super); function IS_BFN(data) { var _this = _super.call(this) || this; _this.Size = 8; _this.Type = enums_1.PacketType.ISP_BFN; _this.ReqI = 0; /** Subtype */ _this.SubT = 0; /** Connection to send to or received from (0 = local / 255 = all) */ _this.UCID = 0; /** If SubT is {@link BFN_DEL_BTN}: ID of single button to delete or first button in range */ _this.ClickID = 0; /** If SubT is {@link BFN_DEL_BTN}: ID of last button in range (if greater than ClickID) */ _this.ClickMax = 0; /** Used internally by InSim */ _this.Inst = 0; _this.initialize(data); return _this; } IS_BFN.prototype.pack = function () { if (this.ClickID > IS_BTN_1.IS_BTN.MAX_CLICK_ID) { throw new RangeError("IS_BFN - Invalid ClickID: ".concat(this.ClickID, " - must be less than or equal to ").concat(IS_BTN_1.IS_BTN.MAX_CLICK_ID)); } if (this.ClickMax > IS_BTN_1.IS_BTN.MAX_CLICK_ID) { throw new RangeError("IS_BFN - Invalid ClickMax: ".concat(this.ClickMax, " - must be less than or equal to ").concat(IS_BTN_1.IS_BTN.MAX_CLICK_ID)); } return _super.prototype.pack.call(this); }; __decorate([ (0, decorators_1.byte)() ], IS_BFN.prototype, "Size", void 0); __decorate([ (0, decorators_1.byte)() ], IS_BFN.prototype, "Type", void 0); __decorate([ (0, decorators_1.byte)() ], IS_BFN.prototype, "ReqI", void 0); __decorate([ (0, decorators_1.byte)() ], IS_BFN.prototype, "SubT", void 0); __decorate([ (0, decorators_1.byte)() ], IS_BFN.prototype, "UCID", void 0); __decorate([ (0, decorators_1.byte)() ], IS_BFN.prototype, "ClickID", void 0); __decorate([ (0, decorators_1.byte)() ], IS_BFN.prototype, "ClickMax", void 0); __decorate([ (0, decorators_1.byte)() ], IS_BFN.prototype, "Inst", void 0); return IS_BFN; }(base_1.SendablePacket)); exports.IS_BFN = IS_BFN; var ButtonFunction; (function (ButtonFunction) { /** Instruction: delete one button or range of buttons (must set ClickID) */ ButtonFunction[ButtonFunction["BFN_DEL_BTN"] = 0] = "BFN_DEL_BTN"; /** Instruction: clear all buttons made by this insim instance */ ButtonFunction[ButtonFunction["BFN_CLEAR"] = 1] = "BFN_CLEAR"; /** Info: user cleared this insim instance's buttons */ ButtonFunction[ButtonFunction["BFN_USER_CLEAR"] = 2] = "BFN_USER_CLEAR"; /** User request: SHIFT+B or SHIFT+I - request for buttons */ ButtonFunction[ButtonFunction["BFN_REQUEST"] = 3] = "BFN_REQUEST"; })(ButtonFunction || (exports.ButtonFunction = ButtonFunction = {}));