Skip to content
This repository has been archived by the owner on May 16, 2021. It is now read-only.

Commit

Permalink
Revert "Don't mark callback as __cdecl when"
Browse files Browse the repository at this point in the history
This reverts commit 5b48253.
  • Loading branch information
garbear committed Oct 20, 2016
1 parent 39751ff commit 1aee01f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 31 deletions.
60 changes: 30 additions & 30 deletions src/api/directinput/JoystickDirectInput.cpp
Expand Up @@ -35,36 +35,6 @@ using namespace JOYSTICK;
#define JOY_POV_SW (JOY_POVBACKWARD + JOY_POVLEFT) / 2
#define JOY_POV_NW (JOY_POVLEFT + JOY_POV_360) / 2

//-----------------------------------------------------------------------------
// Name: EnumObjectsCallback()
// Desc: Callback function for enumerating objects (axes, buttons, POVs) on a
// joystick. This function enables user interface elements for objects
// that are found to exist, and scales axes min/max values.
//-----------------------------------------------------------------------------
static BOOL EnumObjectsCallback(LPCDIDEVICEOBJECTINSTANCE pdidoi, LPVOID pContext)
{
LPDIRECTINPUTDEVICE8 pJoy = static_cast<LPDIRECTINPUTDEVICE8>(pContext);

// For axes that are returned, set the DIPROP_RANGE property for the
// enumerated axis in order to scale min/max values.
if (pdidoi->dwType & DIDFT_AXIS)
{
DIPROPRANGE diprg;
diprg.diph.dwSize = sizeof(DIPROPRANGE);
diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
diprg.diph.dwHow = DIPH_BYID;
diprg.diph.dwObj = pdidoi->dwType; // Specify the enumerated axis
diprg.lMin = AXIS_MIN;
diprg.lMax = AXIS_MAX;

// Set the range for the axis
HRESULT hr = pJoy->SetProperty(DIPROP_RANGE, &diprg.diph);
if (FAILED(hr))
esyslog("%s : Failed to set property on %s", __FUNCTION__, pdidoi->tszName);
}
return DIENUM_CONTINUE;
}

CJoystickDirectInput::CJoystickDirectInput(GUID deviceGuid,
LPDIRECTINPUTDEVICE8 joystickDevice,
const std::string& strName)
Expand Down Expand Up @@ -144,6 +114,36 @@ bool CJoystickDirectInput::Initialize(void)
return CJoystick::Initialize();
}

//-----------------------------------------------------------------------------
// Name: EnumObjectsCallback()
// Desc: Callback function for enumerating objects (axes, buttons, POVs) on a
// joystick. This function enables user interface elements for objects
// that are found to exist, and scales axes min/max values.
//-----------------------------------------------------------------------------
BOOL CALLBACK CJoystickDirectInput::EnumObjectsCallback(const DIDEVICEOBJECTINSTANCE* pdidoi, VOID* pContext)
{
LPDIRECTINPUTDEVICE8 pJoy = static_cast<LPDIRECTINPUTDEVICE8>(pContext);

// For axes that are returned, set the DIPROP_RANGE property for the
// enumerated axis in order to scale min/max values.
if (pdidoi->dwType & DIDFT_AXIS)
{
DIPROPRANGE diprg;
diprg.diph.dwSize = sizeof(DIPROPRANGE);
diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
diprg.diph.dwHow = DIPH_BYID;
diprg.diph.dwObj = pdidoi->dwType; // Specify the enumerated axis
diprg.lMin = AXIS_MIN;
diprg.lMax = AXIS_MAX;

// Set the range for the axis
HRESULT hr = pJoy->SetProperty(DIPROP_RANGE, &diprg.diph);
if (FAILED(hr))
esyslog("%s : Failed to set property on %s", __FUNCTION__, pdidoi->tszName);
}
return DIENUM_CONTINUE;
}

bool CJoystickDirectInput::ScanEvents(void)
{
HRESULT hr;
Expand Down
2 changes: 2 additions & 0 deletions src/api/directinput/JoystickDirectInput.h
Expand Up @@ -43,6 +43,8 @@ namespace JOYSTICK
virtual bool ScanEvents(void) override;

private:
static BOOL CALLBACK EnumObjectsCallback(const DIDEVICEOBJECTINSTANCE *pdidoi, VOID *pContext);

GUID m_deviceGuid;
LPDIRECTINPUTDEVICE8 m_joystickDevice;
};
Expand Down
2 changes: 1 addition & 1 deletion src/api/directinput/JoystickInterfaceDirectInput.h
Expand Up @@ -43,7 +43,7 @@ namespace JOYSTICK
private:
bool InitializeDirectInput(void);

static BOOL EnumJoysticksCallback(const DIDEVICEINSTANCE *pdidInstance, VOID *pContext);
static BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE *pdidInstance, VOID *pContext);
static bool IsXInputDevice(const GUID *pGuidProductFromDirectInput);
static HWND GetMainWindowHandle(void);
static BOOL CALLBACK EnumWindowsCallback(HWND hnd, LPARAM lParam);
Expand Down

0 comments on commit 1aee01f

Please sign in to comment.