Skip to content

Commit

Permalink
Merge pull request #97 from nasa/96-add-daco-device
Browse files Browse the repository at this point in the history
add daco THC device
  • Loading branch information
prkunz authored Jan 30, 2025
2 parents 7c3a3ac + 95af45c commit 0152784
Show file tree
Hide file tree
Showing 15 changed files with 225 additions and 1 deletion.
1 change: 1 addition & 0 deletions 3rdParty/trick/python/idf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def useFirstAvailableDevice(self):
# loop through all supported devices
for device in [
trick.UsbChProPedals,
trick.UsbDacoThc,
trick.UsbDualShock3,
trick.UsbDualShock4,
trick.UsbExtreme3dPro,
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ set(SRC_IDF
source/idf/CompositeInput.cpp
source/idf/CompositeRoboticsController.cpp
source/idf/Controller.cpp
source/idf/DacoThc.cpp
source/idf/Deadbandable.cpp
source/idf/Deadband.cpp
source/idf/DualShock3.cpp
Expand Down Expand Up @@ -72,6 +73,7 @@ set(SRC_IDF
source/idf/ThrustMasterBase.cpp
source/idf/ThrustMaster.cpp
source/idf/UsbChProPedals.cpp
source/idf/UsbDacoThc.cpp
source/idf/UsbDevice.cpp
source/idf/UsbDualShock3.cpp
source/idf/UsbDualShock4.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 @@ -8,6 +8,7 @@
#include "idf/SerialThrustMaster.hh"
#include "idf/SerialThrustMaster2.hh"
#include "idf/UsbDevice.hh"
#include "idf/UsbDacoThc.hh"
#include "idf/UsbChProPedals.hh"
#include "idf/UsbDualShock3.hh"
#include "idf/UsbDualShock4.hh"
Expand Down Expand Up @@ -62,6 +63,7 @@ void configure(idf::InputDevice& device) {

void run() {
idf::UsbChProPedals chProPedals;
idf::UsbDacoThc dacoThc;
idf::UsbDualShock3 dualShock3;
idf::UsbDualShock4 dualShock4;
idf::UsbExtreme3dPro extreme3dPro;
Expand All @@ -85,6 +87,7 @@ void run() {

std::vector<idf::UsbDevice*> devices;
devices.push_back(&chProPedals);
devices.push_back(&dacoThc);
devices.push_back(&dualShock3);
devices.push_back(&dualShock4);
devices.push_back(&extreme3dPro);
Expand Down
56 changes: 56 additions & 0 deletions include/idf/DacoThc.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
PURPOSE:
LIBRARY DEPENDENCIES: (
(idf/DacoThc.cpp)
)
*/

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

#ifndef DACO_THC_HH
#define DACO_THC_HH

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

namespace idf {

/**
* %DacoThc DF0201 3 Axes 5 Switch Controller input layout
*
* @author Philip Kunz
*/
class DacoThc : public virtual InputLayout {

public:

/** constructor */
DacoThc();

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

/** forward backward */
SingleInput forwardBackwardTranslation;

/** y axis */
SingleInput leftRightTranslation;

/** z axis */
SingleInput upDownTranslation;

/** switch */
SingleInput switch1;

protected:

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

};

} // namespace

#endif
1 change: 1 addition & 0 deletions include/idf/PythonInterface.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

// USB Devices
#include "idf/UsbChProPedals.hh"
#include "idf/UsbDacoThc.hh"
#include "idf/UsbDualShock3.hh"
#include "idf/UsbDualShock4.hh"
#include "idf/UsbExtreme3dPro.hh"
Expand Down
11 changes: 10 additions & 1 deletion include/idf/SingleCameraController.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ LIBRARY DEPENDENCIES: (
#include "idf/Input.hh"
#include "idf/CompositeInput.hh"

#include "idf/DacoThc.hh"
#include "idf/DualShock.hh"
#include "idf/Extreme3dPro.hh"
#include "idf/Gravis.hh"
Expand Down Expand Up @@ -248,7 +249,6 @@ class SingleCameraController : public CameraController {
*/
static SingleCameraController* createInstance(const SaitekX56Throttle& saitekX56Throttle);


/**
* creates a new SingleCameraController mapped to @a XBoxOne using appropriate defaults
*
Expand All @@ -257,6 +257,15 @@ class SingleCameraController : public CameraController {
* @return a new XBoxOne-based camera controller
*/
static SingleCameraController* createInstance(const XBoxOne& xBoxOne);

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

}
Expand Down
9 changes: 9 additions & 0 deletions include/idf/SingleFlightController.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ LIBRARY DEPENDENCIES: (
#include "idf/Input.hh"
#include "idf/CompositeInput.hh"

#include "idf/DacoThc.hh"
#include "idf/DualShock.hh"
#include "idf/Extreme3dPro.hh"
#include "idf/Gravis.hh"
Expand Down Expand Up @@ -271,6 +272,14 @@ class SingleFlightController : public FlightController {
*/
static SingleFlightController* createInstance(const XBoxOne& xBoxOne);

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

};

Expand Down
12 changes: 12 additions & 0 deletions include/idf/SingleRoboticsController.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ LIBRARY DEPENDENCIES: (
#include "idf/Input.hh"
#include "idf/CompositeInput.hh"

#include "idf/DacoThc.hh"
#include "idf/DualShock.hh"
#include "idf/Extreme3dPro.hh"
#include "idf/Gravis.hh"
Expand Down Expand Up @@ -333,6 +334,17 @@ class SingleRoboticsController : public RoboticsController {
* @return a new Er7Orion-based flight controller
*/
static SingleRoboticsController* createInstance(const Er7Orion& er7Orion);


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

};

}
Expand Down
35 changes: 35 additions & 0 deletions include/idf/UsbDacoThc.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
PURPOSE:
LIBRARY DEPENDENCIES: (
(idf/UsbDacoThc.cpp)
)
*/

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

#ifndef USB_DACO_THC_HH
#define USB_DACO_THC_HH

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

namespace idf {

/** USB DacoThc DF0201 3 Axis 5 Switch Controller */
class UsbDacoThc : public UsbDevice, public DacoThc {

public:

/* constructor */
UsbDacoThc();

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

};

} // namespace idf

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

namespace idf {

DacoThc::DacoThc() :
forwardBackwardTranslation(0, 65535, 32768),
leftRightTranslation(0, 65535, 32768),
upDownTranslation(0, 65535, 32768),
switch1(0, 1) {}

const std::vector<InputLayout::Configurable>& DacoThc::getConfigurables() {
static std::vector<Configurable> inputs;
if (inputs.empty()) {
append(InputLayout::getConfigurables(), inputs);
inputs.push_back(Configurable(forwardBackwardTranslation, "Forward/Backward Translation", "forwardBackwardTranslation"));
inputs.push_back(Configurable(leftRightTranslation, "Left/Right Translation", "leftRightTranslation"));
inputs.push_back(Configurable(upDownTranslation, "Up/Down Translation", "upDownTranslation"));
}
return inputs;
}

} // namespace idf
17 changes: 17 additions & 0 deletions source/idf/SingleCameraController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,21 @@ SingleCameraController* SingleCameraController::createInstance(const XBoxOne& xB
return controller;
}

SingleCameraController* SingleCameraController::createInstance(const DacoThc& dacoThc) {
SingleInput* dummyInput = new SingleInput(-1, 1);

SingleCameraController *controller =
new SingleCameraController(
dacoThc.leftRightTranslation,
dacoThc.leftRightTranslation,
*dummyInput,
dacoThc.forwardBackwardTranslation);

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

return controller;
}

}
20 changes: 20 additions & 0 deletions source/idf/SingleFlightController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,24 @@ SingleFlightController* SingleFlightController::createInstance(const XBoxOne& xB
return controller;
}

SingleFlightController* SingleFlightController::createInstance(const DacoThc& dacoThc) {
SingleInput* dummyInput = new SingleInput(-1, 1);

SingleFlightController *controller =
new SingleFlightController(
*dummyInput,
*dummyInput,
*dummyInput,
dacoThc.forwardBackwardTranslation,
dacoThc.leftRightTranslation,
dacoThc.upDownTranslation
);

controller->x.setInverted(true);
controller->y.setInverted(true);
controller->z.setInverted(true);

return controller;
}

}
20 changes: 20 additions & 0 deletions source/idf/SingleRoboticsController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,4 +491,24 @@ SingleRoboticsController* SingleRoboticsController::createInstance(const Er7Orio
return controller;
}

SingleRoboticsController* SingleRoboticsController::createInstance(const DacoThc& dacoThc) {
SingleInput* dummyInput = new SingleInput(-1, 1);

SingleRoboticsController *controller =
new SingleRoboticsController(
*dummyInput,
*dummyInput,
*dummyInput,
dacoThc.forwardBackwardTranslation,
dacoThc.leftRightTranslation,
dacoThc.upDownTranslation,
*dummyInput,
dacoThc.switch1);

controller->x.setInverted(true);
controller->y.setInverted(true);
controller->z.setInverted(true);

return controller;
}
}
16 changes: 16 additions & 0 deletions source/idf/UsbDacoThc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "idf/UsbDacoThc.hh"

namespace idf {

UsbDacoThc::UsbDacoThc() :
UsbDevice("Daco THC DF0201", 7) {}

void UsbDacoThc::decode(const std::vector<unsigned char>& data) {
leftRightTranslation.setValue(((unsigned)data[1] << 8) | data[0]);
upDownTranslation.setValue(((unsigned)data[3] << 8) | data[2]);
forwardBackwardTranslation.setValue(((unsigned)data[5] << 8) | data[4]);

switch1.setValue(data[6] & 0x1);
}

} // namespace idf
1 change: 1 addition & 0 deletions source/idf/UsbDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ UsbDevice::UsbDevice(const std::string& id, unsigned length) :
}
}
identifications["Ch Pdo Pedals"].push_back(Identification(0x068E, 0x00F2, 0));
identifications["Daco THC DF0201"].push_back(Identification(0x1CFA, 0x0044, 0));
identifications["Extreme 3D Pro"].push_back(Identification(0x046D, 0xC215, 0));
identifications["Gravis"].push_back(Identification(0x0428, 0x4001, 0));
identifications["Hagstrom KE-USB36"].push_back(Identification(0x03EB, 0x3650, 0));
Expand Down

0 comments on commit 0152784

Please sign in to comment.