Skip to content

Commit

Permalink
Merge pull request #7688 from jordan-woyak/evdev-improve
Browse files Browse the repository at this point in the history
ControllerInterface: evdev: Cleanups and effect processing fixes.
  • Loading branch information
Helios747 committed Feb 3, 2019
2 parents d11ee96 + 6cc8775 commit e913073
Show file tree
Hide file tree
Showing 4 changed files with 259 additions and 141 deletions.
18 changes: 11 additions & 7 deletions Source/Core/InputCommon/ControllerInterface/Device.h
Expand Up @@ -16,13 +16,17 @@ typedef double ControlState;

namespace ciface
{
// 100Hz which homebrew docs very roughly imply is within WiiMote normal
// range, used for periodic haptic effects though often ignored by devices
// TODO: Make this configurable.
constexpr int RUMBLE_PERIOD_MS = 10;
// This needs to be at least as long as the longest rumble that might ever be played.
// Too short and it's going to stop in the middle of a long effect.
// Infinite values are invalid for ramp effects and probably not sensible.
constexpr int RUMBLE_LENGTH_MS = 1000 * 10;

namespace Core
{
//
// Device
//
// A device class
//
class Device
{
public:
Expand Down Expand Up @@ -163,5 +167,5 @@ class DeviceContainer
mutable std::mutex m_devices_mutex;
std::vector<std::shared_ptr<Device>> m_devices;
};
}
}
} // namespace Core
} // namespace ciface
Expand Up @@ -13,14 +13,6 @@ namespace ciface
{
namespace ForceFeedback
{
// 100Hz which homebrew docs very roughly imply is within WiiMote normal
// range, used for periodic haptic effects though often ignored by devices
constexpr int RUMBLE_PERIOD = DI_SECONDS / 100;
// This needs to be at least as long as the longest rumble that might ever be played.
// Too short and it's going to stop in the middle of a long effect.
// "INFINITE" is invalid for ramp effects and probably not sensible.
constexpr int RUMBLE_LENGTH_MAX = DI_SECONDS * 10;

// Template instantiation:
template class ForceFeedbackDevice::TypedForce<DICONSTANTFORCE>;
template class ForceFeedbackDevice::TypedForce<DIRAMPFORCE>;
Expand Down Expand Up @@ -96,7 +88,7 @@ bool ForceFeedbackDevice::InitForceFeedback(const LPDIRECTINPUTDEVICE8 device, i
DIEFFECT eff{};
eff.dwSize = sizeof(eff);
eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
eff.dwDuration = RUMBLE_LENGTH_MAX;
eff.dwDuration = DI_SECONDS / 1000 * RUMBLE_LENGTH_MS;
eff.dwSamplePeriod = 0;
eff.dwGain = DI_FFNOMINALMAX;
eff.dwTriggerButton = DIEB_NOTRIGGER;
Expand All @@ -113,10 +105,9 @@ bool ForceFeedbackDevice::InitForceFeedback(const LPDIRECTINPUTDEVICE8 device, i
diRF.lStart = diRF.lEnd = 0;
DIPERIODIC diPE{};
diPE.dwMagnitude = 0;
// Is it sensible to have a zero-offset?
diPE.lOffset = 0;
diPE.dwPhase = 0;
diPE.dwPeriod = RUMBLE_PERIOD;
diPE.dwPeriod = DI_SECONDS / 1000 * RUMBLE_PERIOD_MS;

for (auto& f : force_type_names)
{
Expand Down

0 comments on commit e913073

Please sign in to comment.