Page 1 of 1

finger event (?)

Posted: Tue Jan 03, 2023 8:17 am
by AZJIO
I wanted to make events for the movement of the fingers up, down, right, left, but this does not work. Is this procedure only for specific tasks?

Code: Select all

Procedure RenderFrame()
	Static Finger = -1
	
	If ExamineTouchScreen()
		
		For i = 0 To 4
			If TouchScreenPushed(i) And Finger = -1
				Finger = i
				Break
			EndIf
		Next
		If Finger <> -1 And TouchScreenPushed(Finger)
			If TouchDeltaX(Finger) > 0
				Debug "+x"
				ChangeMonth(1)
			ElseIf TouchDeltaX(Finger) < 0
				Debug "-x"
				ChangeMonth(0)
			EndIf
			If TouchDeltaY(Finger) > 0
				Debug "+y"
				ChangeMonth(1)
			ElseIf TouchDeltaY(Finger) < 0
				Debug "-y"
				ChangeMonth(0)
			EndIf
		Else
			Finger = -1
		EndIf
	EndIf
EndProcedure 

BindEvent(#PB_Event_RenderFrame, @RenderFrame())

Re: finger event (?)

Posted: Tue Jan 03, 2023 1:41 pm
by plouf
first try online demo
https://www.spiderbasic.com/showcase/on ... creen.html

this works ? (works in my phone)

Re: finger event (?)

Posted: Wed Jan 04, 2023 4:24 am
by AZJIO
plouf wrote: Tue Jan 03, 2023 1:41 pm this works ?
does not work (I have version 5.1)

Re: finger event (?)

Posted: Wed Jan 04, 2023 2:48 pm
by plouf
android 5.1 ?
tricky since the "documented" absolute minimun...

Re: finger event (?)

Posted: Wed Jan 04, 2023 2:57 pm
by useful
Here is the simplest template, which shows that there is a response as stated for 5 simultaneous touches.
But I couldn't get anything without screen, and I didn't even hope to.
If it were possible, at least it would be mentioned in documentation and examples.
Tested on Android 5.1 MEIZU M3S.
Ie all this as well as many other 2d games with sprites.
p.s. And even on Android 4.2.2 works, but catches only 1 (one) touch.
p.p.s. And on Android 11go and BQ5031G only 2(two).
So in addition to the version of the OS affects the sensitivity of the equipment.

Code: Select all

EnableExplicit
#Desktop    = 0
Global DW   = 0
Global DH   = 0
Declare EventSD()
Declare EventRF()
ExamineDesktops()
DW = DesktopWidth(#Desktop)
DH = DesktopHeight(#Desktop)
OpenScreen(DW,DH,-1,"TestTS")
BindEvent(#PB_Event_SizeDesktop, @EventSD())
BindEvent(#PB_Event_RenderFrame, @EventRF())
FlipBuffers()
Procedure EventSD()
  DW = DesktopWidth(#Desktop)
  DH = DesktopHeight(#Desktop)
  ResizeScreen(DW,DH)
EndProcedure
Procedure EventRF()
  ExamineTouchScreen()
  ClearDebugOutput()
  Debug "Tsp0 " + Str(TouchScreenPushed(0))
  Debug "Tsp1 " + Str(TouchScreenPushed(1))
  Debug "Tsp2 " + Str(TouchScreenPushed(2))
  Debug "Tsp3 " + Str(TouchScreenPushed(3))
  Debug "Tsp4 " + Str(TouchScreenPushed(4))
  FlipBuffers()
EndProcedure