@irsdk-node/native 4.0.2 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -46
- package/binding.gyp +28 -19
- package/dist/INativeSDK.d.ts +28 -0
- package/dist/INativeSDK.js +2 -0
- package/dist/MockSdk.d.ts +43 -0
- package/dist/MockSdk.js +70 -0
- package/dist/mock-data/loader.d.ts +3 -0
- package/dist/mock-data/loader.js +41 -0
- package/dist/mock-data/session.json +4305 -0
- package/dist/mock-data/telemetry.json +4986 -0
- package/{src/index.d.ts → index.d.ts} +5 -35
- package/index.js +36 -0
- package/lib/irsdk_client.cpp +495 -495
- package/lib/irsdk_client.h +139 -139
- package/lib/irsdk_defines.h +528 -528
- package/{src → lib}/irsdk_node.cc +404 -375
- package/{src → lib}/irsdk_node.h +49 -50
- package/lib/irsdk_node_mocked.cc +226 -0
- package/lib/irsdk_utils.cpp +377 -377
- package/lib/yaml_parser.cpp +176 -176
- package/lib/yaml_parser.h +34 -34
- package/package.json +37 -29
- package/prebuilds/darwin-arm64/@irsdk-node+native.node +0 -0
- package/prebuilds/linux-x64/@irsdk-node+native.node +0 -0
- package/prebuilds/win32-x64/@irsdk-node+native.node +0 -0
- package/build/Debug/irsdk_node.exp +0 -0
- package/build/Debug/irsdk_node.lib +0 -0
- package/build/Debug/irsdk_node.node +0 -0
- package/build/Debug/irsdk_node.pdb +0 -0
- package/build/Debug/obj/irsdk_node/irsdk_node.node.recipe +0 -11
- package/build/Debug/obj/irsdk_node/irsdk_node.tlog/CL.command.1.tlog +0 -0
- package/build/Debug/obj/irsdk_node/irsdk_node.tlog/CL.read.1.tlog +0 -0
- package/build/Debug/obj/irsdk_node/irsdk_node.tlog/CL.write.1.tlog +0 -0
- package/build/Debug/obj/irsdk_node/irsdk_node.tlog/Cl.items.tlog +0 -4
- package/build/Debug/obj/irsdk_node/irsdk_node.tlog/irsdk_node.lastbuildstate +0 -2
- package/build/Debug/obj/irsdk_node/irsdk_node.tlog/link.command.1.tlog +0 -0
- package/build/Debug/obj/irsdk_node/irsdk_node.tlog/link.read.1.tlog +0 -0
- package/build/Debug/obj/irsdk_node/irsdk_node.tlog/link.secondary.1.tlog +0 -3
- package/build/Debug/obj/irsdk_node/irsdk_node.tlog/link.write.1.tlog +0 -0
- package/build/Debug/obj/irsdk_node/lib/irsdk_utils.obj +0 -0
- package/build/Debug/obj/irsdk_node/lib/yaml_parser.obj +0 -0
- package/build/Debug/obj/irsdk_node/src/irsdk_node.obj +0 -0
- package/build/Debug/obj/irsdk_node/vcpkg.applocal.log +0 -1
- package/build/Debug/obj/irsdk_node/win_delay_load_hook.obj +0 -0
- package/build/Release/irsdk_node.exp +0 -0
- package/build/Release/irsdk_node.iobj +0 -0
- package/build/Release/irsdk_node.ipdb +0 -0
- package/build/Release/irsdk_node.lib +0 -0
- package/build/Release/irsdk_node.node +0 -0
- package/build/Release/irsdk_node.pdb +0 -0
- package/build/Release/obj/irsdk_node/irsdk_node.node.recipe +0 -11
- package/build/Release/obj/irsdk_node/irsdk_node.tlog/CL.command.1.tlog +0 -0
- package/build/Release/obj/irsdk_node/irsdk_node.tlog/CL.read.1.tlog +0 -0
- package/build/Release/obj/irsdk_node/irsdk_node.tlog/CL.write.1.tlog +0 -0
- package/build/Release/obj/irsdk_node/irsdk_node.tlog/Cl.items.tlog +0 -4
- package/build/Release/obj/irsdk_node/irsdk_node.tlog/irsdk_node.lastbuildstate +0 -2
- package/build/Release/obj/irsdk_node/irsdk_node.tlog/link.command.1.tlog +0 -0
- package/build/Release/obj/irsdk_node/irsdk_node.tlog/link.read.1.tlog +0 -0
- package/build/Release/obj/irsdk_node/irsdk_node.tlog/link.secondary.1.tlog +0 -5
- package/build/Release/obj/irsdk_node/irsdk_node.tlog/link.write.1.tlog +0 -0
- package/build/Release/obj/irsdk_node/lib/irsdk_utils.obj +0 -0
- package/build/Release/obj/irsdk_node/lib/yaml_parser.obj +0 -0
- package/build/Release/obj/irsdk_node/src/irsdk_node.obj +0 -0
- package/build/Release/obj/irsdk_node/vcpkg.applocal.log +0 -1
- package/build/Release/obj/irsdk_node/win_delay_load_hook.obj +0 -0
- package/build/binding.sln +0 -19
- package/build/config.gypi +0 -426
- package/build/irsdk_node.vcxproj +0 -157
- package/build/irsdk_node.vcxproj.filters +0 -73
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -13
- package/src/index.js +0 -11
package/lib/irsdk_client.h
CHANGED
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) 2013, iRacing.com Motorsport Simulations, LLC.
|
|
3
|
-
All rights reserved.
|
|
4
|
-
|
|
5
|
-
Redistribution and use in source and binary forms, with or without
|
|
6
|
-
modification, are permitted provided that the following conditions are met:
|
|
7
|
-
* Redistributions of source code must retain the above copyright
|
|
8
|
-
notice, this list of conditions and the following disclaimer.
|
|
9
|
-
* Redistributions in binary form must reproduce the above copyright
|
|
10
|
-
notice, this list of conditions and the following disclaimer in the
|
|
11
|
-
documentation and/or other materials provided with the distribution.
|
|
12
|
-
* Neither the name of iRacing.com Motorsport Simulations nor the
|
|
13
|
-
names of its contributors may be used to endorse or promote products
|
|
14
|
-
derived from this software without specific prior written permission.
|
|
15
|
-
|
|
16
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
17
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
18
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
19
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
20
|
-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
21
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
22
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
23
|
-
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
24
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
#ifndef IRSDKCLIENT_H
|
|
29
|
-
#define IRSDKCLIENT_H
|
|
30
|
-
|
|
31
|
-
// A C++ wrapper around the irsdk calls that takes care of the details of maintaining a connection.
|
|
32
|
-
// reads out the data into a cache so you don't have to worry about timming
|
|
33
|
-
class irsdkClient
|
|
34
|
-
{
|
|
35
|
-
public:
|
|
36
|
-
// singleton
|
|
37
|
-
static irsdkClient& instance();
|
|
38
|
-
|
|
39
|
-
// wait for live data, or if a .ibt file is open
|
|
40
|
-
// then read the next line from the file.
|
|
41
|
-
bool waitForData(int timeoutMS = 16);
|
|
42
|
-
|
|
43
|
-
bool isConnected();
|
|
44
|
-
int getStatusID() { return m_statusID; }
|
|
45
|
-
|
|
46
|
-
int getVarIdx(const char*name);
|
|
47
|
-
|
|
48
|
-
// what is the base type of the data
|
|
49
|
-
// returns irsdk_VarType as int so we don't depend on irsdk_defines.h
|
|
50
|
-
int getVarType(int idx);
|
|
51
|
-
int getVarType(const char *name) { return getVarType(getVarIdx(name)); }
|
|
52
|
-
|
|
53
|
-
// how many elements in array, or 1 if not an array
|
|
54
|
-
int getVarCount(int idx);
|
|
55
|
-
int getVarCount(const char *name) { return getVarCount(getVarIdx(name)); }
|
|
56
|
-
|
|
57
|
-
// idx is the variables index, entry is the array offset, or 0 if not an array element
|
|
58
|
-
// will convert data to requested type
|
|
59
|
-
bool getVarBool(int idx, int entry = 0);
|
|
60
|
-
bool getVarBool(const char *name, int entry = 0) { return getVarBool(getVarIdx(name), entry); }
|
|
61
|
-
|
|
62
|
-
int getVarInt(int idx, int entry = 0);
|
|
63
|
-
int getVarInt(const char *name, int entry = 0) { return getVarInt(getVarIdx(name), entry); }
|
|
64
|
-
|
|
65
|
-
float getVarFloat(int idx, int entry = 0);
|
|
66
|
-
float getVarFloat(const char *name, int entry = 0) { return getVarFloat(getVarIdx(name), entry); }
|
|
67
|
-
|
|
68
|
-
double getVarDouble(int idx, int entry = 0);
|
|
69
|
-
double getVarDouble(const char *name, int entry = 0) { return getVarDouble(getVarIdx(name), entry); }
|
|
70
|
-
|
|
71
|
-
//---
|
|
72
|
-
|
|
73
|
-
// value that increments with each update to string
|
|
74
|
-
int getSessionCt() { return irsdk_getSessionInfoStrUpdate(); }
|
|
75
|
-
|
|
76
|
-
// has string changed since we last read any values from it
|
|
77
|
-
bool wasSessionStrUpdated() { return m_lastSessionCt != getSessionCt(); }
|
|
78
|
-
|
|
79
|
-
// pars string for individual value, 1 success, 0 failure, -n minimum buffer size
|
|
80
|
-
//****Note, this is a linear parser, so it is slow!
|
|
81
|
-
int getSessionStrVal(const char *path, char *val, int valLen);
|
|
82
|
-
|
|
83
|
-
// get the whole string
|
|
84
|
-
const char *getSessionStr();
|
|
85
|
-
|
|
86
|
-
protected:
|
|
87
|
-
|
|
88
|
-
irsdkClient()
|
|
89
|
-
: m_data(NULL)
|
|
90
|
-
, m_nData(0)
|
|
91
|
-
, m_statusID(0)
|
|
92
|
-
, m_lastSessionCt(-1)
|
|
93
|
-
{ }
|
|
94
|
-
|
|
95
|
-
~irsdkClient() { shutdown(); }
|
|
96
|
-
|
|
97
|
-
void shutdown();
|
|
98
|
-
|
|
99
|
-
char *m_data;
|
|
100
|
-
int m_nData;
|
|
101
|
-
int m_statusID;
|
|
102
|
-
|
|
103
|
-
int m_lastSessionCt;
|
|
104
|
-
|
|
105
|
-
static irsdkClient *m_instance;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
// helper class to keep track of our variables index
|
|
110
|
-
// Create a global instance of this and it will take care of the details for you.
|
|
111
|
-
class irsdkCVar
|
|
112
|
-
{
|
|
113
|
-
public:
|
|
114
|
-
irsdkCVar();
|
|
115
|
-
irsdkCVar(const char *name);
|
|
116
|
-
|
|
117
|
-
void setVarName(const char *name);
|
|
118
|
-
|
|
119
|
-
// returns irsdk_VarType as int so we don't depend on irsdk_defines.h
|
|
120
|
-
int getType();
|
|
121
|
-
int getCount();
|
|
122
|
-
bool isValid();
|
|
123
|
-
|
|
124
|
-
// entry is the array offset, or 0 if not an array element
|
|
125
|
-
bool getBool(int entry = 0);
|
|
126
|
-
int getInt(int entry = 0);
|
|
127
|
-
float getFloat(int entry = 0);
|
|
128
|
-
double getDouble(int entry = 0);
|
|
129
|
-
|
|
130
|
-
protected:
|
|
131
|
-
bool checkIdx();
|
|
132
|
-
|
|
133
|
-
static const int max_string = 32; //IRSDK_MAX_STRING
|
|
134
|
-
char m_name[max_string];
|
|
135
|
-
int m_idx;
|
|
136
|
-
int m_statusID;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
#endif // IRSDKCLIENT_H
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2013, iRacing.com Motorsport Simulations, LLC.
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
* Redistributions of source code must retain the above copyright
|
|
8
|
+
notice, this list of conditions and the following disclaimer.
|
|
9
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
10
|
+
notice, this list of conditions and the following disclaimer in the
|
|
11
|
+
documentation and/or other materials provided with the distribution.
|
|
12
|
+
* Neither the name of iRacing.com Motorsport Simulations nor the
|
|
13
|
+
names of its contributors may be used to endorse or promote products
|
|
14
|
+
derived from this software without specific prior written permission.
|
|
15
|
+
|
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
17
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
18
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
19
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
20
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
21
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
22
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
23
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
24
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
#ifndef IRSDKCLIENT_H
|
|
29
|
+
#define IRSDKCLIENT_H
|
|
30
|
+
|
|
31
|
+
// A C++ wrapper around the irsdk calls that takes care of the details of maintaining a connection.
|
|
32
|
+
// reads out the data into a cache so you don't have to worry about timming
|
|
33
|
+
class irsdkClient
|
|
34
|
+
{
|
|
35
|
+
public:
|
|
36
|
+
// singleton
|
|
37
|
+
static irsdkClient& instance();
|
|
38
|
+
|
|
39
|
+
// wait for live data, or if a .ibt file is open
|
|
40
|
+
// then read the next line from the file.
|
|
41
|
+
bool waitForData(int timeoutMS = 16);
|
|
42
|
+
|
|
43
|
+
bool isConnected();
|
|
44
|
+
int getStatusID() { return m_statusID; }
|
|
45
|
+
|
|
46
|
+
int getVarIdx(const char*name);
|
|
47
|
+
|
|
48
|
+
// what is the base type of the data
|
|
49
|
+
// returns irsdk_VarType as int so we don't depend on irsdk_defines.h
|
|
50
|
+
int getVarType(int idx);
|
|
51
|
+
int getVarType(const char *name) { return getVarType(getVarIdx(name)); }
|
|
52
|
+
|
|
53
|
+
// how many elements in array, or 1 if not an array
|
|
54
|
+
int getVarCount(int idx);
|
|
55
|
+
int getVarCount(const char *name) { return getVarCount(getVarIdx(name)); }
|
|
56
|
+
|
|
57
|
+
// idx is the variables index, entry is the array offset, or 0 if not an array element
|
|
58
|
+
// will convert data to requested type
|
|
59
|
+
bool getVarBool(int idx, int entry = 0);
|
|
60
|
+
bool getVarBool(const char *name, int entry = 0) { return getVarBool(getVarIdx(name), entry); }
|
|
61
|
+
|
|
62
|
+
int getVarInt(int idx, int entry = 0);
|
|
63
|
+
int getVarInt(const char *name, int entry = 0) { return getVarInt(getVarIdx(name), entry); }
|
|
64
|
+
|
|
65
|
+
float getVarFloat(int idx, int entry = 0);
|
|
66
|
+
float getVarFloat(const char *name, int entry = 0) { return getVarFloat(getVarIdx(name), entry); }
|
|
67
|
+
|
|
68
|
+
double getVarDouble(int idx, int entry = 0);
|
|
69
|
+
double getVarDouble(const char *name, int entry = 0) { return getVarDouble(getVarIdx(name), entry); }
|
|
70
|
+
|
|
71
|
+
//---
|
|
72
|
+
|
|
73
|
+
// value that increments with each update to string
|
|
74
|
+
int getSessionCt() { return irsdk_getSessionInfoStrUpdate(); }
|
|
75
|
+
|
|
76
|
+
// has string changed since we last read any values from it
|
|
77
|
+
bool wasSessionStrUpdated() { return m_lastSessionCt != getSessionCt(); }
|
|
78
|
+
|
|
79
|
+
// pars string for individual value, 1 success, 0 failure, -n minimum buffer size
|
|
80
|
+
//****Note, this is a linear parser, so it is slow!
|
|
81
|
+
int getSessionStrVal(const char *path, char *val, int valLen);
|
|
82
|
+
|
|
83
|
+
// get the whole string
|
|
84
|
+
const char *getSessionStr();
|
|
85
|
+
|
|
86
|
+
protected:
|
|
87
|
+
|
|
88
|
+
irsdkClient()
|
|
89
|
+
: m_data(NULL)
|
|
90
|
+
, m_nData(0)
|
|
91
|
+
, m_statusID(0)
|
|
92
|
+
, m_lastSessionCt(-1)
|
|
93
|
+
{ }
|
|
94
|
+
|
|
95
|
+
~irsdkClient() { shutdown(); }
|
|
96
|
+
|
|
97
|
+
void shutdown();
|
|
98
|
+
|
|
99
|
+
char *m_data;
|
|
100
|
+
int m_nData;
|
|
101
|
+
int m_statusID;
|
|
102
|
+
|
|
103
|
+
int m_lastSessionCt;
|
|
104
|
+
|
|
105
|
+
static irsdkClient *m_instance;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
// helper class to keep track of our variables index
|
|
110
|
+
// Create a global instance of this and it will take care of the details for you.
|
|
111
|
+
class irsdkCVar
|
|
112
|
+
{
|
|
113
|
+
public:
|
|
114
|
+
irsdkCVar();
|
|
115
|
+
irsdkCVar(const char *name);
|
|
116
|
+
|
|
117
|
+
void setVarName(const char *name);
|
|
118
|
+
|
|
119
|
+
// returns irsdk_VarType as int so we don't depend on irsdk_defines.h
|
|
120
|
+
int getType();
|
|
121
|
+
int getCount();
|
|
122
|
+
bool isValid();
|
|
123
|
+
|
|
124
|
+
// entry is the array offset, or 0 if not an array element
|
|
125
|
+
bool getBool(int entry = 0);
|
|
126
|
+
int getInt(int entry = 0);
|
|
127
|
+
float getFloat(int entry = 0);
|
|
128
|
+
double getDouble(int entry = 0);
|
|
129
|
+
|
|
130
|
+
protected:
|
|
131
|
+
bool checkIdx();
|
|
132
|
+
|
|
133
|
+
static const int max_string = 32; //IRSDK_MAX_STRING
|
|
134
|
+
char m_name[max_string];
|
|
135
|
+
int m_idx;
|
|
136
|
+
int m_statusID;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
#endif // IRSDKCLIENT_H
|