Problems with Vibration.

BIOS, Controllers, Memory Cards, Serial I/O, Parallel I/O, etc.
Post Reply
User avatar
MihaiGamerXD
Active PSXDEV User
Active PSXDEV User
Posts: 38
Joined: Mar 09, 2019
I am a: Programmer
PlayStation Model: SCPH-1001

Problems with Vibration.

Post by MihaiGamerXD » December 8th, 2020, 3:30 am

Hi all, I have a problem with vibration and I don't understand how it works, the vibration is not working anymore, my controller doesn't vibrate anymore, I'm sure that I'm wrong at my code and I don't know how to fix. Can you help me please?

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: Ok nevermind, it now worked by setting the default vibBuff values to 255, but doesn't work by pressing a button. I still need to find a solution to work with vibration by pressing a button.

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests