Totally Confused with Dual Touch Andriod SDL 2.0

I though I had it ages ago, but always had bug. It seems like I’m doing it all wrong.

Seems like event.tfinger.fingerId; is return all sorts of numbers.
if you go with 0, it’s usually touch one, anything else is touch two, but not entirely.

Can anyone write me a simple code how it’s works?

while ( SDL_PollEvent(&event) )
{
if (event.type == SDL_QUIT)
{

	}

	if (event.type == SDL_KEYDOWN)
	{
		if (event.key.keysym.sym == SDLK_AC_BACK )
		{
			bGameRunning = false;
		}
	}

	//SDL_GetTouchFinger(0, 0);
	//

	//SDL_GetTouchFinger(0,index);

	//event.tfinger.SDL_TouchFingerEvent

	//SDL_GetTouchFinger(0,0);


	touch = event.tfinger.touchId;
	finger = event.tfinger.fingerId;

	sprintf(cTouch, "%3d", touch );
	sprintf(cFinger, "%3d", finger);
	

	if (event.tfinger.fingerId == 0)
	{
		iMouseX = Display0->GetScreenWidth() * event.tfinger.x;
		iMouseY = Display0->GetScreenHeight() * event.tfinger.y;

		bf1 = true;
		bf2 = false; // false
	}

	if (event.tfinger.fingerId == 1)
	{
		iMouseX2 = Display0->GetScreenWidth() * event.tfinger.x;
		iMouseY2 = Display0->GetScreenHeight() * event.tfinger.y;

		bf2 = true;
		bf1 = true;
	}

Are you actually checking for SDL_FINGERDOWN? It’s not shown here and
other events may interfere with your interpretation of the tfinger fields.

Jonny DOn Thu, Jan 2, 2014 at 6:39 AM, Timodor wrote:

I though I had it ages ago, but always had bug. It seems like I’m doing
it all wrong.

Seems like event.tfinger.fingerId; is return all sorts of numbers.
if you go with 0, it’s usually touch one, anything else is touch two, but
not entirely.

Can anyone write me a simple code how it’s works?

while ( SDL_PollEvent(&event) )
{
if (event.type == SDL_QUIT)
{

}

if (event.type == SDL_KEYDOWN)
{
if (event.key.keysym.sym == SDLK_AC_BACK )
{
bGameRunning = false;
}
}

//SDL_GetTouchFinger(0, 0);
//

//SDL_GetTouchFinger(0,index);

//event.tfinger.SDL_TouchFingerEvent

//SDL_GetTouchFinger(0,0);

touch = event.tfinger.touchId;
finger = event.tfinger.fingerId;

sprintf(cTouch, “%3d”, touch );
sprintf(cFinger, “%3d”, finger);

if (event.tfinger.fingerId == 0)
{
iMouseX = Display0->GetScreenWidth() * event.tfinger.x;
iMouseY = Display0->GetScreenHeight() * event.tfinger.y;

bf1 = true;
bf2 = false; // false
}

if (event.tfinger.fingerId == 1)
{
iMouseX2 = Display0->GetScreenWidth() * event.tfinger.x;
iMouseY2 = Display0->GetScreenHeight() * event.tfinger.y;

bf2 = true;
bf1 = true;
}


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Maybe I should be getting it inside the FINGER DOWN?

I tried that last night, i believe it was returning 0 and 1 values, but for some reason wasn’t working as it should.

if (event.type == SDL_FINGERDOWN)
{
bFingerDown = true;

		if (CheckButtonsSingle( iMouseX, iMouseY ) == true && bf1 == true)
		{
			if (bButton1 == true)
			{
				if ( Ball0->CheckColide( Player0->GetXpos(), Player0->GetYpos(), Player0->GetZpos() ) == true )
				{
					Ball0->KickBall(Player0->GetVector(0), Display0->GetMatrix(6), Player0->GetVector(2), 3 , Player0->GetPlayerNum() );
				}
			}
			else if (bButton2 == true)
			{
				if ( Ball0->CheckColide( Player0->GetXpos(), Player0->GetYpos(), Player0->GetZpos() ) == true )
				{
					Ball0->KickBall(Player0->GetVector(0), Display0->GetMatrix(6), Player0->GetVector(2), 4, Player0->GetPlayerNum() );
				}
			}
			else if (bButton3 == true && iSecondOld < Clock0->GetSeconds() ) // KICK
			{
				if ( Ball0->CheckColide( Player0->GetXpos(), Player0->GetYpos(), Player0->GetZpos() ) == true )
				{
					Ball0->KickBall(Player0->GetVector(0), Display0->GetMatrix(6), Player0->GetVector(2), 6 , Player0->GetPlayerNum() );
				}
			}
		}
		else if (CheckButtonsSingle( iMouseX2, iMouseY2 ) == true && bf2 == true)
		{
			if (bButton1 == true)
			{
				if ( Ball0->CheckColide( Player0->GetXpos(), Player0->GetYpos(), Player0->GetZpos() ) == true )
				{
					Ball0->KickBall(Player0->GetVector(0), Display0->GetMatrix(6), Player0->GetVector(2), 3 , Player0->GetPlayerNum() );
				}
			}
			else if (bButton2 == true)
			{
				if ( Ball0->CheckColide( Player0->GetXpos(), Player0->GetYpos(), Player0->GetZpos() ) == true )
				{
					Ball0->KickBall(Player0->GetVector(0), Display0->GetMatrix(6), Player0->GetVector(2), 4, Player0->GetPlayerNum() );
				}
			}
			else if (bButton3 == true && iSecondOld < Clock0->GetSeconds() ) // KICK
			{
				if ( Ball0->CheckColide( Player0->GetXpos(), Player0->GetYpos(), Player0->GetZpos() ) == true )
				{
					Ball0->KickBall(Player0->GetVector(0), Display0->GetMatrix(6), Player0->GetVector(2), 6 , Player0->GetPlayerNum() );
				}
			}
		}

		bButton1 = false;
		bButton2 = false;
		bButton3 = false;

if (event.type == SDL_FINGERUP)
{
if (event.tfinger.fingerId == 0 )
{
bf1 = false; // ture

			iMouseX = -1;
			iMouseY = -1;
		}
		if (event.tfinger.fingerId == 1 )
		{
			bf1 = true;
			bf2 = false; // false

			iMouseX2 = -1;
			iMouseY2 = -1;
		}

		//RESET MOUSEOLDS
		iMouseXold = -1;
		iMouseYold = -1;

			//bFingerDown = false;
	}

Everything tends to work fine if you press something on the left down side of the screen which is the movement buttons then use right side of the screen to as form touch screen look.

It seems like first touch is fine with left side of screen and second touch is fine with right side of the screen.
But when you reverse it, first touch is the right and second the left that’s where the issue occurs.

Tried all sorts of combinations, putting here and there.
I need a constant stream of events to get the x and the y

    SDL_Finger *arnold;
SDL_Finger *arnold2;


            arnold = SDL_GetTouchFinger(event.tfinger.touchId, 0);
	arnold2 = SDL_GetTouchFinger(event.tfinger.touchId, 1);

	if (arnold != NULL)
	{
		iMouseX = Display0->GetScreenWidth() * arnold->x;
		iMouseY = Display0->GetScreenHeight() * arnold->y;
	}

	if (arnold2 != NULL)
	{
		iMouseX2 = Display0->GetScreenWidth() * arnold2->x;
		iMouseY2 = Display0->GetScreenHeight() * arnold2->y;
	}

Code:

touch 2 does not register on 1 / 3 of the left side of the screen.
touch 1 register’s everywhere.

http://codepad.org/lSeMAERK

Here is the entire input events function. Hope someone can see the problem.