diff --git a/package-lock.json b/package-lock.json index 2d6c1dc..fb25a6c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-simconnect", - "version": "3.6.3-alpha.0", + "version": "4.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "node-simconnect", - "version": "3.6.3-alpha.0", + "version": "4.0.0", "license": "LGPL-3.0-or-later", "dependencies": { "@types/node": "*", diff --git a/package.json b/package.json index 0aa5e64..3dffe08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-simconnect", - "version": "3.6.3-alpha.0", + "version": "4.0.0", "description": "A SimConnect client library for Node.JS.", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/samples/typescript/inputEvents.ts b/samples/typescript/inputEvents.ts index 52de737..ece4d37 100644 --- a/samples/typescript/inputEvents.ts +++ b/samples/typescript/inputEvents.ts @@ -9,7 +9,7 @@ open('My app', Protocol.KittyHawk) let allInputEvents: { inputEventName: string; - inputEventIdHash: string; + inputEventIdHash: bigint; params?: string; }[] = []; @@ -17,7 +17,7 @@ open('My app', Protocol.KittyHawk) recvEnumerateInputEvents.inputEventDescriptors.forEach(e => { allInputEvents.push({ inputEventName: e.name, - inputEventIdHash: e.inputEventIdHash.toString(), + inputEventIdHash: e.inputEventIdHash, }); handle.enumerateInputEventParams(e.inputEventIdHash); }); @@ -27,8 +27,7 @@ open('My app', Protocol.KittyHawk) // Update the list with the received value allInputEvents = allInputEvents.map(inputEvent => { if ( - inputEvent.inputEventIdHash === - recvEnumerateInputEventParams.inputEventIdHash.toString() + inputEvent.inputEventIdHash === recvEnumerateInputEventParams.inputEventIdHash ) { return { ...inputEvent, params: recvEnumerateInputEventParams.value }; } else { diff --git a/src/RawBuffer.ts b/src/RawBuffer.ts index 88ad166..76ded7c 100644 --- a/src/RawBuffer.ts +++ b/src/RawBuffer.ts @@ -71,8 +71,8 @@ class RawBuffer { return this.buffer.readInt64().toNumber(); } - readUint64(): Long { - return this.buffer.readUint64(); + readUint64(): bigint { + return BigInt(this.buffer.readUint64().toString(10)); } /** @deprecated use readInt64() instead */ @@ -86,8 +86,10 @@ class RawBuffer { this.buffer.writeUint64(value, offset); } - writeUint64(value: Long, offset?: number) { - this.buffer.writeUint64(value, offset); + writeUint64(value: bigint, offset?: number) { + const buffer = Buffer.alloc(8); + buffer.writeBigUint64LE(value); + this.buffer.append(buffer, undefined, offset); } /** @deprecated use writeInt64() instead */ diff --git a/src/SimConnectConnection.ts b/src/SimConnectConnection.ts index 53a9646..2c7f7d7 100644 --- a/src/SimConnectConnection.ts +++ b/src/SimConnectConnection.ts @@ -1596,7 +1596,7 @@ class SimConnectConnection extends EventEmitter { * * @returns sendId of packet (can be used to identify packet when exception event occurs) */ - getInputEvent(dataRequestID: number, inputEventHashID: Long): number { + getInputEvent(dataRequestID: number, inputEventHashID: bigint): number { if (this._ourProtocol < Protocol.KittyHawk) throw Error(SimConnectError.BadVersion); const packet = this._beginPacket(0x50).putInt32(dataRequestID).putUint64(inputEventHashID); @@ -1607,7 +1607,7 @@ class SimConnectConnection extends EventEmitter { * * @returns sendId of packet (can be used to identify packet when exception event occurs) */ - setInputEvent(inputEventHashID: Long, value: number | string): number { + setInputEvent(inputEventHashID: bigint, value: number | string): number { if (this._ourProtocol < Protocol.KittyHawk) throw Error(SimConnectError.BadVersion); const packet = this._beginPacket(0x51).putUint64(inputEventHashID); @@ -1625,7 +1625,7 @@ class SimConnectConnection extends EventEmitter { * * @returns sendId of packet (can be used to identify packet when exception event occurs) */ - subscribeInputEvent(inputEventHashID: Long): number { + subscribeInputEvent(inputEventHashID: bigint): number { if (this._ourProtocol < Protocol.KittyHawk) throw Error(SimConnectError.BadVersion); return this._buildAndSend(this._beginPacket(0x52).putUint64(inputEventHashID)); @@ -1635,7 +1635,7 @@ class SimConnectConnection extends EventEmitter { * * @returns sendId of packet (can be used to identify packet when exception event occurs) */ - unsubscribeInputEvent(inputEventHashID: Long): number { + unsubscribeInputEvent(inputEventHashID: bigint): number { if (this._ourProtocol < Protocol.KittyHawk) throw Error(SimConnectError.BadVersion); return this._buildAndSend(this._beginPacket(0x53).putUint64(inputEventHashID)); @@ -1645,7 +1645,7 @@ class SimConnectConnection extends EventEmitter { * * @returns sendId of packet (can be used to identify packet when exception event occurs) */ - enumerateInputEventParams(inputEventHashID: Long): number { + enumerateInputEventParams(inputEventHashID: bigint): number { if (this._ourProtocol < Protocol.KittyHawk) throw Error(SimConnectError.BadVersion); return this._buildAndSend(this._beginPacket(0x54).putUint64(inputEventHashID)); diff --git a/src/SimConnectPacketBuilder.ts b/src/SimConnectPacketBuilder.ts index e4decdc..8a565ee 100644 --- a/src/SimConnectPacketBuilder.ts +++ b/src/SimConnectPacketBuilder.ts @@ -54,7 +54,7 @@ export class SimConnectPacketBuilder { return this; } - putUint64(value: Long, offset?: number) { + putUint64(value: bigint, offset?: number) { this.packetContent.writeUint64(value, offset); return this; } diff --git a/src/datastructures/InputEventDescriptor.ts b/src/datastructures/InputEventDescriptor.ts index 54631b9..ab7f120 100644 --- a/src/datastructures/InputEventDescriptor.ts +++ b/src/datastructures/InputEventDescriptor.ts @@ -4,7 +4,7 @@ import { RawBuffer } from '../RawBuffer'; export class InputEventDescriptor { name: string; - inputEventIdHash: Long; + inputEventIdHash: bigint; type: InputEventType; diff --git a/src/recv/RecvEnumerateInputEventParams.ts b/src/recv/RecvEnumerateInputEventParams.ts index be9f9f2..73920c9 100644 --- a/src/recv/RecvEnumerateInputEventParams.ts +++ b/src/recv/RecvEnumerateInputEventParams.ts @@ -1,7 +1,7 @@ import { RawBuffer } from '../RawBuffer'; export class RecvEnumerateInputEventParams { - inputEventIdHash: Long; + inputEventIdHash: bigint; value: string; diff --git a/src/recv/RecvSubscribeInputEvent.ts b/src/recv/RecvSubscribeInputEvent.ts index 1999e93..e9c6173 100644 --- a/src/recv/RecvSubscribeInputEvent.ts +++ b/src/recv/RecvSubscribeInputEvent.ts @@ -2,7 +2,7 @@ import { RawBuffer } from '../RawBuffer'; import { InputEventType } from '../enums/InputEventType'; export class RecvSubscribeInputEvent { - inputEventIdHash: Long; + inputEventIdHash: bigint; type: InputEventType;