diff options
| author | Scott Mansell <phiren@gmail.com> | 2015-07-13 12:40:38 +1200 |
|---|---|---|
| committer | Scott Mansell <phiren@gmail.com> | 2015-07-13 12:40:38 +1200 |
| commit | dc25277a2f0fb175b865ed1cd87fecc83ae1e5d0 (patch) | |
| tree | b16c3fa537a52a6b638eb2b3849f22f0eb716441 /Source/Core/InputCommon | |
| parent | b30ae1b9f8a49b0b19e2802ce4f91f6505cd0682 (diff) | |
| parent | 87e19f1c190719bd1280eb94bcdf372caca5287b (diff) | |
Merge branch 'stable' into 'master'
Diffstat (limited to 'Source/Core/InputCommon')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp | 15 | ||||
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/evdev/evdev.h | 1 |
2 files changed, 14 insertions, 2 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp index 75384393b6..25fa21a74b 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -217,6 +217,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; @@ -261,9 +267,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); } } diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h index c6c65e312d..5b3c23a466 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h @@ -52,6 +52,7 @@ private: public: std::string GetName() const override; ForceFeedback(u16 type, libevdev* dev) : m_type(type), m_id(-1) { m_fd = libevdev_get_fd(dev); } + ~ForceFeedback(); void SetState(ControlState state) override; private: const u16 m_type; |
