The problem: You can't get joystick information in an X² script. How many times have you wished you could get that button on your joystick to do something in a script?
A possible solution: I've written a little utility called JoyScript. What it does is watch a joystick and every 100ms writes the information on all the joystick buttons to an XML language file. A script can then load this file whenever it wants to check on the state of the joystick's buttons.
The language file is VERY simple. It writes to page 2498, starting at ID 100 for button 1 (the trigger) to ID 103 for button 4. Remember, the script will have to load the XML language file every time it wants to check on the buttons.
I have a dual CPU computer, and it works fine for me. However, when I was visiting my parents last week, I noticed that when I would hit CTRL-ALT-DEL to switch out of X², that it sometimes took 10 seconds or more for windows to respond. I'm thinking that X² raises its priority level very high. If this is the case, it may starve JoyScript of cpu time. I don't have access to a single CPU computer right now, so I can't test this out.
You can download the program from: ftp://ftp.excelcia.org/x2/utilities/Joy ... 3Setup.exe
It has a full installer, and should be pretty straighforward. When run it will try to locate all your joysticks and will let you select which one to monitor. Click on the "..." button in the Output box to select the output file. If you have a North American (Enlight) version of X2, then it will automatically find your <x2>/t folder. If not, then you will have to tell the program where to find it. DON'T OVERWRITE AN EXISTING XML FILE - not unless it is one that JoyScript has created. The program will ask you if you want to overwrite if you select an existing file, and if you click yes, it will happily erase any XML file there in favour of the joystick button data. So make sure you're not overwriting something you need.
If you have Borland's C++ Builder (I was too lazy to code it in Visual Studio), you can download the source code and project files from: ftp://ftp.excelcia.org/x2/utilities/Joy ... Source.zip.
I'll be putting support in my turret scripts soon to be able to use the joystick trigger to manually fire the fore turret.
Utility to allow reading the joystick inside scripts
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
-
- Posts: 1133
- Joined: Thu, 10. Jul 03, 07:42
Utility to allow reading the joystick inside scripts
Last edited by Reven on Fri, 8. Oct 04, 04:55, edited 2 times in total.
You were warned... pirates will be hunted down like vermin.
Ex Turbo Modestum
Ex Turbo Modestum
-
- Posts: 1133
- Joined: Thu, 10. Jul 03, 07:42
Anyone using this utility should update to 1.03. I apologize, but a bug in 1.02 will make it probably not work. I've vowed not to stay up all night programming any more - I make too many silly mistakes that way. 
If you have 1.02, just uninstall it and install 1.03.
For those that don't know, I've integrated this into a new command on my gunnery crews script that allows you manual control of a turret. So when you use the fire button on your joystick, a turret will fire on whatever you have targeted.
I would really appreciate it if someone could test this out on a computer that doesn't have dual CPUs. I'd like to see if the system works for everyone.
You can download the latest JoyScript at: ftp://ftp.excelcia.org/x2/utilities/Joy ... 3Setup.exe
You can download the latest Gunnery Crews beta at:
ftp://ftp.excelcia.org/x2/scripts/Gunne ... 0Beta5.zip.
Please use this thread for discussion of the JoyScript program. If you have any issues with the Gunnery Crews script that isn't related to JoyScript, then please post them in the Gunnery Crews thread.

