Skip to content
Snippets Groups Projects
Commit 74e730fe authored by Your Name's avatar Your Name
Browse files

Make force feedback optional

parent 08e51ccc
No related branches found
No related tags found
1 merge request!327Remove laser scanner features memory
......@@ -33,6 +33,7 @@ void GamepadUnit::onInitComponent()
ARMARX_TRACE;
offeringTopic(getProperty<std::string>("GamepadTopicName").getValue());
deviceName = getProperty<std::string>("GamepadDeviceName").getValue();
deviceEventName = getProperty<std::string>("GamepadForceFeedbackName").getValue();
readTask = new RunningTask<GamepadUnit>(this, &GamepadUnit::run, "GamepadUnit");
}
......@@ -83,7 +84,7 @@ void GamepadUnit::vibrate(const ::Ice::Current&)
bool GamepadUnit::openGamepadConnection()
{
if (js.open(deviceName))
if (js.open(deviceName, deviceEventName))
{
ARMARX_TRACE;
......
......@@ -53,6 +53,7 @@ namespace armarx
//defineOptionalProperty<std::string>("PropertyName", "DefaultValue", "Description");
defineOptionalProperty<std::string>("GamepadTopicName", "GamepadValues", "Name of the Gamepad Topic");
defineOptionalProperty<std::string>("GamepadDeviceName", "/dev/input/js2", "device that will be opened as a gamepad");
defineOptionalProperty<std::string>("GamepadForceFeedbackName", "", "device that will be used for force feedback, leave empty to disable");
defineOptionalProperty<int>("PublishTimeout", 2000, "In Milliseconds. Timeout after which the gamepad data is not published after, if no new data was read from the gamepad");
}
};
......@@ -119,6 +120,7 @@ namespace armarx
void run();
std::mutex mutex;
std::string deviceName;
std::string deviceEventName;
Joystick js;
GamepadData data;
TimestampVariantPtr dataTimestamp;
......
......@@ -52,13 +52,21 @@ namespace armarx
std::string name;
bool
open(std::string const& deviceName)
open(std::string const& deviceName, std::string const& deviceEventName)
{
fd = ::open(deviceName.c_str(), O_RDONLY);
fdEvent = ::open("/dev/input/event2", O_RDWR | O_CLOEXEC);
ARMARX_CHECK(fdEvent != -1);
if (!deviceEventName.empty())
{
ARMARX_INFO << "Force feedback enabled";
fdEvent = ::open(deviceEventName.c_str(), O_RDWR | O_CLOEXEC);
ARMARX_CHECK(fdEvent != -1);
} else {
ARMARX_INFO << "Force feedback disabled";
}
if (fd != -1)
{
// ARMARX_INFO << "before";
......@@ -113,8 +121,10 @@ namespace armarx
void
executeEffect(int gain = 100, const int nTimes = 1)
{
// this feature is disabled
if(fdEvent < 0) return;
// see https://docs.kernel.org/input/ff.html
ARMARX_CHECK(fdEvent >= 0);
// https://xnux.eu/devices/feature/vibrator.html
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment