2
0
Эх сурвалжийг харах

Implemented new factory-based Joystick driver framework.

woollybah 10 жил өмнө
parent
commit
d89faec40b
2 өөрчлөгдсөн 484 нэмэгдсэн , 254 устгасан
  1. 182 254
      freejoy.mod/freejoy.bmx
  2. 302 0
      joystick.mod/joystick.bmx

+ 182 - 254
freejoy.mod/freejoy.bmx

@@ -1,15 +1,18 @@
+SuperStrict
 
 Rem
-bbdoc: User input/Joystick
+bbdoc: FreeJoy joystick driver
 End Rem
 Module Pub.FreeJoy
 
-ModuleInfo "Version: 1.09"
-ModuleInfo "Author: Simon Armstrong"
+ModuleInfo "Version: 1.10"
+ModuleInfo "Author: Simon Armstrong, Bruce A Henderson"
 ModuleInfo "License: zlib/libpng"
 ModuleInfo "Copyright: Blitz Research Ltd"
 ModuleInfo "Modserver: BRL"
 
+ModuleInfo "History: 1.10 Release"
+ModuleInfo "History: Uses new Factory-based driver framework."
 ModuleInfo "History: 1.09 Release"
 ModuleInfo "History: Linux devices can be located in various places."
 ModuleInfo "History: 1.08 Release"
@@ -23,6 +26,8 @@ ModuleInfo "History: Fixed Linux C Compiler warnings"
 ModuleInfo "History: 1.04 Release"
 ModuleInfo "History: Fixed C Compiler warnings"
 
+Import Pub.Joystick
+
 ?MacOS
 Import "freejoy.macosx.c"
 Import "-framework IOKit"
@@ -34,263 +39,186 @@ Import "freejoy.linux.c"
 
 Extern
 
