Skip to content

Commit

Permalink
Merge pull request #95 from nasa/94-add-a-new-apem-device
Browse files Browse the repository at this point in the history
Add new APEM HC as IndustrialProducts4
  • Loading branch information
prkunz authored Sep 16, 2024
2 parents 15c27f7 + 7440c19 commit 7c3a3ac
Show file tree
Hide file tree
Showing 15 changed files with 265 additions and 0 deletions.
1 change: 1 addition & 0 deletions 3rdParty/trick/python/idf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def useFirstAvailableDevice(self):
trick.UsbGravis,
trick.UsbIndustrialProducts,
trick.UsbIndustrialProducts3,
trick.UsbIndustrialProducts4,
trick.UsbSaitek,
trick.UsbSaitekX52,
trick.UsbSaitekX56Stick,
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ set(SRC_IDF
source/idf/HagstromKEUSB36.cpp
source/idf/IndustrialProducts2.cpp
source/idf/IndustrialProducts3.cpp
source/idf/IndustrialProducts4.cpp
source/idf/IndustrialProducts.cpp
source/idf/Input.cpp
source/idf/InputDevice.cpp
Expand Down Expand Up @@ -81,6 +82,7 @@ set(SRC_IDF
source/idf/UsbHagstromKEUSB36FS.cpp
source/idf/UsbIndustrialProducts2.cpp
source/idf/UsbIndustrialProducts3.cpp
source/idf/UsbIndustrialProducts4.cpp
source/idf/UsbIndustrialProducts.cpp
source/idf/UsbKeyboard.cpp
source/idf/UsbMadCatz.cpp
Expand Down
3 changes: 3 additions & 0 deletions apps/configurator/configurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "idf/UsbIndustrialProducts.hh"
#include "idf/UsbIndustrialProducts2.hh"
#include "idf/UsbIndustrialProducts3.hh"
#include "idf/UsbIndustrialProducts4.hh"
#include "idf/UsbMadCatz.hh"
#include "idf/UsbSaitek.hh"
#include "idf/UsbSaitekX52.hh"
Expand Down Expand Up @@ -68,6 +69,7 @@ void run() {
idf::UsbIndustrialProducts industrialProducts;
idf::UsbIndustrialProducts2 industrialProducts2;
idf::UsbIndustrialProducts3 industrialProducts3;
idf::UsbIndustrialProducts4 industrialProducts4;
idf::UsbMadCatz madcatz;
idf::UsbSaitek saitek;
idf::UsbSaitekX52 saitekX52;
Expand All @@ -90,6 +92,7 @@ void run() {
devices.push_back(&industrialProducts);
devices.push_back(&industrialProducts2);
devices.push_back(&industrialProducts3);
devices.push_back(&industrialProducts4);
devices.push_back(&madcatz);
devices.push_back(&saitek);
devices.push_back(&saitekX52);
Expand Down
76 changes: 76 additions & 0 deletions include/idf/IndustrialProducts4.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
PURPOSE:
LIBRARY DEPENDENCIES: (
(idf/IndustrialProducts4.cpp)
)
*/

/**
* @trick_parse{everything}
* @trick_link_dependency{idf/IndustrialProducts4.cpp}
*/

#ifndef INDUSTRIAL_PRODUCTS4_HH
#define INDUSTRIAL_PRODUCTS4_HH

#include "idf/InputLayout.hh"
#include "idf/SingleInput.hh"

namespace idf {

/**
* %IndustrialProducts4 hand controller's input layout
*
* @author Philip Kunz
*/
class IndustrialProducts4 : public virtual InputLayout {

public:

/** constructor */
IndustrialProducts4();

/** destructor */
virtual ~IndustrialProducts4() {};

/** forward-backward pivoting */
SingleInput forwardBackwardPivot;

/** left-right pivoting */
SingleInput leftRightPivot;

/** twisting */
SingleInput twist;

/** the trigger button */
SingleInput trigger;

/** the grip button */
SingleInput grip;

/** the upper trigger of the switch */
SingleInput switchUp;

/** the lower trigger of the switch */
SingleInput switchDown;

/** up-down pivoting of the analog hat */
SingleInput hatUpDownPivot;

/** left-right pivoting of the analog hat */
SingleInput hatLeftRightPivot;

/** the upper button */
SingleInput button1;

/* the lower button*/
SingleInput button2;

protected:

virtual const std::vector<Configurable>& getConfigurables();
};

}

#endif
1 change: 1 addition & 0 deletions include/idf/PythonInterface.hh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include "idf/UsbIndustrialProducts.hh"
#include "idf/UsbIndustrialProducts2.hh"
#include "idf/UsbIndustrialProducts3.hh"
#include "idf/UsbIndustrialProducts4.hh"
#include "idf/UsbKeyboard.hh"
#include "idf/UsbSaitek.hh"
#include "idf/UsbSaitekX52.hh"
Expand Down
10 changes: 10 additions & 0 deletions include/idf/SingleCameraController.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ LIBRARY DEPENDENCIES: (
#include "idf/IndustrialProducts.hh"
#include "idf/IndustrialProducts2.hh"
#include "idf/IndustrialProducts3.hh"
#include "idf/IndustrialProducts4.hh"
#include "idf/SaitekX52.hh"
#include "idf/SaitekX56Stick.hh"
#include "idf/SaitekX56Throttle.hh"
Expand Down Expand Up @@ -211,6 +212,15 @@ class SingleCameraController : public CameraController {
*/
static SingleCameraController* createInstance(const IndustrialProducts3& industrialProducts3);

/**
* creates a new SingleCameraController mapped to @a industrialProducts4 using appropriate defaults
*
* @param industrialProducts4 the inputs to use in the default mapping
*
* @return a new industrialProducts4-based camera controller
*/
static SingleCameraController* createInstance(const IndustrialProducts4& industrialProducts4);

/**
* creates a new SingleCameraController mapped to @a SaitekX52 using appropriate defaults
*
Expand Down
10 changes: 10 additions & 0 deletions include/idf/SingleFlightController.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ LIBRARY DEPENDENCIES: (
#include "idf/IndustrialProducts.hh"
#include "idf/IndustrialProducts2.hh"
#include "idf/IndustrialProducts3.hh"
#include "idf/IndustrialProducts4.hh"
#include "idf/SaitekX52.hh"
#include "idf/SaitekX56Stick.hh"
#include "idf/SpaceBase.hh"
Expand Down Expand Up @@ -234,6 +235,15 @@ class SingleFlightController : public FlightController {
*/
static SingleFlightController* createInstance(const IndustrialProducts3& industrialProducts3);

/*
* creates a new SingleFlightController mapped to @a industrialProducts4 using appropriate defaults
*
* @param industrialProducts4 the inputs to use in the default mapping
*
* @return a new IndustrialProducts4-based flight controller
*/
static SingleFlightController* createInstance(const IndustrialProducts4& industrialProducts4);

/**
* creates a new SingleFlightController mapped to @a SaitekX52 using appropriate defaults
*
Expand Down
10 changes: 10 additions & 0 deletions include/idf/SingleRoboticsController.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ LIBRARY DEPENDENCIES: (
#include "idf/IndustrialProducts.hh"
#include "idf/IndustrialProducts2.hh"
#include "idf/IndustrialProducts3.hh"
#include "idf/IndustrialProducts4.hh"
#include "idf/SaitekX52.hh"
#include "idf/SaitekX56Stick.hh"
#include "idf/SpaceExplorer.hh"
Expand Down Expand Up @@ -297,6 +298,15 @@ class SingleRoboticsController : public RoboticsController {
*/
static SingleRoboticsController* createInstance(const IndustrialProducts3& industrialProducts3);

/*
* creates a new SingleRoboticsController mapped to @a industrialProducts4 using appropriate defaults
*
* @param industrialProducts4 the inputs to use in the default mapping
*
* @return a new industrialProducts4-based robotics controller
*/
static SingleRoboticsController* createInstance(const IndustrialProducts4& industrialProducts4);

/*
* creates a new SingleRoboticsController mapped to @a SaitekX52 using appropriate defaults
*
Expand Down
35 changes: 35 additions & 0 deletions include/idf/UsbIndustrialProducts4.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
PURPOSE:
LIBRARY DEPENDENCIES: (
(idf/UsbIndustrialProducts4.cpp)
)
*/

/**
* @trick_parse{everything}
* @trick_link_dependency{idf/UsbIndustrialProducts4.cpp}
*/

#ifndef USB_INDUSTRIAL_PRODUCTS4_HH
#define USB_INDUSTRIAL_PRODUCTS4_HH

#include "idf/UsbDevice.hh"
#include "idf/IndustrialProducts4.hh"

namespace idf {

/** USB IndustrialProducts joystick. Implementation of APEM HJRMCSAUYGLEA Hand Controller */
class UsbIndustrialProducts4 : public UsbDevice, public IndustrialProducts4 {

public:

/** constructor */
UsbIndustrialProducts4();

void decode(const std::vector<unsigned char>& data);

};

}

#endif
31 changes: 31 additions & 0 deletions source/idf/IndustrialProducts4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "idf/IndustrialProducts4.hh"

namespace idf {

IndustrialProducts4::IndustrialProducts4() :
forwardBackwardPivot(0, 1023, 512),
leftRightPivot(0, 1023, 512),
twist(0, 1023, 512),
trigger(0, 1),
grip(0,1),
switchUp(0, 1),
switchDown(0, 1),
hatUpDownPivot(0, 1023, 512),
hatLeftRightPivot(0, 1023, 512),
button1(0, 1),
button2(0, 1) {}

const std::vector<InputLayout::Configurable>& IndustrialProducts4::getConfigurables() {
static std::vector<Configurable> inputs;
if (inputs.empty()) {
append(InputLayout::getConfigurables(), inputs);
inputs.push_back(Configurable(forwardBackwardPivot, "Forward/Backward Pivot", "forwardBackwardPivot"));
inputs.push_back(Configurable(leftRightPivot, "Left/Right Pivot", "leftRightPivot"));
inputs.push_back(Configurable(twist, "Twist", "twist"));
inputs.push_back(Configurable(hatUpDownPivot, "Hat Up/Down Pivot", "hatUpDownPivot"));
inputs.push_back(Configurable(hatLeftRightPivot, "Hat Left/Right Pivot", "hatLeftRightPivot"));
}
return inputs;
}

}
15 changes: 15 additions & 0 deletions source/idf/SingleCameraController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,21 @@ SingleCameraController* SingleCameraController::createInstance(const IndustrialP
return controller;
}

SingleCameraController* SingleCameraController::createInstance(const IndustrialProducts4& industrialProducts) {
SingleCameraController *controller =
new SingleCameraController(
industrialProducts.twist,
industrialProducts.forwardBackwardPivot,
industrialProducts.leftRightPivot,
industrialProducts.hatUpDownPivot);

controller->pan.setInverted(true);
controller->tilt.setInverted(true);

return controller;
}


SingleCameraController* SingleCameraController::createInstance(const SaitekX52& saitekX52) {
CompositeInput* spin = new CompositeInput();
spin->addInput(saitekX52.toggle1);
Expand Down
20 changes: 20 additions & 0 deletions source/idf/SingleFlightController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,26 @@ SingleFlightController* SingleFlightController::createInstance(const IndustrialP
return controller;
}

SingleFlightController* SingleFlightController::createInstance(const IndustrialProducts4& industrialProducts) {
CompositeInput* z = new CompositeInput();
z->addInput(industrialProducts.switchUp);
z->addInput(industrialProducts.switchDown, -1);

SingleFlightController *controller =
new SingleFlightController(
industrialProducts.leftRightPivot,
industrialProducts.forwardBackwardPivot,
industrialProducts.twist,
industrialProducts.hatUpDownPivot,
industrialProducts.hatLeftRightPivot,
*z);

controller->pitch.setInverted(true);
controller->yaw.setInverted(true);
controller->y.setInverted(true);

return controller;
}

SingleFlightController* SingleFlightController::createInstance(const SaitekX52& saitekX52) {
CompositeInput* z = new CompositeInput();
Expand Down
25 changes: 25 additions & 0 deletions source/idf/SingleRoboticsController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,31 @@ SingleRoboticsController* SingleRoboticsController::createInstance(const Industr
return controller;
}

SingleRoboticsController* SingleRoboticsController::createInstance(const IndustrialProducts4& industrialProducts) {
CompositeInput* z = new CompositeInput();
z->addInput(industrialProducts.switchUp);
z->addInput(industrialProducts.switchDown, -1);

SingleRoboticsController *controller =
new SingleRoboticsController(
industrialProducts.leftRightPivot,
industrialProducts.forwardBackwardPivot,
industrialProducts.twist,
industrialProducts.hatUpDownPivot,
industrialProducts.hatLeftRightPivot,
*z,
industrialProducts.trigger,
industrialProducts.button1);

controller->pitch.setInverted(true);
controller->yaw.setInverted(true);
controller->y.setInverted(true);

controller->rateMode.setToggle(true);

return controller;
}

SingleRoboticsController* SingleRoboticsController::createInstance(const SaitekX52& saitekX52) {
CompositeInput* z = new CompositeInput();
z->addInput(saitekX52.buttonA);
Expand Down
1 change: 1 addition & 0 deletions source/idf/UsbDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ UsbDevice::UsbDevice(const std::string& id, unsigned length) :
identifications["Industrial Products"].push_back(Identification(0x068E, 0x002E, 0));
identifications["Industrial Products 2"].push_back(Identification(0x068E, 0x0019, 0));
identifications["Industrial Products 3"].push_back(Identification(0x068E, 0x0026, 0));
identifications["Industrial Products 4"].push_back(Identification(0x068E, 0x0177, 0));
identifications["Playstation 3 Controller"].push_back(Identification(0x054C, 0x0268, 0));
identifications["Playstation 4 Controller"].push_back(Identification(0x054C, 0x05C4, 0));
identifications["Playstation 4 Controller"].push_back(Identification(0x054C, 0x09CC, 3));
Expand Down
25 changes: 25 additions & 0 deletions source/idf/UsbIndustrialProducts4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "idf/UsbIndustrialProducts4.hh"

namespace idf {

UsbIndustrialProducts4::UsbIndustrialProducts4() :
UsbDevice("Industrial Products 4", 11) {}

void UsbIndustrialProducts4::decode(const std::vector<unsigned char>& data) {
leftRightPivot.setValue(((unsigned)data[1]) << 8 | data[0]);
forwardBackwardPivot.setValue(((unsigned)data[3]) << 8 | data[2]);
twist.setValue(((unsigned)data[5]) << 8 | data[4]);

hatLeftRightPivot.setValue(((unsigned)data[7]) << 8 | data[6]);
hatUpDownPivot.setValue(((unsigned)data[9]) << 8 | data[8]);

trigger.setValue(data[10] & 1);
grip.setValue(data[10] >> 1 & 1);
switchUp.setValue(data[10] >> 2 & 1);
switchDown.setValue(data[10] >> 3 & 1);
button1.setValue(data[10] >> 4 & 1);
button2.setValue(data[10] >> 5 & 1);

}

}

0 comments on commit 7c3a3ac

Please sign in to comment.