Skip to content
This repository was archived by the owner on Nov 4, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/brl/gametarget.monkey
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ Class BBGameDelegate Abstract
Method RenderGame:Void() Abstract
Method KeyEvent:Void( event:Int,data:Int ) Abstract
Method MouseEvent:Void( event:Int,data:Int,x:Float,y:Float ) Abstract
Method TouchEvent:Void( event:Int,data:Int,x:Float,y:Float ) Abstract
Method TouchEvent:Void( event:Int,data:Int,x:Float,y:Float,force:Float,maximumPossibleForce:Float) Abstract
Method TouchEvent:Void( event:Int,data:Int,x:Float,y:Float) Abstract
Method MotionEvent:Void( event:Int,data:Int,x:Float,y:Float,z:Float ) Abstract
Method DiscardGraphics:Void() Abstract
End
Expand Down
8 changes: 4 additions & 4 deletions modules/brl/native/gametarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class BBGameDelegate : public Object{
virtual void RenderGame(){}
virtual void KeyEvent( int event,int data ){}
virtual void MouseEvent( int event,int data,Float x,Float y ){}
virtual void TouchEvent( int event,int data,Float x,Float y ){}
virtual void TouchEvent( int event,int data,Float x,Float y,Float force, Float maximumPossibleForce){}
virtual void MotionEvent( int event,int data,Float x,Float y,Float z ){}
virtual void DiscardGraphics(){}
};
Expand Down Expand Up @@ -87,7 +87,7 @@ class BBGame{
virtual void RenderGame();
virtual void KeyEvent( int ev,int data );
virtual void MouseEvent( int ev,int data,float x,float y );
virtual void TouchEvent( int ev,int data,float x,float y );
virtual void TouchEvent( int ev,int data,float x,float y,float force,float maximumPossibleForce );
virtual void MotionEvent( int ev,int data,float x,float y,float z );
virtual void DiscardGraphics();

Expand Down Expand Up @@ -372,12 +372,12 @@ void BBGame::MouseEvent( int ev,int data,float x,float y ){
gc_collect();
}

void BBGame::TouchEvent( int ev,int data,float x,float y ){
void BBGame::TouchEvent( int ev,int data,float x,float y,float force, float maximumPossibleForce ){

if( !_started ) return;

try{
_delegate->TouchEvent( ev,data,x,y );
_delegate->TouchEvent( ev,data,x,y,force,maximumPossibleForce );
}catch( ThrowableObject *ex ){
Die( ex );
}
Expand Down
8 changes: 6 additions & 2 deletions modules/mojo/app.monkey
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,14 @@ Class GameDelegate Extends BBGameDelegate
_input.MouseEvent event,data,x,y
End

Method TouchEvent:Void( event:Int,data:Int,x:Float,y:Float )
_input.TouchEvent event,data,x,y
Method TouchEvent:Void( event:Int,data:Int,x:Float,y:Float, force:Float, maximumPossibleForce:Float )
_input.TouchEvent event,data,x,y,force,maximumPossibleForce
End

Method TouchEvent:Void( event:Int,data:Int,x:Float,y:Float )
TouchEvent(event,data,x,y,0,0)
End

Method MotionEvent:Void( event:Int,data:Int,x:Float,y:Float,z:Float )
_input.MotionEvent event,data,x,y,z
End
Expand Down
8 changes: 8 additions & 0 deletions modules/mojo/input.monkey
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ Function TouchY#( index=0 )
Return device.TouchY( index )
End

Function TouchForce#( index=0 )
Return device.TouchForce( index )
End

Function TouchMaximumPossibleForce#( index= 0)
Return device.TouchMaximumPossibleForce( index )
End

Function TouchDown( index=0 )
Return device.KeyDown( KEY_TOUCH0+index )
End
Expand Down
17 changes: 16 additions & 1 deletion modules/mojo/inputdevice.monkey
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ Class InputDevice
If index>=0 And index<32 Return _touchY[index]
Return 0
End

Method TouchForce#( index )
If index>=0 And index<32 Return _touchForce[index]
Return 0
End

Method TouchMaximumPossibleForce#( index )
If index>=0 And index<32 Return _touchMaximumPossibleForce[index]
Return 0
End

Method AccelX#()
Return _accelX
Expand Down Expand Up @@ -155,19 +165,22 @@ Class InputDevice
_touchY[0]=y
End

Method TouchEvent:Void( event:Int,data:Int,x:Float,y:Float )
Method TouchEvent:Void( event:Int,data:Int,x:Float,y:Float, force:Float = 0.0, maximumPossibleForce:Float = 0.0 )
Select event
Case BBGameEvent.TouchDown
KeyEvent BBGameEvent.KeyDown,KEY_TOUCH0+data
Case BBGameEvent.TouchUp
KeyEvent BBGameEvent.KeyUp,KEY_TOUCH0+data
_touchForce[data] = 0
Return
Case BBGameEvent.TouchMove
Default
Return
End
_touchX[data]=x
_touchY[data]=y
_touchForce[data] = force
_touchMaximumPossibleForce[data] = maximumPossibleForce
If data=0
_mouseX=x
_mouseY=y
Expand Down Expand Up @@ -228,6 +241,8 @@ Private
Field _mouseY:Float
Field _touchX:Float[32]
Field _touchY:Float[32]
Field _touchForce:Float[32]
Field _touchMaximumPossibleForce:Float[32]
Field _accelX:Float
Field _accelY:Float
Field _accelZ:Float
Expand Down
9 changes: 7 additions & 2 deletions targets/ios/modules/native/iosgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,13 @@ void BBIosGame::TouchesEvent( UIEvent *event ){
CGPoint p=[touch locationInView:view];
p.x*=scaleFactor;
p.y*=scaleFactor;

TouchEvent( ev,pid,p.x,p.y );

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) {
TouchEvent( ev,pid,p.x,p.y, _touches[pid].force, _touches[pid].maximumPossibleForce );
} else {
TouchEvent( ev,pid,p.x,p.y, 0, 0 );
}
}
}
}
Expand Down