Mark Sibly 7 年之前
父節點
當前提交
c4d4cb2c1c
共有 1 個文件被更改,包括 8 次插入2 次删除
  1. 8 2
      bananas/joystick/joystick.monkey2

+ 8 - 2
bananas/joystick/joystick.monkey2

@@ -8,10 +8,16 @@ Using std..
 Using mojo..
 
 Class MyWindow Extends Window
+	
+	Field _joystick0:JoystickDevice
+	Field _joystick1:JoystickDevice
 
 	Method New()
 		Super.New( "Joystick test",640,480 )
 		
+		_joystick0=JoystickDevice.Open( 0 )
+		_joystick1=JoystickDevice.Open( 1 )
+		
 		JoystickDevice.JoystickAdded+=Lambda( index:Int )
 			Print "Joystick added: index="+index
 		End
@@ -26,10 +32,10 @@ Class MyWindow Extends Window
 	
 		App.RequestRender()
 	
-		canvas.DrawText( "NumJoysticks="+JoystickDevice.NumJoysticks(),0,0 )
+		canvas.DrawText( "NumJoysticks="+JoystickDevice.NumJoysticks()+", joystick0.Attached="+_joystick0?.Attached+", joystick1.Attached="+_joystick1?.Attached,0,0 )
 		
 		For Local i:=0 Until 4
-		
+			
 			Local joy:=JoystickDevice.Open( i )
 			If Not joy Exit