summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
diff options
context:
space:
mode:
authorScott Mansell <phiren@gmail.com>2015-07-06 07:57:31 +1200
committerScott Mansell <phiren@gmail.com>2015-07-07 16:59:10 +1200
commit6e969133f5e0f5fe9551a0ace39b242c5c3aac78 (patch)
treee15401e4cddbbc2106907a321d5b8860278dd732 /Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
parentbd196e8c71853ef83a47156117efc2ad581f4b38 (diff)
evdev: Delete rumble effects on the correct file descriptor.
Was using m_id insted of m_fd. Also re-arrange the code so rumble effects always get deleted instead of just on stop commands.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
index 9b31da73c4..6ee55ba0e5 100644
--- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
@@ -216,6 +216,12 @@ void evdevDevice::ForceFeedback::SetState(ControlState state)
// libevdev doesn't have nice helpers for forcefeedback
// we will use the file descriptors directly.
+ if (m_id != -1) // delete the previous effect (which also stops it)
+ {
+ ioctl(m_fd, EVIOCRMFF, m_id);
+ m_id = -1;
+ }
+
if (state > 0) // Upload and start an effect.
{
ff_effect effect;
@@ -260,9 +266,14 @@ void evdevDevice::ForceFeedback::SetState(ControlState state)
write(m_fd, (const void*) &play, sizeof(play));
}
- else if (m_id != -1) // delete the effect (which also stops it)
+}
+
+evdevDevice::ForceFeedback::~ForceFeedback()
+{
+ // delete the uploaded effect, so we don't leak it.
+ if (m_id != -1)
{
- ioctl(m_id, EVIOCRMFF, m_id);
+ ioctl(m_fd, EVIOCRMFF, m_id);
}
}