If you have 1.02, just uninstall it and install 1.03.
For those that don't know, I've integrated this into a new command on my gunnery crews script that allows you manual control of a turret. So when you use the fire button on your joystick, a turret will fire on whatever you have targeted.
I would really appreciate it if someone could test this out on a computer that doesn't have dual CPUs. I'd like to see if the system works for everyone.
You can download the latest JoyScript at: ftp://ftp.excelcia.org/x2/utilities/Joy ... 3Setup.exe
You can download the latest Gunnery Crews beta at:
ftp://ftp.excelcia.org/x2/scripts/Gunne ... 0Beta5.zip.
Please use this thread for discussion of the JoyScript program. If you have any issues with the Gunnery Crews script that isn't related to JoyScript, then please post them in the Gunnery Crews thread.
You were warned... pirates will be hunted down like vermin.
Ex Turbo Modestum
Ex Turbo Modestum
-
- Posts: 2997
- Joined: Sat, 20. Mar 04, 20:50
Re: Utility to allow reading the joystick inside scripts
It leaves it set to normal. However it can be sluggish recognising keypresses unless you raise the priority level.Reven wrote:I'm thinking that X² raises its priority level very high.
-
- Posts: 820
- Joined: Mon, 16. Feb 04, 13:08
-
- Posts: 1190
- Joined: Wed, 6. Nov 02, 20:31
Re: Utility to allow reading the joystick inside scripts
Most of the keystroke problems in X2 rely on the scripts. A script consumes more or less CPU-time, depending on the work the script need to do (expecially "while"-loops are CPU intensive). To provide more CPU time for the system and for X2 you should use the 'wait'-command of the script editor extensively.Some Strange Man wrote:It leaves it set to normal. However it can be sluggish recognising keypresses unless you raise the priority level.Reven wrote:I'm thinking that X² raises its priority level very high.
For example, for testing:
Install my script "Supply Software ST1" Version 5 (see: http://www.egosoft.com/x2/forum/viewtopic.php?t=46022). Make usage of the new trade command "Sell ware for best price" and then work with keyboard (X2 "r"-menue or something else).
Then stop the command, edit my script "plugin.fabsupplysoftST1.main2" ( delete all "wait"-commands in this script), save and start the ship-command again. You will recognize a heavy delay if you're using the keyboard.
-
- Posts: 53
- Joined: Wed, 18. Feb 04, 07:34
New version available! Now with 32 joystick buttons!
Recently, I wrote to Kurt (aka, Reven) to ask about the possibility of using more than 4 joystick buttons. My reasoning is twofold:
1) Originally, JoyScript was written for the optional 'Bridge Command' for the Hired Gunnery Crews signed script. However, it's entirely possible for almost any script to be written (or modified) to take advantage of JoyScript and, thus, take commands from the joystick. (I plan on modifying or writing a few myself...) So having more buttons available would make this much more feasible without conflicts.
2) I have a nice Sidewinder joystick with 9 buttons and I'd like to take advantage of some of the less-used ones. Further, at least for custom scripts, I'd rather keep buttons 1 through 4 the way they are because they get used often for things like missiles and guns.
Anyway, this is part of Kurt's reply:
1) Originally, JoyScript was written for the optional 'Bridge Command' for the Hired Gunnery Crews signed script. However, it's entirely possible for almost any script to be written (or modified) to take advantage of JoyScript and, thus, take commands from the joystick. (I plan on modifying or writing a few myself...) So having more buttons available would make this much more feasible without conflicts.
2) I have a nice Sidewinder joystick with 9 buttons and I'd like to take advantage of some of the less-used ones. Further, at least for custom scripts, I'd rather keep buttons 1 through 4 the way they are because they get used often for things like missiles and guns.
Anyway, this is part of Kurt's reply:
Originally I designed the program to handle up to 32 buttons, but I see in my program notes that there was a problem I couldn't solve at the time that prevented this from working. I don't remember now what that problem was, and I've now successfully run the program supporting more than four buttons. I guess I'm smarter now than I was three years ago.![]()
So I've made version 1.05 with the support for up to 32 joystick buttons. It's available at
ftp://ftp.excelcia.org/x2/utilities/Joy ... 5Setup.zip
If you want the source code, it's available at
ftp://ftp.excelcia.org/x2/utilities/Joy ... Source.zip
Regards,
Kurt.
p.s. If you're still active on the X2/X3 forums, please feel free to post about the new version.
-
- Posts: 53
- Joined: Wed, 18. Feb 04, 07:34
A required library file, RTL60.BPL, was not found!
While trying to get JoyScript v1.04 to work, I ran into a serious problem. It seemed to install successfully, but when I tried to start it I was greeted with a couple of pop-up error messages. The error message on top was:
NOTE: This is probably not an issue for those running Windows XP as it's more modern and comes with most runtime libraries installed.
I currently run X2 from an installation of Windows 98SE, with the UNOFFICIAL Windows98 Second Edition Service Pack 2.1a installed, as well as MS IE v6.0 SP1, and a variety of other updates and runtime libraries. I had the latest Java installed, as well as the runtime libraries for OCX, VisualBasic 6, and Visual C++, so I thought I was covered. But, obviously, something was missing.
After searching through several pages of search engine results for "RTL60.BPL", I finally found a relevant, working download. (You will not believe how hard it is to find a working, relevant download for this!) And after some reading, I began to understand what this was.
As far as I can tell, JoyScript was written and compiled using Borland Developer Studio 2006 - which includes Delphi 2006, C Builder 2006, and C#Builder 2006 in one package. (It has quote "Integrated support for C, C++, C#, and Delphi programming languages...") As such, it requires it's own version of runtime libraries. These are not included in the JoyScript download and the runtime libraries for Visual C++ will not work (as that's an unrelated Micro$oft product). Strangely, it appears that none of these BPL library files are available from the official Borland website (at least without being a registered customer) - even though such files are usually required to run apps compiled by Borland products!
Anyway, I found a working download here:
Zonum Solutions > BPL Files
I found it does (ordinarily) work to put the BPL file(s) in the same directory as the app - and this works regardless of the flavor of Windows. However, through trial and error and a bit of research, I found the last paragraph to be a bit misleading:
It does also work to put all the BPL files into to Windows/system32 folder... but only for those using Windows NT, Windows 2000, or Windows XP. Otherwise (Windows 98/SE/ME), you should put these files into the Windows/System folder.
PS: In case you wondered what Zonum Solutions is about:
The error message underneath this one stated:Error Starting Program
A required .DLL file, RTL60.BPL, was not found.
OK, this seemed straightforward enough. Obviously, my PC was missing one or more files. And, from the top message, it looks like RTL60.BPL was one of them.Error
Unable to execute file:
C:\Program Files\JoyScript\JoyScript.exe
CreateProcess failed; code 1157.
One of the library files needed to run this application cannot be found
NOTE: This is probably not an issue for those running Windows XP as it's more modern and comes with most runtime libraries installed.
I currently run X2 from an installation of Windows 98SE, with the UNOFFICIAL Windows98 Second Edition Service Pack 2.1a installed, as well as MS IE v6.0 SP1, and a variety of other updates and runtime libraries. I had the latest Java installed, as well as the runtime libraries for OCX, VisualBasic 6, and Visual C++, so I thought I was covered. But, obviously, something was missing.
After searching through several pages of search engine results for "RTL60.BPL", I finally found a relevant, working download. (You will not believe how hard it is to find a working, relevant download for this!) And after some reading, I began to understand what this was.
As far as I can tell, JoyScript was written and compiled using Borland Developer Studio 2006 - which includes Delphi 2006, C Builder 2006, and C#Builder 2006 in one package. (It has quote "Integrated support for C, C++, C#, and Delphi programming languages...") As such, it requires it's own version of runtime libraries. These are not included in the JoyScript download and the runtime libraries for Visual C++ will not work (as that's an unrelated Micro$oft product). Strangely, it appears that none of these BPL library files are available from the official Borland website (at least without being a registered customer) - even though such files are usually required to run apps compiled by Borland products!
Anyway, I found a working download here:
Zonum Solutions > BPL Files
There are about two or three dozen different BPL files available. Note that you can either download individual files, or you can download them all in one ZIP.Some tools developed using Borland (TM) products require additional libraries. These libraries have the "BPL" extension file. If when trying to run a Zonums tool, a message asking for a BPL file appears, just download the file from the following list and copy it to the same folder as the application.
If you are using more than one Zonums tool, I will recommend you to copy the bpl files to the Windows/system32 folder. This way you don't have to copy them to every Zonums application folder.
I found it does (ordinarily) work to put the BPL file(s) in the same directory as the app - and this works regardless of the flavor of Windows. However, through trial and error and a bit of research, I found the last paragraph to be a bit misleading:
It does also work to put all the BPL files into to Windows/system32 folder... but only for those using Windows NT, Windows 2000, or Windows XP. Otherwise (Windows 98/SE/ME), you should put these files into the Windows/System folder.
PS: In case you wondered what Zonum Solutions is about:
Hydraulics, Hydrology, Irrigation, Watershed management, CAD, Geographic Information Systems and Remote Sensing Tools.
Last edited by LifeMatrix on Wed, 1. Aug 07, 09:03, edited 1 time in total.
-
- Posts: 53
- Joined: Wed, 18. Feb 04, 07:34
Still more BPL file problems!
Anyway, after downloading RTL60.BPL and putting it into the JoyScript program directory, I tried to start the program again. However, this time I got a different error message!
Thinking this might have to do with the VCL60.BPL file mentioned, I checked my Windows folders and found a copy in Windows/System.
I tried again, this time placing a copy of RTL60.BPL into the Windows/system32 folder. But, nope, same error message! Around this time I read somewhere that for earlier Windows (98/SE/ME) the BPL files go into the Windows/System folder instead of Windows/system32. So I deleted the RTL60.BPL from system32 and placed a copy into System. But still, the same error!
Finally, I looked more closely at the VCL60.BPL file available from Zonum Solutions. I compared it with the version of VCL60.BPL that was already in my Windows/System directory and this is what I found:
* Version of VCL60.BPL on my PC was dated May 22, 2001, 12:00:00 AM
* Version of VCL60.BPL from Zonums.com was dated Feb 2, 2002, 12:00:00 AM
That was the whole problem. After renaming my old "VCL60.BPL" as "VCL60.BPL.bak" and then copying the more recent VCL60.BPL from Zonums.com in it's place, it worked like a charm. HURRAY!
Finally, as rare as downloads for RTL60.BPL are, note that there's also more than one version of this file floating around! I downloaded one version that was dated May 21, 2001, 10:00:00 PM. But the version I found to actually work is dated May 22, 2001, 12:00:00 AM, which is the same as the working VCL60.BPL file...
For your convenience (and in case the Zonums page disappears), here are the two files that JoyScript needs. These are compressed in ZIP format, so they download faster than those from Zonums. If you use Windows 98/SE/ME and get error messages like mine, just unzip these and extract the BPLs into your Windows/System folder.
Download rtl60.bpl.zip
Download vcl60.bpl.zip
What the...?! I'm thinking "'...CheckWin32Version'...? Is JoyScript even compatible with Windows 98/SE/ME?" Device not functioning? I checked and my joystick was plugged-in and fully functional.Error Starting Program
The VCL60.BPL file is
linked to missing export RTL60.BPL:@Sysutils@CheckWin32Version$qqrii.
C:\Program Files\JoyScript\JoyScript.exe
A device attached to the system is not functioning.
Thinking this might have to do with the VCL60.BPL file mentioned, I checked my Windows folders and found a copy in Windows/System.
I tried again, this time placing a copy of RTL60.BPL into the Windows/system32 folder. But, nope, same error message! Around this time I read somewhere that for earlier Windows (98/SE/ME) the BPL files go into the Windows/System folder instead of Windows/system32. So I deleted the RTL60.BPL from system32 and placed a copy into System. But still, the same error!

Finally, I looked more closely at the VCL60.BPL file available from Zonum Solutions. I compared it with the version of VCL60.BPL that was already in my Windows/System directory and this is what I found:
* Version of VCL60.BPL on my PC was dated May 22, 2001, 12:00:00 AM
* Version of VCL60.BPL from Zonums.com was dated Feb 2, 2002, 12:00:00 AM
That was the whole problem. After renaming my old "VCL60.BPL" as "VCL60.BPL.bak" and then copying the more recent VCL60.BPL from Zonums.com in it's place, it worked like a charm. HURRAY!

Finally, as rare as downloads for RTL60.BPL are, note that there's also more than one version of this file floating around! I downloaded one version that was dated May 21, 2001, 10:00:00 PM. But the version I found to actually work is dated May 22, 2001, 12:00:00 AM, which is the same as the working VCL60.BPL file...
For your convenience (and in case the Zonums page disappears), here are the two files that JoyScript needs. These are compressed in ZIP format, so they download faster than those from Zonums. If you use Windows 98/SE/ME and get error messages like mine, just unzip these and extract the BPLs into your Windows/System folder.
Download rtl60.bpl.zip
Download vcl60.bpl.zip