Skip to content
This repository was archived by the owner on Mar 18, 2022. It is now read-only.

Commit 0bf8801

Browse files
committed
Merge branch 'crossplatform'
2 parents b4b6a06 + 2120985 commit 0bf8801

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

GCAdapter.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,12 @@ NAN_METHOD(Request) {
132132
}
133133
adapter_thread_running.Set(true);
134134
adapter_thread = thread(Read);
135+
if (adapter_thread_running.TestAndClear()) {
136+
adapter_thread.join();
137+
}
135138
auto return_string = PollBytes(controller_payload);
136139
auto return_value = Nan::New<v8::String>(return_string).ToLocalChecked();
137-
140+
138141
info.GetReturnValue().Set(return_value);
139142
}
140143
NAN_METHOD(Stop) {
@@ -215,6 +218,9 @@ NAN_METHOD(Process) {
215218
}
216219
adapter_thread_running.Set(true);
217220
adapter_thread = thread(Read);
221+
if (adapter_thread_running.TestAndClear()) {
222+
adapter_thread.join();
223+
}
218224
Nan::HandleScope arr_scope;
219225
v8::Handle<v8::Array> arr = Nan::New<v8::Array>();
220226
for (int i = 0; i < 4; i++) {
@@ -229,6 +235,9 @@ NAN_METHOD(RawData) {
229235
}
230236
adapter_thread_running.Set(true);
231237
adapter_thread = thread(Read);
238+
if (adapter_thread_running.TestAndClear()) {
239+
adapter_thread.join();
240+
}
232241
stringstream return_value;
233242
return_value << "[";
234243
for (int i = 0; i < 10; i++) {

binding.gyp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
{
22
"targets": [
33
{
4-
"link_settings": {
5-
"libraries":["../lib/libusb-1.0.lib"]
6-
},
4+
"conditions": [
5+
["OS=='win'",{
6+
"link_settings": {
7+
"libraries":["../lib/libusb-1.0.lib"]
8+
}
9+
}],
10+
["OS=='linux'", {
11+
"libraries": ["<!@(pkg-config --libs --cflags libusb-1.0)"]
12+
}]
13+
],
714
"include_dirs": [
815
"<!(node -e \"require('nan')\")",
916
"include"

0 commit comments

Comments
 (0)