oJoyStick Object

Back to top of page Description:
 A Hardware Object that reads an Atari style joystick and returns an URCP heading value.
 The following table lists the size and availability of the oJoyStick Object.
 ObjectSizeDescriptionA1A2B1B2C1
oJoyStick4 BytesReads an Atari style joystickxxx
Back to top of page Operation:
 The oJoystick Object monitors a joystick which is expected to be an array of 4 switches.  The 4 switches are arranged where one switch is pressed for any one of the 4 directions N, E, S, W  that the joystick is pressed and two of the switches are pressed if the joystick is pressed in one of the 4 directions NE, SE, NW, SW.  Joysticks made for the Atari game systems and computers provide this type of 4-bit value.  A vintage Atari joystick is constructed in the way.

When the joystick is pressed in any of the 8 possible directions, the Pressed property is set to 1, otherwise the Pressed property is cleared to 0.

When created, the oJoystick Object also creates an instance of the oOrbitSwitch4 object which it uses to read the 4 I/O lines and generate the Heading value.  Modifying any of the properties of the oOrbtSwitch4X Object instance will affect the oJoystick Object's operation. See the oOrbitSwitch4 for more detail on how the 4 I/O lines are read.

Back to top of page Properties:

The following table lists the properties of the oJoyStick Object:

Property

Description

Heading
A value that indicates the current direction the joystick is being pressed.
Object Class: oHeading Value Range: -128 to +127
Data Type: Numeric Default Value: 0
I/O InputsPositionHeadingPressed


URCP Heading

0001Front01
0011 321
0010Left641
0110 961
0100Back-1281
1100 -961
1000Right-641
1001 -321
Other Unchanged0
Pressed
A value that indicates if the joystick is being pushed to one side.
Object Class: oLogic Value Range: 0 - 1
Data Type: Numeric Default Value: 0
IOPack
A value that specifies which pack of 4 I/O lines is connected to the Joystick.
Object Class: oIOPack Value Range: 0 - 7
Data Type: Numeric Default Value: 0
Some I/O Lines have special purposes.  Be sure to see oIOPack help file for details.
Operate
A value that selects whether or not the joystick is read.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOffThe joystick is not read.
1cvOnThe joystick is read.
DIO
The I/O function object used to read the joystick.
Object Class: oOrbitSwitch4 Value Range: -128 to +127
Data Type: Numeric Default Value: 0
Address
Returns a pointer to the address of the oCounter Object instance.
Object Class: oAddress Value Range: 0 - 127
Data Type:Pointer (Read Only) Default Value: Address of Object

Back to top of page Examples:
 In the following example, the oJoystick Object is used.
'This program reads an Atari style 
'joystick and outputs the URCP 
'value to I/O lines 8 - 15.

Dim J As New oJoyStick
Dim D As New oDIO1(7,cvOutput)
Dim C As New oDIO8(3,cvOutput)

Sub Main()
  ooPIC.PullUp = cvTrue

  J.IOPack = 5
  J.Operate = 1
  Do
    C = J.Heading
    D = J.Pressed 
  Loop

End Sub
Back to top of page Connections:
The joystick itself consisted of five switches which are arranged where four of them are used for the directions (UP, DOWN, LEFT, RIGHT) and one is for fire button. The joystick connector is a 9 pin D-shell connector. Normally all switches are open, when he joystick is pressed from the center position, one or two position switches are closed (according to what direction the stick is pressed). The fire button worked so that it closes when the button is pressed. All of the switches are connected between ground and corresponding signal pin of the joystick connector.

9 pin D-SUB female connector layout

9 pin D-SUB female connector layout
9 pin D-SUB female connector at the joystick

PinColorDescription
1WHTUp
2BLUDown
3GRNLeft
4BRNRight
5n/cNot connected
6ORGButton
7n/cNot connected
8BLKGround(-)
9n/cNot connected

Back to top of page Related Items:

 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oBumper4Reads a 4-contact bumper.xxx
Back to top of page Version History and Bug List:
 Firmware Ver B1: Introduced.

Bugs: No known bugs.


ooPIC Compiler Ver 6.0 (c) Copyright 1997 - 2007 Savage Innovations, LLC.