static void *xdk_input_init(void) { xdk_input_t *xdk = (xdk_input_t*)calloc(1, sizeof(*xdk)); if (!xdk) return NULL; #ifdef _XBOX1 XInitDevices(0, NULL); xdk->dwDeviceMask = XGetDevices(XDEVICE_TYPE_GAMEPAD); //Check the device status switch(XGetDeviceEnumerationStatus()) { case XDEVICE_ENUMERATION_IDLE: RARCH_LOG("Input state status: XDEVICE_ENUMERATION_IDLE\n"); break; case XDEVICE_ENUMERATION_BUSY: RARCH_LOG("Input state status: XDEVICE_ENUMERATION_BUSY\n"); break; } while(XGetDeviceEnumerationStatus() == XDEVICE_ENUMERATION_BUSY) {} #endif return xdk; }
//----------------------------------------------------------------------------- // Name: XBInput_CreateGamepads() // Desc: Creates the gamepad devices //----------------------------------------------------------------------------- HRESULT XBInput_CreateGamepads( XBGAMEPAD** ppGamepads ) { // Get a mask of all currently available devices DWORD dwDeviceMask = XGetDevices( XDEVICE_TYPE_GAMEPAD ); // Open the devices for( DWORD i=0; i < XGetPortCount(); i++ ) { ZeroMemory( &g_InputStates[i], sizeof(XINPUT_STATE) ); ZeroMemory( &g_Gamepads[i], sizeof(XBGAMEPAD) ); if( dwDeviceMask & (1<<i) ) { // Get a handle to the device g_Gamepads[i].hDevice = XInputOpen( XDEVICE_TYPE_GAMEPAD, i, XDEVICE_NO_SLOT, NULL ); // Store capabilities of the device XInputGetCapabilities( g_Gamepads[i].hDevice, &g_Gamepads[i].caps ); } } // Created devices are kept global, but for those who prefer member // variables, they can get a pointer to the gamepads returned. if( ppGamepads ) (*ppGamepads) = g_Gamepads; return S_OK; }
static void* xinput_input_init(void) { XInitDevices(0, NULL); dwDeviceMask = XGetDevices(XDEVICE_TYPE_GAMEPAD); //Check the device status switch(XGetDeviceEnumerationStatus()) { case XDEVICE_ENUMERATION_IDLE: RARCH_LOG("Input state status: XDEVICE_ENUMERATION_IDLE\n"); break; case XDEVICE_ENUMERATION_BUSY: RARCH_LOG("Input state status: XDEVICE_ENUMERATION_BUSY\n"); break; } while(XGetDeviceEnumerationStatus() == XDEVICE_ENUMERATION_BUSY) {} return (void*)-1; }
static bool xdk_joypad_init(void) { unsigned autoconf_pad; #ifdef _XBOX1 XInitDevices(0, NULL); dwDeviceMask = XGetDevices(XDEVICE_TYPE_GAMEPAD); /* Check the device status. */ switch(XGetDeviceEnumerationStatus()) { case XDEVICE_ENUMERATION_IDLE: RARCH_LOG("Input state status: XDEVICE_ENUMERATION_IDLE\n"); break; case XDEVICE_ENUMERATION_BUSY: RARCH_LOG("Input state status: XDEVICE_ENUMERATION_BUSY\n"); break; } while(XGetDeviceEnumerationStatus() == XDEVICE_ENUMERATION_BUSY) {} #endif for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++) { strlcpy(g_settings.input.device_names[autoconf_pad], "XInput Controller", sizeof(g_settings.input.device_names[autoconf_pad])); /* TODO - implement VID/PID? */ input_config_autoconfigure_joypad(autoconf_pad, xdk_joypad_name(autoconf_pad), 0, 0, xdk_joypad.ident); } return true; }
void CXBoxMouse::Initialize(void *appData) { m_dwMousePort = XGetDevices( XDEVICE_TYPE_DEBUG_MOUSE ); // See if a mouse is attached and get a handle to it, if it is. for ( DWORD i = 0; i < XGetPortCount()*2; i++ ) { if ( ( m_hMouseDevice[i] == NULL ) && ( m_dwMousePort & anMouseBitmapTable[i] ) ) { // Get a handle to the device if (i < XGetPortCount()) { m_hMouseDevice[i] = XInputOpen( XDEVICE_TYPE_DEBUG_MOUSE, i, XDEVICE_NO_SLOT, NULL ); } else { m_hMouseDevice[i] = XInputOpen( XDEVICE_TYPE_DEBUG_MOUSE, i - XGetPortCount(), XDEVICE_BOTTOM_SLOT, NULL ); } CLog::Log(LOGINFO, "Found mouse on port %i", i); } } }
/* =========== IN_Init =========== */ void IN_Init( void ) { in_state = new inputstate_t; // Initialize support for 4 gamepads XDEVICE_PREALLOC_TYPE xdpt[] = { {XDEVICE_TYPE_GAMEPAD, 4} }; // Initialize the peripherals. We can only ever // call XInitDevices once, no matter what. static bool bInputInitialized = false; if (!bInputInitialized) XInitDevices( sizeof(xdpt) / sizeof(XDEVICE_PREALLOC_TYPE), xdpt ); bInputInitialized = true; // Zero all of our data, including handles memset(in_state->controllers, 0, sizeof(in_state->controllers)); // Find out the status of all gamepad ports, then open them IN_ProcessChanges( XGetDevices( XDEVICE_TYPE_GAMEPAD ), 0 ); IN_RumbleInit(); }