GLBasic forum

Main forum => GLBasic - en => Topic started by: Det on 2013-Mar-14

Title: Mousaxis on iPHONE
Post by: Det on 2013-Mar-14
Hi,
it seem's to me, I did not understand the mouse / touch behaviours in total, perhaps someone could point me to the right direction or has similar problems.

What I did was make a small testprogram for the iPad that should react to touches.

After I've learned that getmouscount will always deliver 16 (or should? there seems to be a bug when more than 5 fingers are placed? Anyway) and in a call Mousestate x,y,b1,b2 the b1 gives me the hint that this "finger" is "active" I came to the point that drives me nuts: Obviously I've got the chance to check whether I've got two finges places (need this, want to implement a "pinch"-gesture) my "swipe" does not work anylonger, without implementing "pinch" my "swipe works. My swipe uses the mouseaxis function.
I assume it is because of the checkroutine that always runs through 16 available mouses and asks for the button1. To do this I need to call "setactivemouse" prior to mousestate. But: This checkroutine is called in an endless loop. So I assume it's an timing / threading issue: I'm afraid the mousaxis-function is interrupted by the "check-function" to early to return an appropriate value.

Anyone else who has witnessed this problem?

Checker-Function:

Code (glbasic) Select

TYPE MOUSEDATA
x
y
b1
b2
xaxis
yaxis
ENDTYPE

TYPE MOUSEINFO
mockamouse=-1
numberofusedmice // Anzahl der Mäuse mit gedrücktemButton als limit der usedMice
usedmice[16] // Indize ins mousedata-array um werte zu kriegen
mousedata[16] AS MOUSEDATA // alle werte der gedrückten mäuse
ENDTYPE
LOCAL i

WHILE TRUE

getMice()



i=maus.numberofusedmice
IF i=2
// pinch, code dropped

       ELSE
// swipe, code dropped
       ENDIF
WEND

// ------------------------------------------------------------- //
// ---  GETMICE  ---
// ------------------------------------------------------------- //
FUNCTION getMice:
// Diese Variablen sind als LOCAL definiert:
//
LOCAL x1%,y1%,b1%,b2%, xs%, ys%

maus.numberofusedmice=0;
FOR x=0 TO GETMOUSECOUNT()-1

SETACTIVEMOUSE x
MOUSESTATE x1%,y1%,b1%,b2%

IF (b1=1)
maus.usedmice[maus.numberofusedmice]=x
maus.mousedata[x].x=x1
maus.mousedata[x].y=y1
maus.mousedata[x].b1=b1
maus.mousedata[x].b2=b2

INC maus.numberofusedmice, 1

ENDIF
NEXT
RETURN



ENDFUNCTION // GETMICE



Ideas anyone?
Thanx in advance
Det
Title: Re: Mousaxis on iPHONE
Post by: matchy on 2013-Mar-14
I think 5 is the limit on iPad and the issue is a over a year old.

http://www.glbasic.com/forum/index.php?topic=5586

(the forum search is your friend)
Title: Re: Mousaxis on iPHONE
Post by: Det on 2013-Mar-14
Yes, I read this, but as ist was over a year old I thought it was fixed. Anway:this is not the point, my problem is mixing mouseaxis and code for mousedetection
Title: Re: Mousaxis on iPHONE
Post by: matchy on 2013-Mar-14
I am unable to test or create iOS (until I downgrade my iPod from 6 to 5) but maus.mousedata[].xaxis is not in the code so I didn't realise.
Title: Re: Mousaxis on iPHONE
Post by: Det on 2013-Mar-14
Hi matchy,
thank's a lot for caring! Obviosly I stripped down my code too much (it was late yesterday  :().

But anyway: I figured it out by myself. The problem seems to be that mixing mouseaxis and mousestate in one loop is not that good an idea...

that code that did not work for me was:
Code (glbasic) Select

FUNCTION getMice:
// Diese Variablen sind als LOCAL definiert:
//
LOCAL x1%,y1%,b1%,b2%, xs%, ys%

maus.numberofusedmice=0;
FOR x=0 TO GETMOUSECOUNT()-1

SETACTIVEMOUSE x
MOUSESTATE x1%,y1%,b1%,b2%

IF (b1=1)
maus.usedmice[maus.numberofusedmice]=x
maus.mousedata[x].x=x1
maus.mousedata[x].y=y1
maus.mousedata[x].b1=b1
maus.mousedata[x].b2=b2
                        xs=MOUSEAXIS(0)
                        ys=MOUSEAXIS(1)
maus.mousedata[0].xaxis=xs
maus.mousedata[0].yaxis=ys
INC maus.numberofusedmice, 1

ENDIF
NEXT
RETURN



and this finally does the trick:
Code (glbasic) Select

FUNCTION getMice:
// Diese Variablen sind als LOCAL definiert:
//
LOCAL x1%,y1%,b1%,b2%, xs%, ys%

maus.numberofusedmice=0;
FOR x=0 TO GETMOUSECOUNT()-1

SETACTIVEMOUSE x
xs=MOUSEAXIS(0)
ys=MOUSEAXIS(1)
maus.mousedata[x].xaxis=xs
maus.mousedata[x].yaxis=ys
NEXT
FOR x=0 TO GETMOUSECOUNT()-1

SETACTIVEMOUSE x
MOUSESTATE x1%,y1%,b1%,b2%

maus.usedmice[maus.numberofusedmice]=x
maus.mousedata[x].x=x1
maus.mousedata[x].y=y1
maus.mousedata[x].b1=b1
maus.mousedata[x].b2=b2
IF (b1=1)
ConOut ( "x1: " + x1 + " xaxis: " + maus.mousedata[x].xaxis)
INC maus.numberofusedmice, 1
ENDIF
NEXT
RETURN



ENDFUNCTION // GETMICE