Code: Select all
MAPLE_FOREACH_BEGIN(MAPLE_FUNC_CONTROLLER, cont_state_t, st)
if (st->buttons & CONT_DPAD_RIGHT)
I've read through all the old posts, even toastman's lengthy explanations, but I'm still not fully getting it here... ideally i'd write a class to do it for me (as that seems the easiest after a little initial work), but I still haven't learned classes yet.
I've also looked through siggler's SmashDC code, which I understand. It is as follows:
Code: Select all
void UpdateControls()
{
UpdateControlSet( 0 );
UpdateControlSet( 1 );
UpdateControlSet( 2 );
UpdateControlSet( 3 );
}
uint8 GetPortAddr( int port )
{
uint8 addr;
addr=maple_addr( port, 0 );
return addr;
}
int PadInPort( int port )
{
int retval=FALSE;
if ( maple_device_func( port, 0 ) == MAPLE_FUNC_CONTROLLER )
retval=TRUE;
return retval;
}
void UpdateControlSet( uint8 index )
{
uint8 mcont = 0;
cont_cond_t cond;
mcont = GetPortAddr( index );
if (cont_get_cond(mcont, &cond))
{
//printf("Error getting controller status\n");
}
else
{
if (!(cond.buttons & CONT_DPAD_UP))
ControlSets[index].Up=TRUE;
else ControlSets[index].Up=FALSE;
if (!(cond.buttons & CONT_DPAD_DOWN))
ControlSets[index].Down=TRUE;
else ControlSets[index].Down=FALSE;
if (!(cond.buttons & CONT_DPAD_LEFT))
ControlSets[index].Left=TRUE;
else ControlSets[index].Left=FALSE;
if (!(cond.buttons & CONT_DPAD_RIGHT))
ControlSets[index].Right=TRUE;
else ControlSets[index].Right=FALSE;
if (!(cond.buttons & CONT_Y))
ControlSets[index].ShootUp=TRUE;
else ControlSets[index].ShootUp=FALSE;
if (!(cond.buttons & CONT_A))
ControlSets[index].ShootDown=TRUE;
else ControlSets[index].ShootDown=FALSE;
if (!(cond.buttons & CONT_X))
ControlSets[index].ShootLeft=TRUE;
else ControlSets[index].ShootLeft=FALSE;
if (!(cond.buttons & CONT_B))
ControlSets[index].ShootRight=TRUE;
else ControlSets[index].ShootRight=FALSE;
if (!(cond.buttons & CONT_START))
{
ControlSets[index].Exit=TRUE;
}
else
ControlSets[index].Exit=FALSE;
}
}