Mark Sibly пре 8 година
родитељ
комит
065a71f7c1
2 измењених фајлова са 75 додато и 51 уклоњено
  1. 38 31
      modules/mojo/app/app.monkey2
  2. 37 20
      modules/mojo/input/touch.monkey2

+ 38 - 31
modules/mojo/app/app.monkey2

@@ -478,6 +478,8 @@ Class AppInstance
 	#end	
 	Method UpdateWindows()
 	
+		If _frozen Return
+	
 		Local render:=_requestRender
 		_requestRender=False
 		
@@ -552,6 +554,8 @@ Class AppInstance
 
 	Field _active:Bool
 	Field _activeWindow:Window
+
+	Field _frozen:Bool
 	
 	Field _keyView:View
 	Field _hoverView:View
@@ -1001,6 +1005,40 @@ Class AppInstance
 		
 			mojo.graphics.glutil.glGraphicsSeq+=1
 
+#if __TARGET__="ios"
+
+		Case SDL_APP_TERMINATING
+			'Terminate the app.
+			'Shut everything down before returning from this function.
+
+		Case SDL_APP_LOWMEMORY
+			'You will get this when your app is paused and iOS wants more memory.
+			'Release as much memory as possible.		
+
+		Case SDL_APP_WILLENTERBACKGROUND
+			'Prepare your app to go into the background. Stop loops, etc.
+			'This gets called when the user hits the home button, or gets a call.
+			Print "SDL_APP_WILLENTERBACKGROUND"
+			_frozen=True
+
+		Case SDL_APP_DIDENTERBACKGROUND
+			'This will get called if the user accepted whatever sent your app to the background.
+			'If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops.
+			'When you get this, you have 5 seconds to save all your state or the app will be terminated.
+			'Your app is NOT active at this point.
+
+		Case SDL_APP_WILLENTERFOREGROUND
+			'This call happens when your app is coming back to the foreground.
+			'Restore all your state here.
+
+		Case SDL_APP_DIDENTERFOREGROUND
+			'Restart your loops here.
+			'Your app is interactive and getting CPU again.
+			Print "SDL_APP_DIDENTERFOREGROUND"
+			RequestRender()
+			_frozen=False
+#Endif
+     
 		End
 			
 	End
@@ -1042,37 +1080,6 @@ Class AppInstance
 
 			End
 
-#if __TARGET__="ios"
-
-		Case SDL_APP_TERMINATING
-			'Terminate the app.
-			'Shut everything down before returning from this function.		
-			return 0
-		Case SDL_APP_LOWMEMORY
-			'You will get this when your app is paused and iOS wants more memory.
-			'Release as much memory as possible.		
-	        return 0
-		Case SDL_APP_WILLENTERBACKGROUND
-			'Prepare your app to go into the background. Stop loops, etc.
-			'This gets called when the user hits the home button, or gets a call.
-	        return 0
-		Case SDL_APP_DIDENTERBACKGROUND
-			'This will get called if the user accepted whatever sent your app to the background.
-			'If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops.
-			'When you get this, you have 5 seconds to save all your state or the app will be terminated.
-			'Your app is NOT active at this point.
-	        return 0
-		Case SDL_APP_WILLENTERFOREGROUND
-			'This call happens when your app is coming back to the foreground.
-			'Restore all your state here.
-	        return 0
-		Case SDL_APP_DIDENTERFOREGROUND
-			'Restart your loops here.
-			'Your app is interactive and getting CPU again.
-	        return 0
-
-#Endif
-	        
 		End
 		
 		Return 1

+ 37 - 20
modules/mojo/input/touch.monkey2

@@ -87,35 +87,51 @@ Class TouchDevice Extends InputDevice
 		
 			Local tevent:=Cast<SDL_TouchFingerEvent Ptr>( event )
 			
-			Local id:=tevent->fingerId
-			If id>=0 And id<10
-				_fingers[id].down=True
-				_fingers[id].pressed=True
-				_fingers[id].pressure=tevent->pressure
-				_fingers[id].location=EventLocation( tevent )
-			Endif
+			Local id:=-1
+			For Local i:=0 Until 10
+				If _fingers[i].down Continue
+				_fingers[i].id=tevent->fingerId
+				id=i
+				Exit
+			Next
+			If id=-1 Return
+			
+			_fingers[id].down=True
+			_fingers[id].pressed=True
+			_fingers[id].pressure=tevent->pressure
+			_fingers[id].location=EventLocation( tevent )
 		
 		Case SDL_FINGERUP
 		
 			Local tevent:=Cast<SDL_TouchFingerEvent Ptr>( event )
 			
-			Local id:=tevent->fingerId
-			If id>=0 And id<10
-				_fingers[id].down=False
-				_fingers[id].released=False
-				_fingers[id].pressure=0
-				_fingers[id].location=EventLocation( tevent )
-			Endif
+			Local id:=-1
+			For Local i:=0 Until 10
+				If Not _fingers[i].down Or _fingers[i].id<>tevent->fingerId Continue
+				id=i
+				Exit
+			Next
+			If id=-1 Return
+			
+			_fingers[id].down=False
+			_fingers[id].released=False
+			_fingers[id].pressure=0
+			_fingers[id].location=EventLocation( tevent )
 			
 		Case SDL_FINGERMOTION
 		
 			Local tevent:=Cast<SDL_TouchFingerEvent Ptr>( event )
 			
-			Local id:=tevent->fingerId
-			If id>=0 And id<10
-				_fingers[id].pressure=tevent->pressure
-				_fingers[id].location=EventLocation( tevent )
-			Endif
+			Local id:=-1
+			For Local i:=0 Until 10
+				If Not _fingers[i].down Or _fingers[i].id<>tevent->fingerId Continue
+				id=i
+				Exit
+			Next
+			If id=-1 Return
+			
+			_fingers[id].pressure=tevent->pressure
+			_fingers[id].location=EventLocation( tevent )
 		
 		End
 
@@ -124,10 +140,11 @@ Class TouchDevice Extends InputDevice
 	Private
 	
 	Struct FingerState
+		Field id:Int
 		Field down:Bool
 		Field pressed:Bool
 		Field released:Bool
-		Field pressure:FLoat
+		Field pressure:Float
 		Field location:Vec2i
 	End