mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-12 06:39:14 +01:00
DirectInput: Use more than 8 bits of precision on axis inputs.
This commit is contained in:
parent
0ca9accd8b
commit
a7c45fb49e
@ -3,6 +3,7 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <limits>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@ -121,13 +122,13 @@ Joystick::Joystick(/*const LPCDIDEVICEINSTANCE lpddi, */ const LPDIRECTINPUTDEVI
|
|||||||
for (unsigned int offset = 0; offset < DIJOFS_BUTTON(0) / sizeof(LONG); ++offset)
|
for (unsigned int offset = 0; offset < DIJOFS_BUTTON(0) / sizeof(LONG); ++offset)
|
||||||
{
|
{
|
||||||
range.diph.dwObj = offset * sizeof(LONG);
|
range.diph.dwObj = offset * sizeof(LONG);
|
||||||
// try to set some nice power of 2 values (128) to match the GameCube controls
|
// Try to set a range with 16 bits of precision:
|
||||||
range.lMin = -(1 << 7);
|
range.lMin = std::numeric_limits<s16>::min();
|
||||||
range.lMax = (1 << 7);
|
range.lMax = std::numeric_limits<s16>::max();
|
||||||
m_device->SetProperty(DIPROP_RANGE, &range.diph);
|
m_device->SetProperty(DIPROP_RANGE, &range.diph);
|
||||||
// but I guess not all devices support setting range
|
// Not all devices support setting DIPROP_RANGE so we must GetProperty right back.
|
||||||
// so I getproperty right afterward incase it didn't set.
|
// This also checks that the axis is present.
|
||||||
// This also checks that the axis is present
|
// Note: Even though not all devices support setting DIPROP_RANGE, some require it.
|
||||||
if (SUCCEEDED(m_device->GetProperty(DIPROP_RANGE, &range.diph)))
|
if (SUCCEEDED(m_device->GetProperty(DIPROP_RANGE, &range.diph)))
|
||||||
{
|
{
|
||||||
const LONG base = (range.lMin + range.lMax) / 2;
|
const LONG base = (range.lMin + range.lMax) / 2;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user