void RefreshJoystickStatus(void) { unsigned char Index=0; bool Temp=false; NumberofJoysticks = EnumerateJoysticks(); for (Index=0;Index<NumberofJoysticks;Index++) Temp=InitJoyStick (Index); if (Right.DiDevice>(NumberofJoysticks-1)) Right.DiDevice=0; if (Left.DiDevice>(NumberofJoysticks-1)) Left.DiDevice=0; SetStickNumbers(Left.DiDevice,Right.DiDevice); if (NumberofJoysticks==0) //Use Mouse input if no Joysticks present { if (Left.UseMouse==3) Left.UseMouse=1; if (Right.UseMouse==3) Right.UseMouse=1; } return; }
InputEngineImpl(HWND hwnd) : m_hwnd(hwnd), m_bFocus(false) { // // Create the direct input object // #ifdef Dynamic_DInput m_hdinput = ::LoadLibrary("dinput.dll"); ZAssert(m_hdinput != NULL); PFNDirectInputCreate pfn = (PFNDirectInputCreate)::GetProcAddress(m_hdinput, "DirectInputCreateA"); ZAssert(pfn != NULL); DDCall(pfn( GetModuleHandle(NULL), DIRECTINPUT_VERSION, &m_pdi, NULL )); // // grab the address of a few dinput globals // // g_pdfDIMouse = (DIDATAFORMAT*)::GetProcAddress(m_hdinput, "c_dfDIMouse"); g_pdfDIMouse = (DIDATAFORMAT*)::GetProcAddress(m_hdinput, "c_dfDIMouse2"); // mdvalley: Mouse2 for more buttons ZAssert(g_pdfDIMouse != NULL); #else DDCall(DirectInputCreate( GetModuleHandle(NULL), DIRECTINPUT_VERSION, &m_pdi, NULL )); //DDCall(DirectInput8Create( // KG - Di8 update // GetModuleHandle(NULL), // DIRECTINPUT_VERSION, // IID_IDirectInput8, // (LPVOID*)&m_pdi, // NULL // )); // g_pdfDIMouse = &c_dfDIMouse; g_pdfDIMouse = &c_dfDIMouse2; // mdvalley: Mouse2 for more buttons #endif // // If we failed then exit the app // if (m_pdi == NULL) { ::MessageBox(NULL, "Error initializing DirectInput. Check your installation", "Error", MB_OK); _exit(0); } // // Enumerate the devices // EnumerateJoysticks(); }