Code: Select all
void controller()
{
int ret = 0;
int set = 0;
int type = 0;
int i = 0;
int ds = 0;
ret = PadGetState(0);
switch(ret)
{
case PadStateDiscon:
break;
case PadStateFindPad:
set = 0;
for (i = 0; i < 100 || !set; i++)
{
VSync(0);
switch(PadGetState(0))
{
case PadStateStable:
type=PadInfoMode(0,InfoModeCurID,0);
if(type)
{
PadSetAct(0,vibBuff[0],vibBuffLen);
while(PadSetActAlign(0,align)==0)
for (ret = 0; ret < 6; ret++)
VSync(0);
}
set=1;
break;
}
}
break;
case PadStateStable:
if (PadSetActAlign(0,align))
ds = 1;
break;
}
pad = (PADTYPE*)padbuff[0];
if (pad->stat == 0)
{
if ((pad->type == 0x4) || (pad->type == 0x5) || (pad->type == 0x7))
{
if (!(pad->btn&PAD_UP))
{
if (pos_y > 0)
{
pos_y -= 4;
if ((pad->type == 0x7) || (pad->type == 0x5))
{
if (ds == 1)
*(u_char*)&vibBuff[0] = 50;
}
}
}
if (!(pad->btn&PAD_DOWN))
{
if (pos_y < 480-256)
{
pos_y += 4;
if ((pad->type == 0x7) || (pad->type == 0x5))
{
if (ds == 1)
*(u_char*)&vibBuff[0] = 50;
}
}
}
if (!(pad->btn&PAD_LEFT))
{
if (pos_x > 0)
{
pos_x -= 4;
if ((pad->type == 0x7) || (pad->type == 0x5))
{
if (ds == 1)
*(u_char*)&vibBuff[0] = 50;
}
}
}
if (!(pad->btn&PAD_RIGHT))
{
if (pos_x < 640-256)
{
pos_x += 4;
if ((pad->type == 0x7) || (pad->type == 0x5))
{
if (ds == 1)
*(u_char*)&vibBuff[0] = 50;
}
}
}
if (ds == 1)
PadSetAct(0,vibBuff[0],vibBuffLen);
}
}
}
Edit 2: Ah now I understand why doesn't work... Because I setted the vibBuffer value to 50 which is not working, but if I set to 255 it works. Well, sorry for disturbing.