What will the RavJoystick Xtra do ?
Developing with the RavJoystick Xtra
RavJoystick Xtra Function Reference
Using the Xtra in a ShockWave movie
Supported File Information Table
Some explanations and definitions are based on information in the MSDN and DirectX
Documentation
The RavJoystick Xtra gives Director developers the ability to use regular and force feedback joysticks, steering wheels, touch screens, and other gaming devices. Force feedback devices can add a new dimension to your Director and ShockWave games. For example if you were creating a fishing game you could create force feedback effects that simulated a fishing pole or if you were creating a space invaders clone you could feel the firing of a missile. If your customer has DirectX 5.0 and above the Xtra can use it, but it also has the ability to use the default joystick drivers present on all Win32 systems. By being able to dynamically use either method your application can use most joysticks without asking them to install other software while taking advantage of advanced features when present. On systems with multiple joysticks the Xtra provides several functions and dialogs to help your customer choose which device to use as well as dialogs to calibrate it. Force feedback gives your application a whole new dimension and the RavJoystick Xtra gives you the ability to take advantage of these devices.
The demo subdirectory contains example Director DIR movies to experiment with.
To purchase the RavJoystick Xtra electronically please visit http://www.ravware.com or to order by phone please call: 1-630-858-0989. All payment must be made at the time of purchase using Visa or MasterCard. Purchase orders are NOT accepted.
All RavWare products are available in demo form to allow you to evaluate them before purchase, for this reason products are not returnable or refundable.
For sales questions please contact sales@ravware.com
RavWare provides support strictly through email. Questions will be answered as soon as possible and in a timely manner. Support is available 9:00AM to 6:00PM US Central Time and Monday through Friday excluding any holidays or vacation. Please provide the product serial number with any questions.
If you have a suggestion for a future product feature or an idea for simplifying the learning curve in using the product, please e-mail it to RavWare at support@ravware.com.
This software is provided "as is", without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability or fitness for a particular purpose. The software or its documentation or samples may include errors or technical inaccuracies. Changes are periodically made to this software, its documentation and samples, and may be incorporated in new versions. RavWare may improve or change products at any time without notice. RavWare does not assume responsibility for, and disclaims all liability for, errors in this software or its documentation and samples. RavWare will not be responsible for any damages of any sort under any conditions and is not liable for lost profits, or any special, indirect, consequential, or incidental damages. While the software contains no known bugs, use it at your own risk.
Some jurisdictions do not allow the exclusion of implied warranties, so the above exclusion may not apply to you.
Purchasing the software entitles the registered user to an unlimited royalty free
runtime license for distributing the Xtra in a compiled Director application the
registered user develops. For development the registered user is licensed to possess
and operate a single installed copy of the software, operation over a network is
forbidden. Any copying or network operation of this software is a violation of this
license agreement. The registered user may not redistribute any documents
, human-readable product serial numbers , or any files accompanying the Xtra.
This requires that Director movies containing product serial numbers must be distributed
as protected files or inside projectors. The Xtra is serialized for
identification. The user may not rent or lease the Xtra. You may not reverse
engineer, decompile, or disassemble the Xtra.
Any product that the registered user creates using the Xtra must not compete with the Xtra
in any way; e.g.; the product must not be another Xtra or software development tool,
application or projector that has the same features and is intended for distribution to
other software developers or system integrators. The user may not extend access to the
Xtra in any form, either directly or indirectly. The end product must be unique and not
simply wrap the Xtra's functionality.
All material presented is copyrighted by RavWare Software. No part of this material may be
used or reproduced in any fashion without prior written consent.
The demo version of the Xtra is only to be used for evaluation purposes. The demo may be
redistributed, provided no charge is made and can not be altered in any manner and must
distributed intact as is, including all files.
Violation of this licensing agreement automatically terminates your right to use this
software. RavWare will take any legal action necessary for loss profits or infringement of
intellectual property.
The RavJoystick Xtra was designed to be easy to use and quick to implement. To demonstrate how to start using the Xtra in your Director application see the Code Examples section for information on how to open , read, and close a joystick.
The demo subdirectory contains example Director DIR movies to experiment with.
RavJoystick Xtra Functions |
|
Function Name | Description |
RavScanAlljoysticks | Get information on every attached joystick on the system |
RavOpenjoystick | Open a joystick using a specified index, or use a pre-made dialog |
RavGetjoystickState | Get joystick position, buttons, and state |
RavClosejoystick | Close a joystick previously opened with RavOpenjoystick |
RavCalibrateDlg | Call the system joystick calibration dialog for setting the joystick's properties |
RavCreatePeriodicForce | Create a force that pulsates according to a defined wave pattern |
RavCreateConstantForce | Create a force that moves in a steady single direction at a set strength |
RavCreateRampForce | Create a force that steadily increases or decreases in magnitude |
RavCreateFrictionForce | Create a force that generates resistance to movement of the joystick |
RavCreateInertiaForce | Create a force that that increases with the acceleration of movement along an axis |
RavCreateSpringForce | Create a force that tends to move the stick back to a certain position after it has been moved from that position |
RavCreateDamperForce | Create a force that increases with the movement along an axis |
RavCreateHardwareForce | Create a force that is specific to the Joystick |
RavStartEffect | Start a force feedback effect |
RavStopEffect | Stop a force feedback effect |
RavDestroyEffect | Unload a force feedback effect and all associated memory |
RavSetForceProp | Change a property for an already created force feedback effect |
RavGetProp | Retrieves a property value for the Xtra |
RavSetProp | Sets a property value for the Xtra |
RavRegisterjoystickXtra | Unlocks Xtra, only present in sale version |
The RavJoystick Xtra can be used in a ShockWave Movie. The Xtra follows the guidelines set forth by Macromedia for a ShockWave Xtra. The Xtra is marked as "Safe for ShockWave" but you will need to provide an autoinstaller for the Xtra or purchase a ShockWave auto-installer package version of the Xtra from RavWare.
To help in debugging a ShockWave movie you can use the #ravFakeShockwave property to have the Xtra simulate being used from a ShockWave movie from the Director authoring environment.
Instructions from Macromedia on how to use an autoinstall Xtra in ShockWave with comments specific to the Xtra:
Placing package files on a server
Once you've created package files, you need to put them in a single location on a server.
For example:
http://www.myserver.com/packs/ravshockjoystick.w32
Preparing a movie that requires a downloaded Xtra
Xtra downloading occurs before a movie starts. This means that a Web page that includes a
movie that downloads an Xtra does not respond until the package downloads. If the user
chooses not to install the Xtra, Director discards the downloaded package. To improve this
experience, create an introductory movie that checks for the existence of required Xtras
with the XtraList command. If an Xtra isn't available, the movie should present the user
with the choice of proceeding with the download. If the user proceeds, the introduction
should run the main movie with goToNetMovie. If a user chooses not to download
the Xtra, the movie should proceed without the Xtra, or fail gracefully.
To prepare a movie for use with a downloaded Xtra:
1 Open the file Xtrainfo.txt in any text editor and enter the URL to the package files you created earlier and copied to a server. Exclude the file extension from the name of the packages. #nameW32 and #namePPC specify whether the package is for Windows, Macintosh, or both. You don't have to include a package for both platforms.
For example: [#nameW32:"RavJoystick.x32",#package:"http://www.myserver.com/packs/RavShockJoystick"]
2 Open the movie in Director, choose Modify > Movie > Xtras and turn on Download if Needed for the Xtras that should be downloaded. If Download if Needed is not enabled for the Xtra, make sure the file name in Xtrainfo.txt matches the actual file name for the Xtra. When you click the checkbox, Director loads information from the package file at the specified URL and adds it to the current movie. There must be an active network connection for this to work.
3 If the movie is playing from a projector, create an introductory movie that starts the main movie with gotoNetMovie. Xtra downloading does not work if a movie is playing in a projector unless started from another movie with goToNetMovie.
Testing a movie with Xtra downloading
Make sure the Xtra to be downloaded is not installed already. Run the movies you created in the previous section in a browser or as a projector. After you choose to proceed from the introductory movie, Director should download the Xtra package from the specified location and present a Download Security dialog box.
Note that Xtra downloading does not work if a movie is playing in a projector unless you start it from another movie with goToNetMovie. It's often best to use an introductory movie before starting a movie that requires Xtra downloading. Also, Xtra downloading does not occur if you start a movie with go to movie.
Joystick Information Properties |
|||||||||||||||
Property | Description | ||||||||||||||
#Name | The joystick product name : String. | ||||||||||||||
#Drivername | The generic name of the driver being used : String | ||||||||||||||
#XMin | Minimum X-coordinate : Integer | ||||||||||||||
#XMax | Maximum X-coordinate : Integer | ||||||||||||||
#YMin | Minimum Y-coordinate : Integer | ||||||||||||||
#YMax | Maximum Y-coordinate : Integer | ||||||||||||||
#NumButtons | Number of joystick buttons : Integer | ||||||||||||||
#MaxAxes | Maximum number of axes supported by the joystick : Integer | ||||||||||||||
#NumAxes | Number of axes currently in use by the joystick : Integer | ||||||||||||||
#MaxButtons | Maximum number of buttons supported by the joystick : Integer | ||||||||||||||
#HasZ |
|
||||||||||||||
#ZMin | Minimum Z-coordinate : Integer | ||||||||||||||
#ZMax | Maximum Z-coordinate : Integer | ||||||||||||||
#HasR |
|
||||||||||||||
#RMin | Minimum rudder value. The rudder is a fourth axis of movement. : Integer | ||||||||||||||
#RMax | Maximum rudder value. The rudder is a fourth axis of movement. : Integer | ||||||||||||||
#HasU |
|
||||||||||||||
#UMin | Minimum u-coordinate (fifth axis or joystick defined) values : Integer | ||||||||||||||
#UMax | Maximum u-coordinate (fifth axis or joystick defined) values : Integer | ||||||||||||||
#HasV |
|
||||||||||||||
#VMin | Minimum v-coordinate (sixth axis or joystick defined) values : Integer | ||||||||||||||
#VMax | Maximum v-coordinate (sixth axis or joystick defined) values : Integer | ||||||||||||||
#HasPov |
|
||||||||||||||
#HasForceFeedback |
|
||||||||||||||
#joystickType |
|
||||||||||||||
#HardWareEffects | Contains a list of string names for most of the force feedback effects stored directly in the joystick. This property is only filled out when a force feedback joystick is opened. List of strings |
Joystick Force Feedback Information Properties |
|||||||
Property | Description | ||||||
#ActuatorOn |
|
||||||
#PowerOn |
|
||||||
#SafetyOn |
|
||||||
#UserSwitchOn |
|
||||||
#DeviceLost |
|
||||||
#DeviceEmpty |
|
||||||
#DevicePaused |
|
||||||
#DeviceStopped |
|
Parameters:
instanceVar - An instance of the RavJoystick Xtra.
Return:
A list containing information about every attached joystick on the system. Use the property #TotalAttached to determine how many entries are in the array. Each entry in the list will contain a property list that describes features about each joystick. The general layout of the list is [ [joystick 1 Property List] , [joystick 2 Property List] , [joystick 3 Property List], ...]
Each property list contains properties describing the joystick. For example if you wanted to access the name of the joystick for the first joystick detected on the system you could do so using the below code:
-- Find How Many joysticks Installed Set Totaljoysticks = RavGetProp(joystickXtra,#TotalAttached)
if (Totaljoysticks > 0) then -- Get Information on each joystick on the machine set joysticksInfo = RavScanAlljoysticks(joystickXtra)
-- Output the Name of the First joystick put joysticksInfo[1].Name end if
The properties that the function will contain are listed in the Joystick Information Properties. If the system does not have any joystick's attached the list will be an empty list or "[ ]".
Description:
The function provides general information about each joystick attached to the system. It does not give the name of specific hardware effects or the maximum or minimum force a Force feedback joystick supports. To get these features you will need to open the joystick using the RavOpenjoystick function and get the property #CurrentStickInfo using RavGetProp. This function is helpful when you are providing a custom method for your customer to choose which joystick to use and do not want to use the provided dialogs in RavOpenjoystick.
Parameters:
InstanceVar - An instance of the RavJoystick Xtra.
Stick - The index of which joystick to open. This index value will be from 1 to the property #TotalAttached . This value can also be set to
Stick Value | Description |
1..16 | Open a joystick that has been detected with RavScanAlljoysticks . This will be the array index. |
-2 | Scan the system and use the value of the first clicked joystick. This is commonly referred to as "Click to Pick" All a user needs to do is click any button on the desired joystick. This does the same as -3 but does not use a dialog and does not continuously scan for input. To do so you will need to call this function in a repeat loop. |
-3 | Displays a dialog and waits for a user to click any button on a joystick. If the cancel button is pressed the function does not open any joystick. This is commonly referred to as "Click to Pick" |
-4 | Displays a dialog that contains an enumerated list of every joystick and gaming device on the system. If the cancel button is pressed the function does not open any joystick. |
API - Determines which set of drivers to use to open the joystick with.
API Symbol | Description |
#WinMM | Use the default Windows Multimedia drivers. Using this API will allow you to get all the position and button information but will not allow you to get or set Force Feedback information. |
#DirectInput | Use the DirectX DirectInput API if present. Use this API when you want to set or get Force Feedback from the joystick. Also , some drivers contained optimized implementations for input for DirectInput. |
Return:
#true | The joystick was opened successfully. |
#false | The joystick could not be opened. See the #ravLastErrorCode and #ravLastErrorCodeString properties. |
Description:
The function opens a joystick for input. After successfully opening a joystick you can get information on the joystick by using the RavGetProp function for items such as hardware force feedback effects, the state of various power switches, and the position of the joystick.
Example:
See Open a joystick
Parameters:
InstanceVar - An instance of the RavJoystick Xtra.
Return:
A list containing information about the state of the joystick at the time the function was called. The state information contains the value of each button on the joystick and values for the various joystick Axes, sliders , and POV hats.
Property | Description |
#ButtonStates | A list of integers that are set to 1 if the button is being pressed and 0 if it is not. The list size is determined by the property #Numbuttons: List |
#ButtonNumber | The last button that was pressed: Integer |
#X | The value of the joystick's x-axis , usually the left-right movement of the joystick. : Integer |
#Y | The value of the joystick's y-axis , usually the forward-backward movement of the joystick. : Integer |
#Z | The value of the joystick's z-axis , sometimes referred to as the throttle control. : Integer (See Note) |
#Rx | The value of the joystick's x-axis rotation. : Integer (See Note) |
#Ry | The value of the joystick's y-axis rotation. : Integer (See Note) |
#Rz | The value of the joystick's z-axis rotation. : Integer (See Note) |
#Slider1 | A joystick defined axis, sometimes referred to as the u-axis. : Integer (See Note) |
#Slider2 | A joystick defined axis, sometimes referred to as the v-axis. : Integer (See Note) |
#POV | The current position of the point-of-view hat. The position is indicated in hundredths of degrees clockwise from north (away from the user). The center position is reported as 65535. For indicators that have only five positions, the value for a controller would be 65535, 0, 9,000, 18,000, or 27,000. : Integer (See Note) |
(Note: It will be 0 for joysticks that lack this feature. Use the RavScanAlljoysticks function or the #CurrentStickInfo to determine if the joystick has such a feature.)
An example returned list :
[#ButtonStates: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], #ButtonNumber: 0, #X: 52416, #Y: 256, #Z: 65024, #Slider1: 0, #Slider2: 0, #POV: 65535, #Rx: 0, #Ry: 0, #Rz: 32768]
For example if you wanted to access the X Pos of the currently open joystick
-- Get the Current State of the JoySick Set joystickState = RavGetjoystickState(joystickXtra) -- Output the joystick XPos put joystickState.X
To Find if the first button on a currently open joystick is being pressed the Lingo code
would be:
-- Get the Current State of the JoyStick Set joystickState = RavGetjoystickState(joystickXtra) -- Get the state of Button 1 being pressed , Check count(joystickState) > 0 put joystickState.ButtonStates[1]
Description:
This function returns the state of an open joystick including the positions of the various axis and buttons. Usually this function will be called in the main loop of your application to get the joystick's state. If the joystick is taken by another application the Xtra will try to get the joystick back when this function is called. No state information is available when the calibration dialog is open.
Example:
Parameters:
InstanceVar - An instance of the RavJoystick Xtra.
Return:
#true | The joystick was closed successfully. |
#false | The joystick was not closed. See the #ravLastErrorCode and #ravLastErrorCodeString properties. |
Description:
The function will close a joystick opened with the RavOpenjoystick function and release all associated resources.
Example:
See Close joystick
Parameters:
InstanceVar - An instance of the RavJoystick Xtra.
Return:
#true | The calibration dialog was successfully created. |
#false | The calibration dialog could not be created. See the #ravLastErrorCode and #ravLastErrorCodeString properties. |
Description:
The function launches the control panel calibration dialog so that a user can setup the joystick however they choose. This function can be called before or after opening a joystick. If the Xtra is using DirectInput and this is called while the joystick is open then the dialog will be launched specific to the opened dialog. While the calibration dialog is open you can not retrieve any information about the state of the joystick.
Example:
Parameters:
InstanceVar - An instance of the RavJoystick Xtra.
PeriodType | Description |
#sine | The waveform follows the trigonometric sine function |
#cosine | The waveform follows the trigonometric cosine function |
#squarehigh | The waveform that switches between maximum and minimum forces instantaneously |
#squarelow | The waveform that switches between minimum and maximum forces instantaneously |
#triangleup | The waveform that linearly moves between maximum and minimum force values |
#triangledown | The waveform that linearly moves between minimum and maximum force values |
#sawtoothup | The waveform drops vertically after it reaches maximum positive force. |
#sawtoothdown | The waveform rises vertically after it reaches maximum negative force. |
Period - The period of the force effect measured in microseconds (uS)
Magnitude - The magnitude of the effect, in the range 0 to 10,000. If an envelope is applied to this effect, then the value represents the magnitude of the sustain. If no envelope is applied, then the value represents the amplitude of the entire effect.
Offset - The offset of the force effect. The range of forces generated by the effect will be (Offset - Magnitude) to (Offset + Magnitude). The value of the offset member is also the baseline for any envelope that is applied to the effect
Duration - The total time length of the force effect measured in microseconds (uS) Set this value to "the maxInteger" for an infinite duration.
Direction - The direction from which the force effect is coming from, a positive force on a given axis pushes from the positive toward the negative. The angle is measured in hundredths of degrees from the (0, 1) direction, rotated in the direction of (1 , 0). This usually means that "north" is away from the user, and "east" is to the user's right. The range is from 0 to 35999 corresponding to 0 to 360 degrees in polar coordinates.
Attacktime - The time it takes to reach the sustain level, measured in microseconds (uS)
Attacklevel - The amplitude for the start of the envelope, relative to the baseline, in the range 0 to 10,000.
Fadetime - The time it takes to reach the fade level measured in microseconds (uS)
Fadelevel - The amplitude for the end of the envelope, relative to the baseline, in the range 0 to 10,000.
Button - The joystick button that the effect should be associated with. Set this to -1 if you don't want the effect associated with any button.
Return:
The return value is an integer Identification value that you can use to reference the effect throughout the Xtra. You will need this value if you are loading and freeing many force feedback effects or manually starting and stopping an effect.
Description:
The function creates a force that pulsates according to a defined wave pattern. You can have the effect triggered by associating it with a button or manually using the RavStartForce / RavStopForce functions
Example:
See Setting a joystick button to create a force on click
Parameters:
InstanceVar - An instance of the RavJoystick Xtra.
Magnitude - The magnitude of the effect, in the range 0 to 10,000. If an envelope is applied to this effect, then the value represents the magnitude of the sustain. If no envelope is applied, then the value represents the amplitude of the entire effect.
Duration - The total time length of the force effect measured in microseconds (uS) Set this value to "the maxInteger" for an infinite duration.
Direction - The direction from which the force effect is coming from, a positive force on a given axis pushes from the positive toward the negative. The angle is measured in hundredths of degrees from the (0, 1) direction, rotated in the direction of (1 , 0). This usually means that "north" is away from the user, and "east" is to the user's right. The range is from 0 to 35999 corresponding to 0 to 360 degrees in polar coordinates.
Attacktime - The time it takes to reach the sustain level, measured in microseconds (uS)
Attacklevel - The amplitude for the start of the envelope, relative to the baseline, in the range 0 to 10,000.
Fadetime - The time it takes to reach the fade level measured in microseconds (uS)
Fadelevel - The amplitude for the end of the envelope, relative to the baseline, in the range 0 to 10,000.
Button - The joystick button that the effect should be associated with. Set this to -1 if you don't want the effect associated with any button.
Return:
The return value is an integer Identification value that you can use to reference the effect throughout the Xtra. You will need this value if you are loading and freeing many force feedback effects or manually starting and stopping an effect.
Description:
Create a force that moves in a steady single direction at a set strength.
Parameters:
InstanceVar - An instance of the RavJoystick Xtra.
Start - The magnitude at the start of the effect, in the range -10,000 to +10,000
End - The magnitude at the end of the effect, in the range -10,000 to +10,000
Duration - The total time length of the force effect measured in microseconds (uS) Set this value to "the maxInteger" for an infinite duration.
Direction - The direction from which the force effect is coming from, a positive force on a given axis pushes from the positive toward the negative. The angle is measured in hundredths of degrees from the (0, 1) direction, rotated in the direction of (1 , 0). This usually means that "north" is away from the user, and "east" is to the user's right. The range is from 0 to 35999 corresponding to 0 to 360 degrees in polar coordinates.
Attacktime - The time it takes to reach the sustain level, measured in microseconds (uS)
Attacklevel - The amplitude for the start of the envelope, relative to the baseline, in the range 0 to 10,000.
Fadetime - The time it takes to reach the fade level measured in microseconds (uS)
Fadelevel - The amplitude for the end of the envelope, relative to the baseline, in the range 0 to 10,000.
Button - The joystick button that the effect should be associated with. Set this to -1 if you don't want the effect associated with any button.
Return:
The return value is an integer Identification value that you can use to reference the effect throughout the Xtra. You will need this value if you are loading and freeing many force feedback effects or manually starting and stopping an effect.
Description:
Create a force that steadily increases or decreases in magnitude.
Parameters:
InstanceVar - An instance of the RavJoystick Xtra.
Fx - The x-axis force coefficient, in the range -10,000 to +10,000.
Fy - The y-axis force coefficient, in the range -10,000 to +10,000.
Duration - The total time length of the force effect measured in microseconds (uS). Set this value to "the maxInteger" for an infinite duration.
Button - The joystick button that the effect should be associated with. Set this to -1 if you don't want the effect associated with any button.
Return:
The return value is an integer Identification value that you can use to reference the effect throughout the Xtra. You will need this value if you are loading and freeing many force feedback effects or manually starting and stopping an effect.
Description:
Create a force that generates resistance to movement of the joystick. A 1D force can be generated by setting either Fx or Fy to 0. A 2D force can be generated by setting both Fx and Fy to non-zero values.
Parameters:
InstanceVar - An instance of the RavJoystick Xtra.
Mx - The x-axis M coefficient, in the range -10,000 to +10,000.
My - The y-axis M coefficient, in the range -10,000 to +10,000.
AOx - The x-axis initial acceleration , in the range -10,000 to +10,000.
AOy - The y-axis initial acceleration , in the range -10,000 to +10,000.
Duration - The total time length of the force effect measured in microseconds (uS). Set this value to "the maxInteger" for an infinite duration.
Button - The joystick button that the effect should be associated with. Set this to -1 if you don't want the effect associated with any button.
Return:
The return value is an integer Identification value that you can use to reference the effect throughout the Xtra. You will need this value if you are loading and freeing many force feedback effects or manually starting and stopping an effect.
Description:
Create a force that that increases with the acceleration of movement along an axis. A 1D inertia force can be generated by setting either Mx or My to 0. A 2D force can be generated by setting both Mx and My to non-zero values.
Parameters:
InstanceVar - An instance of the RavJoystick Xtra.
Kx - The x-axis K coefficient, in the range -10,000 to +10,000.
Ky - The y-axis K coefficient, in the range -10,000 to +10,000.
Centerx - The x-axis center, in the range -10,000 to +10,000.
Centery - The y-axis center, in the range -10,000 to +10,000.
Duration - The total time length of the force effect measured in microseconds (uS)
Button - The joystick button that the effect should be associated with. Set this to -1 if you don't want the effect associated with any button.
Return:
The return value is an integer Identification value that you can use to reference the effect throughout the Xtra. You will need this value if you are loading and freeing many force feedback effects or manually starting and stopping an effect.
Description:
Create a force that tends to move the stick back to a certain position after it has been moved from that position. A 1D spring force can be generated by setting either Kx or Ky to 0. A 2D force can be generated by setting both Kx and Ky to non-zero values.
Parameters:
InstanceVar - An instance of the RavJoystick Xtra.
Bx - The x-axis B force coefficient, in the range -10,000 to +10,000.
By - The y-axis B force coefficient, in the range -10,000 to +10,000.
VOx - The x-axis initial velocity, in the range -10,000 to +10,000.
VOy - The y-axis initial velocity, in the range -10,000 to +10,000.
Duration - The total time length of the force effect measured in microseconds (uS)
Button - The joystick button that the effect should be associated with. Set this to -1 if you don't want the effect associated with any button.
Return:
The return value is an integer Identification value that you can use to reference the effect throughout the Xtra. You will need this value if you are loading and freeing many force feedback effects or manually starting and stopping an effect.
Description:
Create a force that increases with the movement along an axis. A 1D damper force can be generated by setting either Bx or By to 0. A 2D force can be generated by setting both Bx and By to non-zero values.
Parameters:
InstanceVar - An instance of the RavJoystick Xtra.
EffectName - The name of the hardware implemented effect to create. The name can be retrieved using the RavGetProp function with the #CurrentStickInfo after a force feedback joystick has been opened using DirectInput.
Gain - The gain to be applied to the force effect, in the range 0 to 10,000. The gain is a scaling factor applied to all magnitudes of the effect and its envelope
Duration - The total time length of the force effect measured in microseconds (uS)
Direction - The direction from which the force effect is coming from, a positive force on a given axis pushes from the positive toward the negative. The angle is measured in hundredths of degrees from the (0, 1) direction, rotated in the direction of (1 , 0). This usually means that "north" is away from the user, and "east" is to the user's right. The range is from 0 to 35999 corresponding to 0 to 360 degrees in polar coordinates.
Button - The joystick button that the effect should be associated with. Set this to -1 if you don't want the effect associated with any button.
Return:
The return value is an integer Identification value that you can use to reference the effect throughout the Xtra. You will need this value if you are loading and freeing many force feedback effects or manually starting and stopping an effect.
Description:
Create a force that is specific to the Joystick The name can be retrieved using the RavGetProp function with the #CurrentStickInfo after a force feedback joystick has been opened using DirectInput.
For some joysticks calling a system modal dialog box such as a Lingo Alert command will prevent the joystick from using any hardware stored effect.
Example:
See Using hardware specific Force Feedback Effects
Parameters:
InstanceVar - An instance of the RavJoystick Xtra.
EffectID - An effect Identification value returned from RavCreatePeriodicForce ,RavCreateConstantForce , RavCreateRampForce , RavCreateFrictionForce , RavCreateInertiaForce , RavCreateSpringForce , RavCreateDamperForce or RavCreateHardwareForce that refers to the specific effect.
Iterations - The number of times to repeat the effect. Set this value to "the maxInteger" for infinite iterations. Some joysticks do not support this parameter being anything but 1.
Flags - A numerical flag to be passed to an effect. The below table lists possible values that are currently supported
0 | Nothing |
1 | All other effects on the device should be stopped before the specified effect is played. If this flag is omitted, then the effect is mixed with existing effects already started on the device. |
2147483648 | Do not automatically download the effect. |
2147483649 | This will do both of the above 2 options (1) and (2147483649) |
Return:
#true | The effect was started. |
#false | The effect could not be started. See the #ravLastErrorCode and #ravLastErrorCodeString properties. |
Description:
Starts playback of a previously created effect. This function is used when you want to control an effect manually. Most joysticks do not support anything more than 1 iteration. The Xtra will generate error code 11 if the joystick does not support more than 1 iteration.
Example:
See Manually starting an effect
Parameters:
InstanceVar - An instance of the RavJoystick Xtra.
EffectID - An effect Identification value returned from RavCreatePeriodicForce ,RavCreateConstantForce , RavCreateRampForce , RavCreateFrictionForce , RavCreateInertiaForce , RavCreateSpringForce , RavCreateDamperForce or RavCreateHardwareForce that refers to the specific effect.
Return:
#true | The effect was stopped. |
#false | The effect could not be stopped. See the #ravLastErrorCode and #ravLastErrorCodeString properties. |
Description:
Stops an effect that has been manually started using the RavStartEffect.
Example:
See Manually stopping an effect
Parameters:
InstanceVar - An instance of the RavJoystick Xtra.
EffectID - An effect Identification value returned from RavCreatePeriodicForce ,RavCreateConstantForce , RavCreateRampForce , RavCreateFrictionForce , RavCreateInertiaForce , RavCreateSpringForce , RavCreateDamperForce or RavCreateHardwareForce that refers to the specific effect.
Return:
#true | The effect was destroyed. |
#false | The effect was not able to be destroyed. See the #ravLastErrorCode and #ravLastErrorCodeString properties. |
Description:
Releases all the memory associated with a force feedback effect. When the Xtra is destroyed all effects are destroyed and released from it. This function gives you the ability to conserve memory on the joystick by discarding specific effects you no longer need.
Example:
See Manually stopping an effect
Parameters:
InstanceVar - An instance of the RavJoystick Xtra.
EffectID - An effect Identification value returned from RavCreatePeriodicForce ,RavCreateConstantForce , RavCreateRampForce , RavCreateFrictionForce , RavCreateInertiaForce , RavCreateSpringForce , RavCreateDamperForce or RavCreateHardwareForce that refers to the specific effect.
Prop | Value |
#duration | The total time length of the force effect measured in microseconds (uS) Set this value to "the maxInteger" for an infinite duration. : Integer |
#direction | The direction from which the force effect is coming from, a positive force on a given axis pushes from the positive toward the negative. The angle is measured in hundredths of degrees from the (0, 1) direction, rotated in the direction of (1 , 0). This usually means that "north" is away from the user, and "east" is to the user's right. The range is from 0 to 35999 corresponding to 0 to 360 degrees in polar coordinates. : Integer |
Return:
#true | The effect was changed successfully. |
#false | The effect could not be changed. See the #ravLastErrorCode and #ravLastErrorCodeString properties. |
Description:
The function gives you the ability to change properties for already created force feedback effects. This is usually needed when you are manually changing an effect.
Property Table |
||||||
Prop | RavGetProp():Return Value or RavSetProp(Value) | Get/Set | ||||
#TotalAttached | The total attached joysticks detected for the computer. : Integer | G | ||||
#TotalPossible | The total possible joysticks the system can support : Integer | |||||
#CurrentStickInfo | The properties for the open joystick. See joystick Information Properties : List | G | ||||
#ForceFeedbackState | The force feedback properties for an open joystick. See joystick Force Feedback Information Properties : List | G | ||||
#ravFakeShockwave |
|
G | ||||
#ApiInUse |
|
G | ||||
#DirectInputInstalled |
|
G | ||||
#XtraVersion | The current version number of the Xtra. : String | G/S | ||||
#Saturation | Sets the value for the saturation zones of a joystick, in the range 0 to 10,000. The saturation level is the point at which the axis is considered to be at its most extreme position. For example, if the saturation level is set to 9,500, then the axis reaches the extreme of its range when it has moved 95 percent of the physical distance from its center position (or from the dead zone). Integer | G/S | ||||
#DeadZone | Sets the value for the dead zone of a joystick, in the range 0 to 10,000, where 0 indicates there is no dead zone, 5,000 indicates that the dead zone extends over 50 percent of the physical range of the axis on both sides of center, and 10,000 indicates that the entire physical range of the axis is dead. : Integer | G/S | ||||
#AutoCenter |
|
S | ||||
#ravlasterrorcode | Returns the integer code for the last error. See error code table : Integer | G | ||||
#ravlasterrorcodestring | Translates the last error code to a string. See error code table : String | G |
Parameters:
instanceVar - An instance of the RavJoystick Xtra.
Symbol - The property value to set. See the Property Table
Return Value:
The return value's type depends on the property being requested. In the property table each property's return type follows the description.
Description:
RavGetProp retrieves various settings for internal variables used by the specific instance of the Xtra.
Example:
See Open a joystick , Using hardware specific Force Feedback Effects
Parameters:
instanceVar - An instance of the RavJoystick Xtra.
Symbol - The property value to set. See the Property Table
Val - The value to set the property to. See the Property Table
Return:
#true | The property was set successfully. |
#false | The property could not be set. See the #ravLastErrorCode and #ravLastErrorCodeString properties. |
Description:
RavSetProp sets various settings for internal variables used by the specific instance of the Xtra.
Example:
See Open a joystick using DirectInput and setting advanced features
Parameters:
instanceVar - An instance of the RavJoystick Xtra.
regCode - Code assigned to a registered customer at time of purchase for the RavJoystick Xtra.
Return Value:
#true | The Xtra instance has been successfully unlocked. |
#false | The Xtra instance failed to unlock , no functions will be accessible. See the #ravLastErrorCode and #ravLastErrorCodeString properties. |
Description:
If you have purchased the RavJoystick Xtra you were given a serial/registration number and a registered copy of the Xtra. Replace the demo version of the Xtra with the registered version. The registered version does not display a warning box when it starts , but it will not allow any methods to be called until you first use the RavRegisterjoystickXtra method.
This method is only present in the sale version of the Xtra. The demo version will beep and display a dialog box.
If you have problems registering the RavJoystick Xtra, please check the following (Partially Taken from technote 12219 from macromedia):
Example:
See Open a joystick
Error Table | |
Integer Error Code | String Error Message |
0 | "No error" |
2 | "Could not access the needed function" |
3 | "Could not allocate needed memory" |
4 | "Unknown type or too many or few parameters" |
5 | "Xtra not registered" |
6 | "A parameter's data type was incorrect" |
7 | "The specified effect is not open" |
8 | "A negative value was used where a positive one was expected" |
9 | "The system does not have a joystick attached" |
10 | "Joystick data could not be retrieved" |
11 | "Value of variable can not be used" |
12 | "Joystick driver missing" |
13 | "The pointer or handle specified is invalid" |
14 | "A joystick must be opened before position data can be retrieved" |
15 | "The specified joystick does not exist or is unattached" |
16 | "Joystick is not open, DirectInput is not loaded, or the device does not support force feedback." |
17 | "Cannot add another effect" |
18 | Device does not support force feedback" |
Unknown | "Need to specify a valid error code" |
Compatibility Table |
Director 6 - Passed Win32 |
Director 6 - Passed Win32 |
Director 6.5 - Passed Win32 |
Director 6.5 - Passed Win32 |
Director 7 - Passed Win32 |
Director 7 - Passed Win32 |
Director 7.02 - Passed Win32 |
Director 7.02 - Passed Win32 |
v1.0 - Feb 22, 2000
Please examine the example Director compatible DIR files that were installed with the Xtra. They should be in the "Demos" subdirectory from where you installed the RavJoystick Xtra.
------------------------------------------------------------------------ -- Open a joystick using a possible dialog -- Which stick contains the joystick you want to open , or -- If which Stick is -3 It will use Click to Pick Dialog , if it -- is -4 it will use Enum Dialog ------------------------------------------------------------------------ on Openjoystick WhichStick global joystickXtra -- Check if the joystick Xtra is Already Open if (objectp(joystickXtra) = true) then Closejoystick end if
-- Create an Instance of the Xtra Set joystickXtra = new(xtra "RavJoystick")
-- Check it was loaded OK if (objectp(joystickXtra) = false) then -- The Xtra failed to load, check to make sure the Xtra is -- in the correct SubDirectory alert "Xtra unable to load, check file path" Closejoystick exit end if
-- ** DO XTRA Registration in Sale Version, Replace "BAD-SERIALNUMBER" -- With Sale Serial Number if (RavRegisterjoystickXtra(joystickXtra,"BAD-SERIALNUMBER") = #false) then alert "Xtra serial number failed to register" Closejoystick exit end if
-- Check that there is at least 1 joystick Attached. This code is for -- demonstration purposes but if you only detect 1 joystick you really -- don't need to ask them which joystick to use, Just set WhichStick = 1 -- Just UnComment the Else Clause Set Totaljoysticks = RavGetProp(joystickXtra,#TotalAttached) if (Totaljoysticks < 1) then Alert "No joysticks Attached" Closejoystick exit --else if (Totaljoysticks = 1) then --WhichStick = 1 end if
-- This Example does not use DirectInput, but you could just change -- the following code to #DirectInput instead of #WinMM -- If which Stick is -3 It will use Click to Pick Dialog , if it -- is -4 it will use Enum Dialog if (RavOpenjoystick(joystickXtra,WhichStick,#WinMM) = #false) then Alert RavGetProp(joystickXtra,#RavLastErrorCodeString) end if end
------------------------------------------------------------------------ -- Get the joystick Info , this just puts the value to the message window ------------------------------------------------------------------------ on GetjoystickInfo global joystickXtra if (objectP(joystickXtra) = true) then Set joystickState = RavGetjoystickState(joystickXtra) -- To get a value use the following: put joystickState.X put joystickState.Y put joystickState.Z put joystickState.POV put joystickState.Rx put joystickState.Ry put joystickState.Rz put joystickState.Slider1 put joystickState.Slider2 -- To get the state of button 1 put joystickState.ButtonStates[1] end if end
------------------------------------------------------------------------ -- Close the joystick if it is Open ------------------------------------------------------------------------ on Closejoystick global joystickXtra
if (objectp(joystickXtra) = true) then -- Close the joystick RavClosejoystick(joystickXtra) Set joystickXtra = 0 end if end
------------------------------------------------------------------------ -- Bring up a calibration dialog for users to setup the joystick ------------------------------------------------------------------------ on CalibratejoystickDialog global joystickXtra -- Check if the Xtra is already open, if is not open, then open it. if (objectp(joystickXtra) = false) then -- Create an Instance of the Xtra Set joystickXtra = new(xtra "RavJoystick")
-- Check it was loaded OK if (objectp(joystickXtra) = false) then -- The Xtra failed to load, check to make sure the Xtra is -- in the correct SubDirectory alert "Xtra unable to load, check file path" Closejoystick exit end if
-- ** DO XTRA Registration in Sale Version, Replace "BAD-SERIALNUMBER" -- With Sale Serial Number if (RavRegisterjoystickXtra(joystickXtra,"BAD-SERIALNUMBER") = #false) then alert "Xtra serial number failed to register" Closejoystick exit end if end if
if (objectp(joystickXtra) = true) then RavCalibrateDlg(joystickXtra) end if end
------------------------------------------------------------------------ -- Open a Joystick using DirectInput ------------------------------------------------------------------------ on OpenJoyStick WhichStick global JoyStickXtra -- Check if the JoyStick Xtra is Already Open if (objectp(JoyStickXtra) = true) then CloseJoyStick end if -- Create an Instance of the Xtra Set JoyStickXtra = new(xtra "RavJoystick")
-- Check it was loaded OK if (objectp(JoyStickXtra) = false) then -- The Xtra failed to load, check to make sure the Xtra is -- in the correct SubDirectory alert "Xtra unable to load, check file path" CloseJoyStick exit end if
-- ** DO XTRA Registration in Sale Version, Replace "BAD-SERIALNUMBER" -- With Sale Serial Number if (RavRegisterJoyStickXtra(JoyStickXtra,"BAD-SERIALNUMBER") = #false) then alert "Xtra serial number failed to register" CloseJoyStick exit end if
-- Check that there is at least 1 JoyStick Attached. This code is for -- demonstration purposes but if you only detect 1 Joystick you really -- don't need to ask them which Joystick to use, Just set WhichStick = 1 -- Just UnComment the Else Clause Set TotalJoySticks = RavGetProp(JoyStickXtra,#TotalAttached) if (TotalJoySticks < 1) then Alert "No JoySticks Attached" CloseJoyStick exit --else if (TotalJoySticks = 1) then --WhichStick = 1 end if
if (RavGetProp(JoyStickXtra,#DirectInputInstalled) <> #true) then Alert "DirectInput Not Present" CloseJoyStick exit end if
-- This Demo does not use DirectInput, but you could also change -- the following code to #DirectInput instead of #WinMM -- If which Stick is -3 It will use Click to Pick Dialog , if it -- is -4 it will use Enum Dialog if (RavOpenJoyStick(JoyStickXtra,WhichStick,#DirectInput) = #false) then Alert RavGetProp(JoyStickXtra,#RavLastErrorCodeString) end if -- Set Advanced Features -- 95% of Full distance is considered Maximum RavSetProp(JoyStickXtra,#Saturation,9500) -- 10% of center is dead zone RavSetProp(JoyStickXtra,#DeadZone,1000) end
This example is an excerpt from the demo program D7_ROMForceFeedbackTest.DIR included with the installation. It assumes that the Xtra has been created and the Joystick has been opened.
on SetEachButtonToROMEffect global JoystickXtra global ROMForceID
if (objectP(JoyStickXtra) = false) then Alert "Xtra not loaded" exit end if
-- Find Any ROM Effects Set JoyInfoList = RavGetProp(JoyStickXtra,#CurrentStickInfo) if (count(JoyInfoList) = 0) then Alert "Joystick Information Could Not Be Filled Out" exit end if
-- Set each Button on the Joystick to a Different ROM effect -- So Button 1 will be set to ROM Effect 1, ... -- Maximum of 8 buttons Set HowMany = min(JoyInfoList.MaxButtons,count(JoyInfoList.HardWareEffects)) Set HowMany = min(8,HowMany)
Set TempString = ""
repeat with i = 1 to HowMany -- Choose the First Effect and Assign it to JoyStick Button 2 Set EffectName = JoyInfoList.HardWareEffects[i] Set ROMForceID = RavCreateHardwareForce(JoyStickXtra,EffectName,0,the maxInteger,0,i)
Set TempString = TempString & " " & "Button" & string(i) & ": " & EffectName & ","
-- For debugging you may want to output a debug message, but -- modal dialogs screw up some joysticks. if (ROMForceID < 1) then put RavGetProp(JoyStickXtra,#RavLastErrorCodeString) end if end repeat
if (TempString = "") then Set TempString = "No effects to map" end if
end
This example is an excerpt from the demo program D7_ForceFeedbackBtnTes.DIR included with the installation. It assumes that the Xtra has been created and the Joystick has been opened. You would call this function when you want to start the force and then continually in an application's update loop such as the exitframe handler. Notice that to be able to play this back manually you cannot bind the effect to a button but must use -1.
on StartPeriodicForce
global JoystickXtra global PeriodicForceID
if (objectP(JoyStickXtra) = false) then Alert "Xtra not loaded" exit end if
-- Check if the effect is already open , if it isn't then open it if (PeriodicForceID < 1) then Set PeriodicForceID = RavCreatePeriodicForce(JoystickXtra,#SquareHigh,100000,50,0,the maxInteger,0,0,0,0,0,-1)
if (PeriodicForceID < 1) then Alert RavGetProp(JoyStickXtra,#RavLastErrorCodeString) Set PeriodicForceID = 0 exit end if
end if
-- Start the playback of the effect if (RavStartEffect(JoystickXtra,PeriodicForceID,1,0) = #false) then Alert RavGetProp(JoyStickXtra,#RavLastErrorCodeString) end if end
This example is an excerpt from the demo program D7_ForceFeedbackBtnTes.DIR included with the installation. It assumes that the Xtra has been created and the Joystick has been opened. You would call this function when you want to stop and destroy an effect.
on EndPeriodicForce global JoystickXtra global PeriodicForceID
if (objectP(JoyStickXtra) = false) then Alert "Xtra not loaded" exit end if if (PeriodicForceID < 1) then -- Nothing to Destroy exit end if
if (RavStopEffect(JoystickXtra,PeriodicForceID) = #false) then Alert RavGetProp(JoyStickXtra,#RavLastErrorCodeString) end if -- Destroy the Effect RavDestroyEffect(JoyStickXtra,PeriodicForceID)
Set PeriodicForceID = 0 end
This example is an excerpt from the demo program D7_ForceFeedbackBtnTes.DIR included with the installation. It assumes that the Xtra has been created and the Joystick has been opened.
on SetForceForButton global JoystickXtra global ForceID
if (objectP(JoyStickXtra) = false) then Alert "Xtra not loaded" exit end if
Set ForceID = RavCreatePeriodicForce(JoystickXtra,#SquareHigh,100000,50,0,the maxInteger,0,0,0,0,0,1) if (ForceID < 1) then Alert RavGetProp(JoyStickXtra,#RavLastErrorCodeString) end if
end
Basic joystick overview
In this document a "joystick" will refer to an input device that provide alternatives to using the keyboard and mouse. The joystick provides positional information within a coordinate system that has absolute maximum and minimum values in each axis of movement. This can be a traditional joystick such as those present in arcade games , steering wheels, or even some touch screen devices. There are usually 4 to 10 or more buttons that have a simple Boolean state of either being pressed down or unpressed. Some external additions such as foot pedals are reported as buttons for the #NumButtons and #MaxButtons but these are not traditional buttons with an up or down state. There are usually 2 axis (x,y) and sometimes a third (z) that can be used as a throttle or depth control. Additionally there can a Point of View (POV) or "hat" and additional sliders or shift keys.
Working with a Steering Wheel
This description applies to the Microsoft Force Feedback Steering wheel, other devices may differ slightly. The actual steering wheel portion of the device ranges from 0 to 65535 for the X-Axis. You can get the position of the steering wheel using the RavGetjoystickState function and querying the "X" property list value. The foot pedal will modify the Y-axis and will be 32768 when both pedals are up. Pushing the right pedal all the way down will decrease the value towards 0, while pushing the left pedal all the way down will increase the value to 65535. This would indicate that full acceleration is when the Y axis value is 0 and full stop is 65535.
How to determine which joystick to use ?
On systems with multiple joysticks you need to ask the user which joystick they want to use. The Xtra provides you with several methods to help in this task. The 2 most common techniques for choosing among several joysticks is to have them either click a button on the joystick they want to use or have them choose from an enumerated list of attached joysticks. The Xtra provides 2 dialogs in the RavOpenJoystick function that wrap these 2 techniques . However if you would like to use your own technique the Xtra provides the RavScanAlljoysticks and RavOpenJoystick to allow you to construct your own interface.
How to design a force ?
Just as there are paint programs to create complex and amazing images there are tools that provide an easy and fast method to create and experiment with forces. Microsoft provides a free tool called Force Factory with DirectX and there is a fairly cheap tool called I-FORCE Studio that allow you to interactively change and apply forces. These tools usually output to a C++ file which is easily translatable to methods in the Xtra and Lingo.
Copyright © 2000 RavWare , All rights reserved.