damanloox Posted October 17, 2020 Report Share Posted October 17, 2020 Could somebody please post an example of reading controller button status (eg. which button is pressed) in assembly...? Quote Link to comment Share on other sites More sharing options...
KaosEngineer Posted October 18, 2020 Report Share Posted October 18, 2020 Not in assembly language but an example in C is available here - https://xbdev.net/tuts/subpages/prt8/index.php Quote Link to comment Share on other sites More sharing options...
damanloox Posted October 18, 2020 Author Report Share Posted October 18, 2020 thanks but... I'm looking for assembly specifically... Quote Link to comment Share on other sites More sharing options...
feudalnate Posted October 18, 2020 Report Share Posted October 18, 2020 (edited) Can you expand on your reasoning a bit? Are you wanting to get device packets during arbitrary execution? Are you avoiding kernel calls? The Xbox doesn't store controller states in memory, you must request and poll peripheral states every time you want to check (SMBus->MCPX (southbridge)->USB hub (controller ports 0-4)->controller (also a USB hub)->port 0). If you want to utilize kernel driver calls and you're not compiling against the XTL then you're going to need to lookup the function addresses and the lookup must be dynamic every time because of the differing kernel versions on the Xbox. If you want to avoid the kernel then you can check how the devs that wrote the cromwell BIOS managed talking to the southbridge/USB host controller/USB devices (fairly certain they wrote multiple drivers) This is bare minimum to fetch controller states with the kernel #include <xtl.h> void WaitAnyControllerStateChange(XINPUT_STATE* ControllerState) { int Changed = 0; //Setup controller input XDEVICE_PREALLOC_TYPE DeviceTypes[] = { {XDEVICE_TYPE_GAMEPAD, 4} }; //4 = polling on all ports XInitDevices(sizeof(DeviceTypes) / sizeof(XDEVICE_PREALLOC_TYPE), DeviceTypes); //init device stack Sleep(500); //have to sleep, it takes almost half a second to initialize the XInput library.. //open handles to each port HANDLE Controllers[4]; Controllers[0] = XInputOpen(XDEVICE_TYPE_GAMEPAD, XDEVICE_PORT0, XDEVICE_NO_SLOT, 0); Controllers[1] = XInputOpen(XDEVICE_TYPE_GAMEPAD, XDEVICE_PORT1, XDEVICE_NO_SLOT, 0); Controllers[2] = XInputOpen(XDEVICE_TYPE_GAMEPAD, XDEVICE_PORT2, XDEVICE_NO_SLOT, 0); Controllers[3] = XInputOpen(XDEVICE_TYPE_GAMEPAD, XDEVICE_PORT3, XDEVICE_NO_SLOT, 0); DWORD Insertions = 0; DWORD Removals = 0; while(1) { if (XGetDeviceChanges(XDEVICE_TYPE_GAMEPAD, &Insertions, &Removals)) //check connection state changes { //something changed, refresh controller handles for(int i = 0; i < 4; i++) { if (Controllers[i] != 0) XInputClose(Controllers[i]); //close any current handles (system doesnt dealloc them itself) } //open new handles Controllers[0] = XInputOpen(XDEVICE_TYPE_GAMEPAD, XDEVICE_PORT0, XDEVICE_NO_SLOT, 0); Controllers[1] = XInputOpen(XDEVICE_TYPE_GAMEPAD, XDEVICE_PORT1, XDEVICE_NO_SLOT, 0); Controllers[2] = XInputOpen(XDEVICE_TYPE_GAMEPAD, XDEVICE_PORT2, XDEVICE_NO_SLOT, 0); Controllers[3] = XInputOpen(XDEVICE_TYPE_GAMEPAD, XDEVICE_PORT3, XDEVICE_NO_SLOT, 0); } //poll controller states on all ports for(int i = 0; i < 4; i++) { if (Controllers[i] != 0) //check bad handle { if (XInputGetState(Controllers[i], ControllerState) == ERROR_SUCCESS) //check input state changes { Changed = 1; break; //something changed, return state } } } if (Changed) break; } } void main() { XINPUT_STATE ControllerState = { 0 }; WaitAnyControllerStateChange(&ControllerState); /* process state data... */ } No one is going to be able to give you some quick code to poll controller state because it's not a simple thing to do Edited October 18, 2020 by feudalnate Quote Link to comment Share on other sites More sharing options...
damanloox Posted October 21, 2020 Author Report Share Posted October 21, 2020 > No one is going to be able to give you some quick code to poll controller state because it's not a simple thing to do That's what I was afraid of Thanks. I wanted to see if there's an "easy" way of including controller status in bios "patcher" (one that enables xiso) to allow startup of different dashboards (based on button pressed). I know there are applications for that - just wanted to avoid long chains of applications being started. I'll have a look at cromwell sources but I have a feeling it's not going to be.. worth it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.