-Rem
-bbdoc: Counts the number of joysticks.
-returns: The number of joysticks and gamecontrollers connected to the system.
-end rem
-Function JoyCount()
-
-Function JoyCName:Byte Ptr(port)
-
-Rem
-bbdoc: Available buttons (on/off controls) on a joystick.
-returns: A bitfield representing which buttons are present.
-end rem
-Function JoyButtonCaps(port)
-
-Rem
-bbdoc: Available axis (proportional controls) on a joystick.
-returns: A bitfield representing which axis are available.
-about:
-The bit positions of the returned value correspond to the following constants defined
-in the FreeJoy module:
-[ Const JOY_X=0
-* Const JOY_Y=1
-* Const JOY_Z=2
-* Const JOY_R=3
-* Const JOY_U=4
-* Const JOY_V=5
-* Const JOY_YAW=6
-* Const JOY_PITCH=7
-* Const JOY_ROLL=8
-* Const JOY_HAT=9
-* Const JOY_WHEEL=10
-]
-End Rem
-Function JoyAxisCaps(port)
-
-Function ReadJoy(port,buttons:Int Ptr,axis:Float Ptr)
-Function WriteJoy(port,channel,value#)
+	Function freejoy_JoyCount:Int() = "JoyCount"
+	Function freejoy_JoyCName:Byte Ptr(port:Int) = "JoyCName"
+	Function freejoy_JoyButtonCaps:Int(port:Int) = "JoyButtonCaps"
+	Function freejoy_JoyAxisCaps:Int(port:Int) = "JoyAxisCaps"
+	Function freejoy_ReadJoy(port:Int,buttons:Int Ptr,axis:Float Ptr) = "ReadJoy"
+	Function freejoy_WriteJoy(port:Int,channel:Int,value#) = "WriteJoy"
 
 End Extern
 
-JoyCount	'required to kick starts some drivers
 
-Const JOY_X=0
-Const JOY_Y=1
-Const JOY_Z=2
-Const JOY_R=3
-Const JOY_U=4
-Const JOY_V=5
-Const JOY_YAW=6
-Const JOY_PITCH=7
-Const JOY_ROLL=8
-Const JOY_HAT=9
-Const JOY_WHEEL=10
 
-Rem
-bbdoc: Get the name of the joysticks connected to the specified port.
-returns: The system name of the joystick.
-end rem
-Function JoyName$(port)
-	Return String.FromCString(JoyCName(port))
-End Function
-
-Global joy_time[16]
-Global joy_buttons[16]
-Global joy_axis#[16*16]
-Global joy_hits[16,16]
-
-Function SampleJoy(port)
-	Local	t
-	t=joy_time[port]-MilliSecs()
-	If t<0 Or t>1
-		Local old=joy_buttons[port]
-		ReadJoy port,Varptr joy_buttons[port],Varptr joy_axis[port*16]
-		For Local button=0 Until 16'To 16
-			Local b=1 Shl button
-			If Not(old & b) And joy_buttons[port]&b joy_hits[button, port]:+1'button and port were t'other way round.
+Type TFreeJoyDriver Extends TJoystickDriver
+
+	Global joy_time:Int[16]
+	Global joy_buttons:Int[16]
+	Global joy_axis#[16*16]
+	Global joy_hits:Int[16,16]
+	
+	Method New()
+		JoyCount
+	End Method
+	
+	Method GetName:String()
+		Return "FreeJoy"
+	End Method
+
+	Method JoyCount:Int()
+		Return freejoy_JoyCount()
+	End Method
+
+	Method JoyName:String(port:Int)
+		Return String.FromCString(freejoy_JoyCName(port))
+	End Method
+
+	Method JoyButtonCaps:Int(port:Int)
+		Return freejoy_JoyButtonCaps(port)
+	End Method
+
+	Method JoyAxisCaps:Int(port:Int)
+		Return freejoy_JoyAxisCaps(port)
+	End Method
+
+	Method JoyDown:Int( button:Int, port:Int=0 )
+		SampleJoy port
+		If joy_buttons[port] & (1 Shl button) Return True
+	End Method
+
+	Method JoyHit:Int( button:Int, port:Int=0 )
+		SampleJoy port
+		Local n:Int=joy_hits[button,port]
+		joy_hits[button,port]=0
+		Return n
+	End Method
+
+	Method JoyX#( port:Int=0 )
+		SampleJoy port
+		Return joy_axis[port*16+JOY_X]
+	End Method
+
+	Method JoyY#( port:Int=0 )
+		SampleJoy port
+		Return joy_axis[port*16+JOY_Y]
+	End Method
+
+	Method JoyZ#( port:Int=0 )
+		SampleJoy port
+		Return joy_axis[port*16+JOY_Z]
+	End Method
+
+	Method JoyR#( port:Int=0 )
+		SampleJoy port
+		Return joy_axis[port*16+JOY_R]
+	End Method
+
+	Method JoyU#( port:Int=0 )
+		SampleJoy port
+		Return joy_axis[port*16+JOY_U]
+	End Method
+
+	Method JoyV#( port:Int=0 )
+		SampleJoy port
+		Return joy_axis[port*16+JOY_V]
+	End Method
+
+	Method JoyYaw#( port:Int=0 )
+		SampleJoy port
+		Return joy_axis[port*16+JOY_YAW]
+	End Method
+
+	Method JoyPitch#( port:Int=0 )
+		SampleJoy port
+		Return joy_axis[port*16+JOY_PITCH]
+	End Method
+
+	Method JoyRoll#( port:Int=0 )
+		SampleJoy port
+		Return joy_axis[port*16+JOY_ROLL]
+	End Method
+
+	Method JoyHat#( port:Int=0 )
+		SampleJoy port
+		Return joy_axis[port*16+JOY_HAT]
+	End Method
+
+	Method JoyWheel#( port:Int=0 )
+		SampleJoy port
+		Return joy_axis[port*16+JOY_WHEEL]
+	End Method
+
+	Method JoyType:Int( port:Int=0 )
+		If port<JoyCount() Return 1
+		Return 0
+	End Method
+
+	Method JoyXDir:Int( port:Int=0 )
+		Local t#=JoyX( port )
+		If t<.333333 Return -1
+		If t>.333333 Return 1
+		Return 0
+	End Method
+
+	Method JoyYDir:Int( port:Int=0 )
+		Local t#=JoyY( port )
+		If t<.333333 Return -1
+		If t>.333333 Return 1
+		Return 0
+	End Method
+
+	Method JoyZDir:Int( port:Int=0 )
+		Local t#=JoyZ( port )
+		If t<.333333 Return -1
+		If t>.333333 Return 1
+		Return 0
+	End Method
+
+	Method JoyUDir:Int( port:Int=0 )
+		Local t#=JoyU( port )
+		If t<.333333 Return -1
+		If t>.333333 Return 1
+		Return 0
+	End Method
+
+	Method JoyVDir:Int( port:Int=0 )
+		Local t#=JoyV( port )
+		If t<.333333 Return -1
+		If t>.333333 Return 1
+		Return 0
+	End Method
+
+	Rem
+	bbdoc: Flush joystick button states.
+	End Rem
+	Method FlushJoy( port_mask:Int=~0 )
+		For Local i:Int=0 Until JoyCount()
+			If i & port_mask
+				SampleJoy i
+				joy_buttons[i]=0
+				For Local j:Int=0 Until 16
+					joy_hits[i,j]=0
+				Next
+			EndIf
 		Next
-	EndIf
-End Function
-
-Rem
-bbdoc: Test the status of a joystick button.
-returns: True if the button is pressed.
-end rem
-Function JoyDown( button,port=0 )
-	SampleJoy port
-	If joy_buttons[port] & (1 Shl button) Return True
-End Function
-
-Rem
-bbdoc: Check for a joystick button press
-returns: Number of times @button has been hit.
-about:
-The returned value represents the number of the times @button has been hit since 
-the last call to #JoyHit with the same specified @button.
-End Rem
-Function JoyHit( button,port=0 )
-	SampleJoy port
-	Local n=joy_hits[button,port]
-	joy_hits[button,port]=0
-	Return n
-End Function
-
-Rem
-bbdoc: Reports the horizontal position of the joystick.
-returns: Zero if the joystick is centered, -1 if Left, 1 if Right or a value inbetween.
-end rem
-Function JoyX#( port=0 )
-	SampleJoy port
-	Return joy_axis[port*16+JOY_X]
-End Function
-
-Rem
-bbdoc: Reports the vertical position of the joystick.
-returns: Zero if the joystick is centered, -1.0 if Up, 1.0 if Down or a value inbetween.
-end rem
-Function JoyY#( port=0 )
-	SampleJoy port
-	Return joy_axis[port*16+JOY_Y]
-End Function
-
-Rem
-bbdoc: Reports the position of the joystick's Z axis if supported.
-returns: Zero if the joystick is centered, -1.0 if Up, 1.0 if Down or a value inbetween.
-end rem
-Function JoyZ#( port=0 )
-	SampleJoy port
-	Return joy_axis[port*16+JOY_Z]
-End Function
-
-Rem
-bbdoc: Reports the position of the joystick's R axis if supported.
-returns: Zero if the joystick is centered, -1.0 if Up, 1.0 if Down or a value inbetween.
-end rem
-Function JoyR#( port=0 )
-	SampleJoy port
-	Return joy_axis[port*16+JOY_R]
-End Function
-
-Rem
-bbdoc: Reports the position of the joystick's U axis if supported.
-returns: Zero if the joystick is centered, -1.0 if Up, 1.0 if Down or a value inbetween.
-about:
-The U value of a joystick usually corresponds to a joystick's 'slider' or 'throttle' feature, although this may vary depending on the joystick, and will not be available with all joysticks.
-End Rem
-Function JoyU#( port=0 )
-	SampleJoy port
-	Return joy_axis[port*16+JOY_U]
-End Function
-
-Rem
-bbdoc: Reports the position of the joystick's V axis if supported.
-returns: Zero if the joystick is centered, -1.0 if Up, 1.0 if Down or a value inbetween.
-about:
-The V value of a joystick usually corresponds to a joystick's 'slider' or 'throttle' feature, although this may vary depending on the joystick, and will not be available with all joysticks.
-End Rem
-Function JoyV#( port=0 )
-	SampleJoy port
-	Return joy_axis[port*16+JOY_V]
-End Function
-
-Rem
-bbdoc: Reports the position of the joystick's YAW axis if supported.
-returns: Zero if the joystick is centered, -1.0 if Up, 1.0 if Down or a value inbetween.
-end rem
-Function JoyYaw#( port=0 )
-	SampleJoy port
-	Return joy_axis[port*16+JOY_YAW]
-End Function
-
-Rem
-bbdoc: Reports the position of the joystick's PITCH axis if supported.
-returns: Zero if the joystick is centered, -1.0 if Up, 1.0 if Down or a value inbetween.
-end rem
-Function JoyPitch#( port=0 )
-	SampleJoy port
-	Return joy_axis[port*16+JOY_PITCH]
-End Function
-
-Rem
-bbdoc: Reports the position of the joystick's ROLL axis if supported.
-returns: Zero if the joystick is centered, -1.0 if Up, 1.0 if Down or a value inbetween.
-end rem
-Function JoyRoll#( port=0 )
-	SampleJoy port
-	Return joy_axis[port*16+JOY_ROLL]
-End Function
+	End Method
+
+	Function SampleJoy(port:Int)
+		Local	t:Int
+		t=joy_time[port]-MilliSecs()
+		If t<0 Or t>1
+			Local old:Int=joy_buttons[port]
+			freejoy_ReadJoy port,Varptr joy_buttons[port],Varptr joy_axis[port*16]
+			For Local button:Int=0 Until 16'To 16
+				Local b:Int=1 Shl button
+				If Not(old & b) And joy_buttons[port]&b joy_hits[button, port]:+1'button and port were t'other way round.
+			Next
+		EndIf
+	End Function
 
-Rem
-bbdoc: Reports the position of the joystick's HAT controller if supported.
-returns: -1.0 if the joystick is centered, and values between 0.0, 0.25, 0.5 and 0.75 for the directions Up, Right, Down, Left respectively.
-End Rem
-Function JoyHat#( port=0 )
-	SampleJoy port
-	Return joy_axis[port*16+JOY_HAT]
-End Function
+End Type
 
-Rem
-bbdoc: Reports the position of the joystick's WHEEL controller if supported.
-returns: Zero if the joystick is centered, -1.0 if Left, 1.0 if Right or a value inbetween.
-End Rem
-Function JoyWheel#( port=0 )
-	SampleJoy port
-	Return joy_axis[port*16+JOY_WHEEL]
-End Function
-
-Function JoyType( port=0 )
-	If port<JoyCount() Return 1
-	Return 0
-End Function
-
-Function JoyXDir( port=0 )
-	Local t#=JoyX( port )
-	If t<.333333 Return -1
-	If t>.333333 Return 1
-	Return 0
-End Function
-
-Function JoyYDir( port=0 )
-	Local t#=JoyY( port )
-	If t<.333333 Return -1
-	If t>.333333 Return 1
-	Return 0
-End Function
-
-Function JoyZDir( port=0 )
-	Local t#=JoyZ( port )
-	If t<.333333 Return -1
-	If t>.333333 Return 1
-	Return 0
-End Function
-
-Function JoyUDir( port=0 )
-	Local t#=JoyU( port )
-	If t<.333333 Return -1
-	If t>.333333 Return 1
-	Return 0
-End Function
-
-Function JoyVDir( port=0 )
-	Local t#=JoyV( port )
-	If t<.333333 Return -1
-	If t>.333333 Return 1
-	Return 0
-End Function
+New TFreeJoyDriver
 
-Rem
-bbdoc: Flush joystick button states.
-End Rem
-Function FlushJoy( port_mask=~0 )
-	For Local i=0 Until JoyCount()
-		If i & port_mask
-			SampleJoy i
-			joy_buttons[i]=0
-			For Local j=0 Until 16
-				joy_hits[i,j]=0
-			Next
-		EndIf
-	Next
-End Function
+' make ourself the default
+GetJoystickDriver("FreeJoy")

+ 302 - 0
joystick.mod/joystick.bmx

@@ -0,0 +1,302 @@
+SuperStrict
+
+Rem
+bbdoc: User input/Joystick
+End Rem
+Module Pub.Joystick
+
+ModuleInfo "Version: 1.00"
+ModuleInfo "Author: Bruce A Henderson"
+ModuleInfo "License: zlib/libpng"
+ModuleInfo "Copyright: Bruce A Henderson"
+
+ModuleInfo "History: 1.00 Release"
+
+Const JOY_X:Int = 0
+Const JOY_Y:Int = 1
+Const JOY_Z:Int = 2
+Const JOY_R:Int = 3
+Const JOY_U:Int = 4
+Const JOY_V:Int = 5
+Const JOY_YAW:Int = 6
+Const JOY_PITCH:Int = 7
+Const JOY_ROLL:Int = 8
+Const JOY_HAT:Int = 9
+Const JOY_WHEEL:Int = 10
+
+
+Private
+
+Global current_joystick:TJoystickDriver
+
+Public
+
+Function JoyCount:Int()
+	Assert current_joystick
+	Return current_joystick.JoyCount()
+End Function
+
+Function JoyName:String(port:Int)
+	Assert current_joystick
+	Return current_joystick.JoyName(port)
+End Function
+
+Rem
+bbdoc: Available buttons (on/off controls) on a joystick.
+returns: A bitfield representing which buttons are present.
+end rem
+Function JoyButtonCaps:Int(port:Int)
+	Assert current_joystick
+	Return current_joystick.JoyButtonCaps(port)
+End Function
+
+Rem
+bbdoc: Available axis (proportional controls) on a joystick.
+returns: A bitfield representing which axis are available.
+about:
+The bit positions of the returned value correspond to the following constants defined
+in the FreeJoy module:
+[ Const JOY_X=0
+* Const JOY_Y=1
+* Const JOY_Z=2
+* Const JOY_R=3
+* Const JOY_U=4
+* Const JOY_V=5
+* Const JOY_YAW=6
+* Const JOY_PITCH=7
+* Const JOY_ROLL=8
+* Const JOY_HAT=9
+* Const JOY_WHEEL=10
+]
+End Rem
+Function JoyAxisCaps:Int(port:Int)
+	Assert current_joystick
+	Return current_joystick.JoyAxisCaps(port)
+End Function
+
+Rem
+bbdoc: Test the status of a joystick button.
+returns: True if the button is pressed.
+end rem
+Function JoyDown:Int( button:Int, port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyDown(button, port)
+End Function
+
+Rem
+bbdoc: Check for a joystick button press
+returns: Number of times @button has been hit.
+about:
+The returned value represents the number of the times @button has been hit since 
+the last call to #JoyHit with the same specified @button.
+End Rem
+Function JoyHit:Int( button:Int, port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyHit(button, port)
+End Function
+
+Rem
+bbdoc: Reports the horizontal position of the joystick.
+returns: Zero if the joystick is centered, -1 if Left, 1 if Right or a value inbetween.
+End Rem
+Function JoyX#( port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyX(port)
+End Function
+
+Rem
+bbdoc: Reports the vertical position of the joystick.
+returns: Zero if the joystick is centered, -1.0 if Up, 1.0 if Down or a value inbetween.
+End Rem
+Function JoyY#( port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyY(port)
+End Function
+
+Rem
+bbdoc: Reports the position of the joystick's Z axis if supported.
+returns: Zero if the joystick is centered, -1.0 if Up, 1.0 if Down or a value inbetween.
+End Rem
+Function JoyZ#( port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyZ(port)
+End Function
+
+Rem
+bbdoc: Reports the position of the joystick's R axis if supported.
+returns: Zero if the joystick is centered, -1.0 if Up, 1.0 if Down or a value inbetween.
+End Rem
+Function JoyR#( port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyR(port)
+End Function
+
+Rem
+bbdoc: Reports the position of the joystick's U axis if supported.
+returns: Zero if the joystick is centered, -1.0 if Up, 1.0 if Down or a value inbetween.
+about:
+The U value of a joystick usually corresponds to a joystick's 'slider' or 'throttle' feature, although this may vary depending on the joystick, and will not be available with all joysticks.
+End Rem
+Function JoyU#( port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyU(port)
+End Function
+
+Rem
+bbdoc: Reports the position of the joystick's V axis if supported.
+returns: Zero if the joystick is centered, -1.0 if Up, 1.0 if Down or a value inbetween.
+about:
+The V value of a joystick usually corresponds to a joystick's 'slider' or 'throttle' feature, although this may vary depending on the joystick, and will not be available with all joysticks.
+End Rem
+Function JoyV#( port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyV(port)
+End Function
+
+Rem
+bbdoc: Reports the position of the joystick's YAW axis if supported.
+returns: Zero if the joystick is centered, -1.0 if Up, 1.0 if Down or a value inbetween.
+End Rem
+Function JoyYaw#( port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyYaw(port)
+End Function
+
+Rem
+bbdoc: Reports the position of the joystick's PITCH axis if supported.
+returns: Zero if the joystick is centered, -1.0 if Up, 1.0 if Down or a value inbetween.
+End Rem
+Function JoyPitch#( port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyPitch(port)
+End Function
+
+Rem
+bbdoc: Reports the position of the joystick's ROLL axis if supported.
+returns: Zero if the joystick is centered, -1.0 if Up, 1.0 if Down or a value inbetween.
+End Rem
+Function JoyRoll#( port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyRoll(port)
+End Function
+
+Rem
+bbdoc: Reports the position of the joystick's HAT controller if supported.
+returns: -1.0 if the joystick is centered, and values between 0.0, 0.25, 0.5 and 0.75 for the directions Up, Right, Down, Left respectively.
+End Rem
+Function JoyHat#( port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyHat(port)
+End Function
+
+Rem
+bbdoc: Reports the position of the joystick's WHEEL controller if supported.
+returns: Zero if the joystick is centered, -1.0 if Left, 1.0 if Right or a value inbetween.
+End Rem
+Function JoyWheel#( port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyWheel(port)
+End Function
+
+Function JoyType:Int( port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyType(port)
+End Function
+
+Function JoyXDir:Int( port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyXDir(port)
+End Function
+
+Function JoyYDir:Int( port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyYDir(port)
+End Function
+
+Function JoyZDir:Int( port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyZDir(port)
+End Function
+
+Function JoyUDir:Int( port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyUDir(port)
+End Function
+
+Function JoyVDir:Int( port:Int=0 )
+	Assert current_joystick
+	Return current_joystick.JoyVDir(port)
+End Function
+
+Rem
+bbdoc: Flush joystick button states.
+End Rem
+Function FlushJoy( port_mask:Int=~0 )
+	Assert current_joystick
+	current_joystick.FlushJoy(port_mask)
+End Function
+
+
+Private
+
+Global joystick_drivers:TJoystickDriver
+
+Public
+
+Rem
+bbdoc: Abstract base type for pixmap loaders
+about:
+To create a new pixmap loader, you should extend TPixmapLoader and implement the #LoadPixmap method.
+
+To install your pixmap loader, simply create an instance of it using #New</font>.
+End Rem
+Type TJoystickDriver
+	Field _succ:TJoystickDriver
+	
+	Method New()
+		_succ=joystick_drivers
+		joystick_drivers=Self
+	End Method
+	
+	Method GetName:String() Abstract
+
+	Method JoyCount:Int() Abstract
+	Method JoyName:String(port:Int) Abstract
+	Method JoyButtonCaps:Int(port:Int) Abstract
+	Method JoyAxisCaps:Int(port:Int) Abstract
+	Method JoyDown:Int( button:Int, port:Int=0 ) Abstract
+	Method JoyHit:Int( button:Int, port:Int=0 ) Abstract
+	Method JoyX#( port:Int=0 ) Abstract
+	Method JoyY#( port:Int=0 ) Abstract
+	Method JoyZ#( port:Int=0 ) Abstract
+	Method JoyR#( port:Int=0 ) Abstract
+	Method JoyU#( port:Int=0 ) Abstract
+	Method JoyV#( port:Int=0 ) Abstract
+	Method JoyYaw#( port:Int=0 ) Abstract
+	Method JoyPitch#( port:Int=0 ) Abstract
+	Method JoyRoll#( port:Int=0 ) Abstract
+	Method JoyHat#( port:Int=0 ) Abstract
+	Method JoyWheel#( port:Int=0 ) Abstract
+	Method JoyType:Int( port:Int=0 ) Abstract
+	Method JoyXDir:Int( port:Int=0 ) Abstract
+	Method JoyYDir:Int( port:Int=0 ) Abstract
+	Method JoyZDir:Int( port:Int=0 ) Abstract
+	Method JoyUDir:Int( port:Int=0 ) Abstract
+	Method JoyVDir:Int( port:Int=0 ) Abstract
+	Method FlushJoy( port_mask:Int=~0 ) Abstract
+	
+End Type
+
+Function GetJoystickDriver:TJoystickDriver(name:String)
+
+	Local driver:TJoystickDriver = joystick_drivers
+	
+	While driver
+		If driver.GetName().ToLower() = name.ToLower() Then
+			current_joystick = driver
+			Return driver
+		End If
+		driver = driver._succ
+	Wend
+
+End Function