15 sprintf_s(msg, 199,
"Joystick::EnumJoysticksCallback {%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}",
16 pdidInstance->guidInstance.Data1, pdidInstance->guidInstance.Data2, pdidInstance->guidInstance.Data3,
17 pdidInstance->guidInstance.Data4[0], pdidInstance->guidInstance.Data4[1], pdidInstance->guidInstance.Data4[2], pdidInstance->guidInstance.Data4[3],
18 pdidInstance->guidInstance.Data4[4], pdidInstance->guidInstance.Data4[5], pdidInstance->guidInstance.Data4[6], pdidInstance->guidInstance.Data4[7]);
24 joystick->
guids.push_back(pdidInstance->guidInstance);
26 return DIENUM_CONTINUE;
46 if (pdidoi->dwType & DIDFT_AXIS)
49 diprg.diph.dwSize =
sizeof(DIPROPRANGE);
50 diprg.diph.dwHeaderSize =
sizeof(DIPROPHEADER);
51 diprg.diph.dwHow = DIPH_BYID;
52 diprg.diph.dwObj = pdidoi->dwType;
53 for (UINT i = 0; i < joystick->
config->
axes.size(); i++)
55 if ((joystick->
config->
axes[i].index == 0 && pdidoi->guidType == GUID_XAxis) ||
56 (joystick->
config->
axes[i].index == 1 && pdidoi->guidType == GUID_YAxis) ||
57 (joystick->
config->
axes[i].index == 2 && pdidoi->guidType == GUID_ZAxis) ||
58 (joystick->
config->
axes[i].index == 3 && pdidoi->guidType == GUID_RxAxis) ||
59 (joystick->
config->
axes[i].index == 4 && pdidoi->guidType == GUID_RyAxis) ||
60 (joystick->
config->
axes[i].index == 5 && pdidoi->guidType == GUID_RzAxis))
66 sprintf_s(msg, 99,
"Joystick::EnumObjectsCallback Configured %S with range %i to %i", pdidoi->tszName, diprg.lMin, diprg.lMax);
70 if (FAILED(hr = joystick->
g_pJoystick->SetProperty(DIPROP_RANGE, &diprg.diph)))
77 return DIENUM_CONTINUE;
82 sprintf_s(msg, 99,
"Joystick::EnumObjectsCallback Unused %S", pdidoi->tszName);
86 return DIENUM_CONTINUE;
107 for (UINT i = 0; i <
guids.size(); i++)
134 if (FAILED(hr =
g_pJoystick->SetDataFormat(&c_dfDIJoystick)))
143 if (FAILED(hr =
g_pJoystick->SetCooperativeLevel(NULL, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND)))
151 sprintf_s(msg, 199,
"Joystick::EnumObjectsCallback {%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}",
169 RtlZeroMemory(&
jsOld,
sizeof(DIJOYSTATE));
217 if (FAILED(hr =
g_pJoystick->GetDeviceState(
sizeof(DIJOYSTATE), &js)))
225 for (UINT i = 0; i <
config->
axes.size(); i++)
229 case 0:
axes.at(0) =
static_cast<float>(js.lX);
231 case 1:
axes.at(1) =
static_cast<float>(js.lY);
233 case 2:
axes.at(2) =
static_cast<float>(js.lZ);
235 case 3:
axes.at(3) =
static_cast<float>(js.lRx);
237 case 4:
axes.at(4) =
static_cast<float>(js.lRy);
239 case 5:
axes.at(5) =
static_cast<float>(js.lRz);
241 case 6:
axes.at(6) =
static_cast<float>(js.rglSlider[0]);
243 case 7:
axes.at(7) =
static_cast<float>(js.rglSlider[1]);
263 if (button->
onPress == (js.rgbButtons[button->
index] > 0))
293 assert(axis <
axes.size());
294 return axes.at(axis);
299 assert(button >= 0 && button < 32);
300 return jsOld.rgbButtons[button] > 0;
305 assert(pov >= 0 && pov < 4);
306 return jsOld.rgdwPOV[pov];
void AppendCommands(std::vector< Command > *commands)
okay, the portable keyboard numbers don't work like the outside keypad because the outside keypad is ...
std::vector< GUID > guids
bool GetButton(int) const
std::vector< float > axes
void FrameMove(float fElapsed)
static BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE *pdidInstance, VOID *pContext)
LPDIRECTINPUTDEVICE8 g_pJoystick
void Log(const char *msg, Level level=Info, int errorCode=0)
These have to be in this order.
void Initialize(Logger *logger, JoystickConfig *config, Bus *prmBus, LPDIRECTINPUT8 g_pDI)
std::vector< Button > buttons
static BOOL CALLBACK EnumObjectsCallback(const DIDEVICEOBJECTINSTANCE *pdidoi, VOID *pContext)