Skip to content

Commit 7c3a3ac

Browse files
authored
Merge pull request #95 from nasa/94-add-a-new-apem-device
Add new APEM HC as IndustrialProducts4
2 parents 15c27f7 + 7440c19 commit 7c3a3ac

15 files changed

+265
-0
lines changed

3rdParty/trick/python/idf/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def useFirstAvailableDevice(self):
4646
trick.UsbGravis,
4747
trick.UsbIndustrialProducts,
4848
trick.UsbIndustrialProducts3,
49+
trick.UsbIndustrialProducts4,
4950
trick.UsbSaitek,
5051
trick.UsbSaitekX52,
5152
trick.UsbSaitekX56Stick,

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ set(SRC_IDF
3434
source/idf/HagstromKEUSB36.cpp
3535
source/idf/IndustrialProducts2.cpp
3636
source/idf/IndustrialProducts3.cpp
37+
source/idf/IndustrialProducts4.cpp
3738
source/idf/IndustrialProducts.cpp
3839
source/idf/Input.cpp
3940
source/idf/InputDevice.cpp
@@ -81,6 +82,7 @@ set(SRC_IDF
8182
source/idf/UsbHagstromKEUSB36FS.cpp
8283
source/idf/UsbIndustrialProducts2.cpp
8384
source/idf/UsbIndustrialProducts3.cpp
85+
source/idf/UsbIndustrialProducts4.cpp
8486
source/idf/UsbIndustrialProducts.cpp
8587
source/idf/UsbKeyboard.cpp
8688
source/idf/UsbMadCatz.cpp

apps/configurator/configurator.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "idf/UsbIndustrialProducts.hh"
1717
#include "idf/UsbIndustrialProducts2.hh"
1818
#include "idf/UsbIndustrialProducts3.hh"
19+
#include "idf/UsbIndustrialProducts4.hh"
1920
#include "idf/UsbMadCatz.hh"
2021
#include "idf/UsbSaitek.hh"
2122
#include "idf/UsbSaitekX52.hh"
@@ -68,6 +69,7 @@ void run() {
6869
idf::UsbIndustrialProducts industrialProducts;
6970
idf::UsbIndustrialProducts2 industrialProducts2;
7071
idf::UsbIndustrialProducts3 industrialProducts3;
72+
idf::UsbIndustrialProducts4 industrialProducts4;
7173
idf::UsbMadCatz madcatz;
7274
idf::UsbSaitek saitek;
7375
idf::UsbSaitekX52 saitekX52;
@@ -90,6 +92,7 @@ void run() {
9092
devices.push_back(&industrialProducts);
9193
devices.push_back(&industrialProducts2);
9294
devices.push_back(&industrialProducts3);
95+
devices.push_back(&industrialProducts4);
9396
devices.push_back(&madcatz);
9497
devices.push_back(&saitek);
9598
devices.push_back(&saitekX52);

include/idf/IndustrialProducts4.hh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
PURPOSE:
3+
LIBRARY DEPENDENCIES: (
4+
(idf/IndustrialProducts4.cpp)
5+
)
6+
*/
7+
8+
/**
9+
* @trick_parse{everything}
10+
* @trick_link_dependency{idf/IndustrialProducts4.cpp}
11+
*/
12+
13+
#ifndef INDUSTRIAL_PRODUCTS4_HH
14+
#define INDUSTRIAL_PRODUCTS4_HH
15+
16+
#include "idf/InputLayout.hh"
17+
#include "idf/SingleInput.hh"
18+
19+
namespace idf {
20+
21+
/**
22+
* %IndustrialProducts4 hand controller's input layout
23+
*
24+
* @author Philip Kunz
25+
*/
26+
class IndustrialProducts4 : public virtual InputLayout {
27+
28+
public:
29+
30+
/** constructor */
31+
IndustrialProducts4();
32+
33+
/** destructor */
34+
virtual ~IndustrialProducts4() {};
35+
36+
/** forward-backward pivoting */
37+
SingleInput forwardBackwardPivot;
38+
39+
/** left-right pivoting */
40+
SingleInput leftRightPivot;
41+
42+
/** twisting */
43+
SingleInput twist;
44+
45+
/** the trigger button */
46+
SingleInput trigger;
47+
48+
/** the grip button */
49+
SingleInput grip;
50+
51+
/** the upper trigger of the switch */
52+
SingleInput switchUp;
53+
54+
/** the lower trigger of the switch */
55+
SingleInput switchDown;
56+
57+
/** up-down pivoting of the analog hat */
58+
SingleInput hatUpDownPivot;
59+
60+
/** left-right pivoting of the analog hat */
61+
SingleInput hatLeftRightPivot;
62+
63+
/** the upper button */
64+
SingleInput button1;
65+
66+
/* the lower button*/
67+
SingleInput button2;
68+
69+
protected:
70+
71+
virtual const std::vector<Configurable>& getConfigurables();
72+
};
73+
74+
}
75+
76+
#endif

include/idf/PythonInterface.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include "idf/UsbIndustrialProducts.hh"
5858
#include "idf/UsbIndustrialProducts2.hh"
5959
#include "idf/UsbIndustrialProducts3.hh"
60+
#include "idf/UsbIndustrialProducts4.hh"
6061
#include "idf/UsbKeyboard.hh"
6162
#include "idf/UsbSaitek.hh"
6263
#include "idf/UsbSaitekX52.hh"

include/idf/SingleCameraController.hh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ LIBRARY DEPENDENCIES: (
2525
#include "idf/IndustrialProducts.hh"
2626
#include "idf/IndustrialProducts2.hh"
2727
#include "idf/IndustrialProducts3.hh"
28+
#include "idf/IndustrialProducts4.hh"
2829
#include "idf/SaitekX52.hh"
2930
#include "idf/SaitekX56Stick.hh"
3031
#include "idf/SaitekX56Throttle.hh"
@@ -211,6 +212,15 @@ class SingleCameraController : public CameraController {
211212
*/
212213
static SingleCameraController* createInstance(const IndustrialProducts3& industrialProducts3);
213214

215+
/**
216+
* creates a new SingleCameraController mapped to @a industrialProducts4 using appropriate defaults
217+
*
218+
* @param industrialProducts4 the inputs to use in the default mapping
219+
*
220+
* @return a new industrialProducts4-based camera controller
221+
*/
222+
static SingleCameraController* createInstance(const IndustrialProducts4& industrialProducts4);
223+
214224
/**
215225
* creates a new SingleCameraController mapped to @a SaitekX52 using appropriate defaults
216226
*

include/idf/SingleFlightController.hh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ LIBRARY DEPENDENCIES: (
2525
#include "idf/IndustrialProducts.hh"
2626
#include "idf/IndustrialProducts2.hh"
2727
#include "idf/IndustrialProducts3.hh"
28+
#include "idf/IndustrialProducts4.hh"
2829
#include "idf/SaitekX52.hh"
2930
#include "idf/SaitekX56Stick.hh"
3031
#include "idf/SpaceBase.hh"
@@ -234,6 +235,15 @@ class SingleFlightController : public FlightController {
234235
*/
235236
static SingleFlightController* createInstance(const IndustrialProducts3& industrialProducts3);
236237

238+
/*
239+
* creates a new SingleFlightController mapped to @a industrialProducts4 using appropriate defaults
240+
*
241+
* @param industrialProducts4 the inputs to use in the default mapping
242+
*
243+
* @return a new IndustrialProducts4-based flight controller
244+
*/
245+
static SingleFlightController* createInstance(const IndustrialProducts4& industrialProducts4);
246+
237247
/**
238248
* creates a new SingleFlightController mapped to @a SaitekX52 using appropriate defaults
239249
*

include/idf/SingleRoboticsController.hh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ LIBRARY DEPENDENCIES: (
2626
#include "idf/IndustrialProducts.hh"
2727
#include "idf/IndustrialProducts2.hh"
2828
#include "idf/IndustrialProducts3.hh"
29+
#include "idf/IndustrialProducts4.hh"
2930
#include "idf/SaitekX52.hh"
3031
#include "idf/SaitekX56Stick.hh"
3132
#include "idf/SpaceExplorer.hh"
@@ -297,6 +298,15 @@ class SingleRoboticsController : public RoboticsController {
297298
*/
298299
static SingleRoboticsController* createInstance(const IndustrialProducts3& industrialProducts3);
299300

301+
/*
302+
* creates a new SingleRoboticsController mapped to @a industrialProducts4 using appropriate defaults
303+
*
304+
* @param industrialProducts4 the inputs to use in the default mapping
305+
*
306+
* @return a new industrialProducts4-based robotics controller
307+
*/
308+
static SingleRoboticsController* createInstance(const IndustrialProducts4& industrialProducts4);
309+
300310
/*
301311
* creates a new SingleRoboticsController mapped to @a SaitekX52 using appropriate defaults
302312
*

include/idf/UsbIndustrialProducts4.hh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
PURPOSE:
3+
LIBRARY DEPENDENCIES: (
4+
(idf/UsbIndustrialProducts4.cpp)
5+
)
6+
*/
7+
8+
/**
9+
* @trick_parse{everything}
10+
* @trick_link_dependency{idf/UsbIndustrialProducts4.cpp}
11+
*/
12+
13+
#ifndef USB_INDUSTRIAL_PRODUCTS4_HH
14+
#define USB_INDUSTRIAL_PRODUCTS4_HH
15+
16+
#include "idf/UsbDevice.hh"
17+
#include "idf/IndustrialProducts4.hh"
18+
19+
namespace idf {
20+
21+
/** USB IndustrialProducts joystick. Implementation of APEM HJRMCSAUYGLEA Hand Controller */
22+
class UsbIndustrialProducts4 : public UsbDevice, public IndustrialProducts4 {
23+
24+
public:
25+
26+
/** constructor */
27+
UsbIndustrialProducts4();
28+
29+
void decode(const std::vector<unsigned char>& data);
30+
31+
};
32+
33+
}
34+
35+
#endif

source/idf/IndustrialProducts4.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "idf/IndustrialProducts4.hh"
2+
3+
namespace idf {
4+
5+
IndustrialProducts4::IndustrialProducts4() :
6+
forwardBackwardPivot(0, 1023, 512),
7+
leftRightPivot(0, 1023, 512),
8+
twist(0, 1023, 512),
9+
trigger(0, 1),
10+
grip(0,1),
11+
switchUp(0, 1),
12+
switchDown(0, 1),
13+
hatUpDownPivot(0, 1023, 512),
14+
hatLeftRightPivot(0, 1023, 512),
15+
button1(0, 1),
16+
button2(0, 1) {}
17+
18+
const std::vector<InputLayout::Configurable>& IndustrialProducts4::getConfigurables() {
19+
static std::vector<Configurable> inputs;
20+
if (inputs.empty()) {
21+
append(InputLayout::getConfigurables(), inputs);
22+
inputs.push_back(Configurable(forwardBackwardPivot, "Forward/Backward Pivot", "forwardBackwardPivot"));
23+
inputs.push_back(Configurable(leftRightPivot, "Left/Right Pivot", "leftRightPivot"));
24+
inputs.push_back(Configurable(twist, "Twist", "twist"));
25+
inputs.push_back(Configurable(hatUpDownPivot, "Hat Up/Down Pivot", "hatUpDownPivot"));
26+
inputs.push_back(Configurable(hatLeftRightPivot, "Hat Left/Right Pivot", "hatLeftRightPivot"));
27+
}
28+
return inputs;
29+
}
30+
31+
}

source/idf/SingleCameraController.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,21 @@ SingleCameraController* SingleCameraController::createInstance(const IndustrialP
191191
return controller;
192192
}
193193

194+
SingleCameraController* SingleCameraController::createInstance(const IndustrialProducts4& industrialProducts) {
195+
SingleCameraController *controller =
196+
new SingleCameraController(
197+
industrialProducts.twist,
198+
industrialProducts.forwardBackwardPivot,
199+
industrialProducts.leftRightPivot,
200+
industrialProducts.hatUpDownPivot);
201+
202+
controller->pan.setInverted(true);
203+
controller->tilt.setInverted(true);
204+
205+
return controller;
206+
}
207+
208+
194209
SingleCameraController* SingleCameraController::createInstance(const SaitekX52& saitekX52) {
195210
CompositeInput* spin = new CompositeInput();
196211
spin->addInput(saitekX52.toggle1);

source/idf/SingleFlightController.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,26 @@ SingleFlightController* SingleFlightController::createInstance(const IndustrialP
268268
return controller;
269269
}
270270

271+
SingleFlightController* SingleFlightController::createInstance(const IndustrialProducts4& industrialProducts) {
272+
CompositeInput* z = new CompositeInput();
273+
z->addInput(industrialProducts.switchUp);
274+
z->addInput(industrialProducts.switchDown, -1);
275+
276+
SingleFlightController *controller =
277+
new SingleFlightController(
278+
industrialProducts.leftRightPivot,
279+
industrialProducts.forwardBackwardPivot,
280+
industrialProducts.twist,
281+
industrialProducts.hatUpDownPivot,
282+
industrialProducts.hatLeftRightPivot,
283+
*z);
284+
285+
controller->pitch.setInverted(true);
286+
controller->yaw.setInverted(true);
287+
controller->y.setInverted(true);
288+
289+
return controller;
290+
}
271291

272292
SingleFlightController* SingleFlightController::createInstance(const SaitekX52& saitekX52) {
273293
CompositeInput* z = new CompositeInput();

source/idf/SingleRoboticsController.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,31 @@ SingleRoboticsController* SingleRoboticsController::createInstance(const Industr
411411
return controller;
412412
}
413413

414+
SingleRoboticsController* SingleRoboticsController::createInstance(const IndustrialProducts4& industrialProducts) {
415+
CompositeInput* z = new CompositeInput();
416+
z->addInput(industrialProducts.switchUp);
417+
z->addInput(industrialProducts.switchDown, -1);
418+
419+
SingleRoboticsController *controller =
420+
new SingleRoboticsController(
421+
industrialProducts.leftRightPivot,
422+
industrialProducts.forwardBackwardPivot,
423+
industrialProducts.twist,
424+
industrialProducts.hatUpDownPivot,
425+
industrialProducts.hatLeftRightPivot,
426+
*z,
427+
industrialProducts.trigger,
428+
industrialProducts.button1);
429+
430+
controller->pitch.setInverted(true);
431+
controller->yaw.setInverted(true);
432+
controller->y.setInverted(true);
433+
434+
controller->rateMode.setToggle(true);
435+
436+
return controller;
437+
}
438+
414439
SingleRoboticsController* SingleRoboticsController::createInstance(const SaitekX52& saitekX52) {
415440
CompositeInput* z = new CompositeInput();
416441
z->addInput(saitekX52.buttonA);

source/idf/UsbDevice.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ UsbDevice::UsbDevice(const std::string& id, unsigned length) :
3737
identifications["Industrial Products"].push_back(Identification(0x068E, 0x002E, 0));
3838
identifications["Industrial Products 2"].push_back(Identification(0x068E, 0x0019, 0));
3939
identifications["Industrial Products 3"].push_back(Identification(0x068E, 0x0026, 0));
40+
identifications["Industrial Products 4"].push_back(Identification(0x068E, 0x0177, 0));
4041
identifications["Playstation 3 Controller"].push_back(Identification(0x054C, 0x0268, 0));
4142
identifications["Playstation 4 Controller"].push_back(Identification(0x054C, 0x05C4, 0));
4243
identifications["Playstation 4 Controller"].push_back(Identification(0x054C, 0x09CC, 3));

source/idf/UsbIndustrialProducts4.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "idf/UsbIndustrialProducts4.hh"
2+
3+
namespace idf {
4+
5+
UsbIndustrialProducts4::UsbIndustrialProducts4() :
6+
UsbDevice("Industrial Products 4", 11) {}
7+
8+
void UsbIndustrialProducts4::decode(const std::vector<unsigned char>& data) {
9+
leftRightPivot.setValue(((unsigned)data[1]) << 8 | data[0]);
10+
forwardBackwardPivot.setValue(((unsigned)data[3]) << 8 | data[2]);
11+
twist.setValue(((unsigned)data[5]) << 8 | data[4]);
12+
13+
hatLeftRightPivot.setValue(((unsigned)data[7]) << 8 | data[6]);
14+
hatUpDownPivot.setValue(((unsigned)data[9]) << 8 | data[8]);
15+
16+
trigger.setValue(data[10] & 1);
17+
grip.setValue(data[10] >> 1 & 1);
18+
switchUp.setValue(data[10] >> 2 & 1);
19+
switchDown.setValue(data[10] >> 3 & 1);
20+
button1.setValue(data[10] >> 4 & 1);
21+
button2.setValue(data[10] >> 5 & 1);
22+
23+
}
24+
25+
}

0 commit comments

Comments
 (0)