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; }
static void* xinput_input_init(void) { XDEVICE_PREALLOC_TYPE types[] = { {XDEVICE_TYPE_GAMEPAD, 4}, {XDEVICE_TYPE_MEMORY_UNIT, 2} }; XInitDevices(sizeof(types) / sizeof(XDEVICE_PREALLOC_TYPE), types ); return (void*)-1; }
static bool xdk_joypad_init(void *data) { #ifdef _XBOX1 XInitDevices(0, NULL); #else unsigned autoconf_pad; for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++) xdk_joypad_autodetect_add(autoconf_pad); #endif (void)data; return true; }
//----------------------------------------------------------------------------- // Name: Create() // Desc: Create the app //----------------------------------------------------------------------------- HRESULT CXBApplication::Create() { HRESULT hr; // Create the Direct3D object // OUTPUT_DEBUG_STRING( "XBApp: Creating Direct3D...\n" ); if( NULL == ( m_pD3D = Direct3DCreate8(D3D_SDK_VERSION) ) ) { // OUTPUT_DEBUG_STRING( "XBApp: Unable to create Direct3D!\n" ); return E_FAIL; } // Create the device // OUTPUT_DEBUG_STRING( "XBApp: Creating the D3D device...\n" ); if( FAILED( hr = m_pD3D->CreateDevice( 0, D3DDEVTYPE_HAL, NULL, D3DCREATE_HARDWARE_VERTEXPROCESSING, &m_d3dpp, &m_pd3dDevice ) ) ) { // OUTPUT_DEBUG_STRING( "XBApp: Could not create D3D device!\n" ); return hr; } // Allow global access to the device g_pd3dDevice = m_pd3dDevice; // Store pointers to the depth and back buffers m_pd3dDevice->GetDepthStencilSurface( &m_pDepthBuffer ); m_pd3dDevice->GetBackBuffer( 0, 0, &m_pBackBuffer ); // Initialize core peripheral port support. Note: If these parameters // are 0 and NULL, respectively, then the default number and types of // controllers will be initialized. XInitDevices( m_dwNumInputDeviceTypes, m_InputDeviceTypes ); // Initialize the app's device-dependent objects // OUTPUT_DEBUG_STRING( "XBApp: Initializing the app...\n" ); if( FAILED( hr = Initialize() ) ) { // OUTPUT_DEBUG_STRING( "XBApp: Call to Initialize() failed!\n" ); return hr; } 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; }
/* =========== 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(); }