This is a unit with functions that make controlling the joystick trivial... It gives full control, and is FAST. Players apprieciate it when they can use their favorite joystick, and it give much more flexibility than the keyboard or mouse...
{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=-=-=-=-=-=- -=-=-=-=-=-=
-=-=-= Joystick Interface Unit =-=-=-
=-=- -=-=
-=-=-= Coded by: Chris Lattner -=-=-=
=-=-=-=-=-=- 1995 -=-=-=-=-=-=
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}
UNIT Jstick;
INTERFACE
PROCEDURE InitJoystick(Range : INTEGER);
(* InitJoystick - Sets up the internal variables required for this unit to
operate. It prompts the user to see if there is a joystick available. If
there is, the Range variable is processed so that when you request the X & Y
coordinates of the joystick, variables within the range you expect will be
returned.
If you pass 2 as range, you can expect to get values from -1 to 1. If you
pass a 4, you will get values ranging from -2 to 2. This isolates you from
the complexities of the joystick, and the values that it returns. *)
FUNCTION JoystickButtons : INTEGER;
(* JoystickButtons - Returns the state of the joystick buttons. Bit #0 is
button 1, Bit #1 is button 2, Bit #2 is button 1 on joystick 2... ect... *)
FUNCTION JoystickX : INTEGER;
(* JoystickX - Reads from the joystick the X position of joystick. Then
it recenters the value and converts it to the range that you specify. It
also mathematically removes the speed dependency of the computer from the
joystick readings. *)
FUNCTION JoystickY : INTEGER;
(* JoystickY - Reads the Y position of the joystick and converts it. *)
PROCEDURE ReadJoystick(VAR X, Y, Buttons : INTEGER);
(* ReadJoystick - Just the three functions JoystickButtons, JoystickX, and
JoystickY rolled together for more convienient use. *)