Go to the documentation of this file.
29 #include <linux/joystick.h>
37 offeringTopic(getProperty<std::string>(
"GamepadTopicName").getValue());
38 deviceName = getProperty<std::string>(
"GamepadDeviceName").getValue();
39 deviceEventName = getProperty<std::string>(
"GamepadForceFeedbackName").getValue();
48 getTopic<GamepadUnitListenerPrx>(getProperty<std::string>(
"GamepadTopicName").getValue());
54 std::unique_lock lock(mutex);
66 const IceUtil::Time age = IceUtil::Time::now() - dataTimestamp->toTime();
67 if (age.toMilliSeconds() < getProperty<int>(
"PublishTimeout").getValue())
71 topicPrx->reportGamepadState(deviceName, js.
name, data, dataTimestamp);
77 <<
"No new signal from gamepad for " << age.toMilliSecondsDouble()
78 <<
" milliseconds. Not sending data. Timeout: "
79 << getProperty<int>(
"PublishTimeout").getValue() <<
" ms";
99 if (js.
open(deviceName, deviceEventName))
132 while (readTask->isRunning())
138 ARMARX_WARNING <<
"failed to read gamepad data - trying to reconnect";
147 std::unique_lock lock(mutex);
153 float axisFactor = 1.0f / 32768.f;
155 data.leftStickY = js.
axis[0] * axisFactor;
156 data.leftStickX = js.
axis[1] * axisFactor;
157 data.rightStickX = js.
axis[3] * axisFactor;
158 data.rightStickY = js.
axis[4] * axisFactor;
159 data.dPadX = js.
axis[7] * axisFactor;
160 data.dPadY = js.
axis[6] * axisFactor;
161 data.leftTrigger = js.
axis[2] * axisFactor;
162 data.rightTrigger = js.
axis[5] * axisFactor;
179 <<
" left x (float): " << data.leftStickX
180 <<
" right trigger: " << data.rightTrigger;
bool open(std::string const &deviceName, std::string const &deviceEventName)
void onDisconnectComponent() override
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
void onExitComponent() override
void vibrate(const ::Ice::Current &=::Ice::emptyCurrent) override
void executeEffect(int gain=100, const int nTimes=1)
std::vector< bool > buttonsPressed
std::vector< int16_t > axis
void onConnectComponent() override
armarx::core::time::DateTime Time
const std::string & to_string(const std::string &s)
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
void onInitComponent() override
void offeringTopic(const std::string &name)
Registers a topic for retrival after initialization.
SpamFilterDataPtr deactivateSpam(float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const
disables the logging for the current line for the given amount of seconds.
bool openGamepadConnection()
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
This file offers overloads of toIce() and fromIce() functions for STL container types.