#4020955 - 10/10/14 10:14 PM
Warthog Views Script ?
|
Joined: Oct 2014
Posts: 7
Lightning
Junior Member
|
Junior Member
Joined: Oct 2014
Posts: 7
BC Canada
|
Hello Just by way of background, let me tell you that I have been a Thrustmaster user since the beginning, WAY back. I even wrote all the files used in the original Ver2 install disk from Thrustmaster for the FCS Pro / WCS Mark II. Have written MANY files for the F16 / F22 / Cougar systems. So you see I'm not just lazy, maybe it's cause I'm old (67) :), but I'm so far totally baffled by the programming language of my brand new Warthog Thought I could use Target software to program a simple H1 (Hat 1) file for views in FS9 / Combat Flight Simulator 1&2, but it doesn't allow for anything more than 4 positions, no angles. Tried to figure out Script Editor to no avail Thinking maybe I spent $800 for new setup and stand by mistake? Would someone please be so kind as to help me out with this? As you can see from below, all I want is to be able to have all 8 views with Button S3 as an "UP" modifier so I can do a little flying and combat. I have been away from flightsims for a few years but, would like to get my feet wet again. Again, any help would be VERY much appreciated. My Old File:- # FS2004.tmj Rem ################################################################# Rem Rem Flight Sim 2004 Rem for Rem Flight Sim 2004 Rem Rem by Robert "Lightning-=BS=-CO" Baum Rem Rem Last modified: 10 January 2004, 10:42 am Rem Rem Controllers: Thrustmaster Cougar Rem Rem ################################################################# Rem Rem This file works equally well with CFS1 or CFS2 Rem Views work as in Hat1 POV, with the S3 key as "UP" modifier. Rem All other buttons assigned in FS preferences Rem ################################################################# USE ALL_DIRECTX_BUTTONS USE MDEF #FS2004.tmm BTN H1U /P USB (D60 D5D) /R USB (U60 U5D) BTN H1UL /H KP7 BTN H1UR /H KP9 BTN H1L /H KP4 BTN H1R /H KP6 BTN H1D /H KP2 BTN H1DL /H KP1 BTN H1DR /H KP3 BTN S3 /H KP5
|
|
#4022066 - 10/14/14 09:31 AM
Re: Warthog Views Script ?
[Re: Lightning]
|
Joined: Oct 2010
Posts: 83
Nicu
Junior Member
|
Junior Member
Joined: Oct 2010
Posts: 83
|
Advice: use first the GUI to generate simple scripts, then examine the scripts to learn how they are made. Also, the manual have some good examples. Regarding your code, I tried to translate it (please let me know if I missed something). Normally the translation from FOXY is quite straightforward, but because you need the HAT corners and TARGET does not translate these corners to virtual keys, I needed to use the Event Handler. include "target.tmh"
//program startup
int main()
{
if(Init(&EventHandle)) return 1; // declare the event handler, return on error
POVKeys[0] = CHAIN(KP8, KP5);
MapKey(&Joystick, S3, KP5); // BTN S3 /H KP5
}
//event handler
int prevKey = -1;
int POVKeys[] = {KP8, KP9, KP6, KP3, KP2, KP1, KP4, KP7};
int EventHandle(int type, alias o, int x)
{
if((&o == &Joystick) & (x == POV))
{
if(prevKey != -1) ActKey(POVKeys[prevKey / 45]);
prevKey = o[x];
if(prevKey != -1) ActKey(KEYON + POVKeys[prevKey / 45]);
}
else DefaultMapping(&o, x);
}
|
|
#4024012 - 10/18/14 05:02 AM
Re: Warthog Views Script ?
[Re: Lightning]
|
Joined: Oct 2014
Posts: 7
Lightning
Junior Member
|
Junior Member
Joined: Oct 2014
Posts: 7
BC Canada
|
Thank you for the reply, just found it Will try it tomorrow. Got buttons programmed in 6 installs of FS9 and 3 of FSX using standard DX USB buttons and it works ok, but can't imagine Dog Fighting without my up diagonals (lose sight lose fight:) ) Can't wait to try your code in Combat Flight Sims (and later other Combat Sims as well) Been a long time since I did much flying, but I may even get back into War Birds etc. Thanks again. PS:- I did actually spend a bunch more time reading the manuals, but it hurt my old brain
|
|
#4030352 - 11/01/14 06:56 PM
Re: Warthog Views Script ?
[Re: Lightning]
|
Joined: Oct 2014
Posts: 7
Lightning
Junior Member
|
Junior Member
Joined: Oct 2014
Posts: 7
BC Canada
|
Ok, just now had a chance to try this. RL got in my way last couple of weeks Created FS9 Corner Views.tmc Ran it from TARGET Script Editor and it does indeed give me the corner views, and S3 gives up view, but S3 does not work as a modifier while in one of the other views. Whole idea is to be able to track a target in any view from just the S3 and the hat. If I just had one file that worked I hope that I could adapt this to any other flight sims I might want to fly. I had everything under the sun programmed on my old Thrustmaster joysticks, but this new Warthog is getting more and more frustrating
|
|
#4031032 - 11/03/14 02:03 PM
Re: Warthog Views Script ?
[Re: Lightning]
|
Joined: Oct 2010
Posts: 83
Nicu
Junior Member
|
Junior Member
Joined: Oct 2010
Posts: 83
|
Try to delete the following line from <main>: POVKeys[0] = CHAIN(KP8, KP5); I added it because your FOXY script seems to do it, but I don't see its meaning... Now, the script presses KP1,2,3,4,6,7,8,9 according with the HAT1 position, and KP5 when S3 is pressed. I can not test the script in game, as I don't have it installed. You can use <Event Tester> to verify if the keys are correctly generated, and to detail me what else do you need.
Last edited by Nicu; 11/03/14 02:04 PM.
|
|
#4034668 - 11/11/14 05:09 PM
Re: Warthog Views Script ?
[Re: Lightning]
|
Joined: Oct 2014
Posts: 7
Lightning
Junior Member
|
Junior Member
Joined: Oct 2014
Posts: 7
BC Canada
|
Hi Nico Been trying out your code (first one), but just noticed I am getting this error message. Running script: C:\Documents and Settings\PC Gamer\My Documents\Thrustmaster Files\TM Warthog Corner Views.tmc Compile Error: Name already defined: EventHandle in TM Warthog Corner Views.tmc at line 29
Sorry to be a pest but this whole process is just beyond my programming skills
Last edited by Lightning; 11/11/14 05:11 PM.
|
|
#4034964 - 11/12/14 08:03 AM
Re: Warthog Views Script ?
[Re: Lightning]
|
Joined: Oct 2010
Posts: 83
Nicu
Junior Member
|
Junior Member
Joined: Oct 2010
Posts: 83
|
No problem. Maybe you copied the EventHandle function from my last post over the script from my first one, instead of simply adding o[x]=-1 as indicated. I will give you the full script again, just get it and replace the old one with this: include "target.tmh"
//program startup
int main()
{
if(Init(&EventHandle)) return 1; // declare the event handler, return on error
// POVKeys[0] = CHAIN(KP8, KP5);
MapKey(&Joystick, S3, KP5); // BTN S3 /H KP5
}
//event handler
int prevKey = -1;
int POVKeys[] = {KP8, KP9, KP6, KP3, KP2, KP1, KP4, KP7};
int EventHandle(int type, alias o, int x)
{
if((&o == &Joystick) & (x == POV))
{
if(prevKey != -1) ActKey(POVKeys[prevKey / 45]);
prevKey = o[x];
if(prevKey != -1) ActKey(KEYON + POVKeys[prevKey / 45]);
o[x] = -1;
}
else DefaultMapping(&o, x);
}
|
|
#4036340 - 11/15/14 06:05 PM
Re: Warthog Views Script ?
[Re: Lightning]
|
Joined: Oct 2014
Posts: 7
Lightning
Junior Member
|
Junior Member
Joined: Oct 2014
Posts: 7
BC Canada
|
Hello again. I have tried this code in Target Script editor (FS9 Corner Views.tmc)
//Code: include "target.tmh"
//program startup int main() { if(Init(&EventHandle)) return 1; // declare the event handler, return on error POVKeys[0] = CHAIN(KP8, KP5); MapKey(&Joystick, S3, KP5); // BTN S3 /H KP5 }
//event handler int prevKey = -1; int POVKeys[] = {KP8, KP9, KP6, KP3, KP2, KP1, KP4, KP7}; int EventHandle(int type, alias o, int x) { if((&o == &Joystick) & (x == POV)) { if(prevKey != -1) ActKey(POVKeys[prevKey / 45]); prevKey = o[x]; if(prevKey != -1) ActKey(KEYON + POVKeys[prevKey / 45]); o[x] = -1; } else DefaultMapping(&o, x); }
Compiles and runs without errors. All views are perfect, but the thing is...none of the axis (joystick or throttle) do anything. Don't show any movement in Windows Game Controller applet, or in game. What am I doing wrong here? Can I not just run the script from the Target Script Editor? Can I add this to an .FCF file and run from Target GUI? Again thanks for your patience and help.
Last edited by Lightning; 11/15/14 06:13 PM.
|
|
#4036581 - 11/16/14 10:15 AM
Re: Warthog Views Script ?
[Re: Nicu]
|
Joined: Dec 2000
Posts: 529
RogueSqdn
USAF Veteran
|
USAF Veteran
Member
Joined: Dec 2000
Posts: 529
Advance, NC
|
I'm wanting to do something similar in X-wing & in TIE Fighter, but using KP5 as the up position, and I want KP8 to be pressed/released when there is no active button on H1. I changed KP8 to 5 in the code for int POVKeys. Can you figure a way for KP8 to be pressed once nothing else is being pressed on H1? include "target.tmh"
//program startup
int main()
{
if(Init(&EventHandle)) return 1; // declare the event handler, return on error
}
//event handler
int prevKey = -1;
int POVKeys[] = {KP5, KP9, KP6, KP3, KP2, KP1, KP4, KP7};
int EventHandle(int type, alias o, int x)
{
if((&o == &Joystick) & (x == POV))
{
if(prevKey != -1) ActKey(POVKeys[prevKey / 45]);
prevKey = o[x];
if(prevKey != -1) ActKey(KEYON + POVKeys[prevKey / 45]);
o[x] = -1;
}
else DefaultMapping(&o, x);
}
Jared ----- FalconNW MachV, Obutto R3volution
DEFENSOR FORTIS
|
|
#4036835 - 11/16/14 11:42 PM
Re: Warthog Views Script ?
[Re: RogueSqdn]
|
Joined: Oct 2014
Posts: 7
Lightning
Junior Member
|
Junior Member
Joined: Oct 2014
Posts: 7
BC Canada
|
Seems to me when I programmed the hat views for X-Wing in the Cougar, or was it the F22, I had to do a... Press KP9 (etc.) and then a Release KP8 ? No idea at all how to do this with this maddening Warthog programming Hope this might be of help to you. Let me know how you make out, cause I just bought and started playing GOG X-Wing and TIE Fighter myself. Can't believe I didn't save my "General.plt" files with ALL medals etc. from X-Wing DOS, as I save everything
Last edited by Lightning; 11/16/14 11:43 PM.
|
|
#4036837 - 11/16/14 11:46 PM
Re: Warthog Views Script ?
[Re: Lightning]
|
Joined: Dec 2000
Posts: 529
RogueSqdn
USAF Veteran
|
USAF Veteran
Member
Joined: Dec 2000
Posts: 529
Advance, NC
|
I fiddled around with the above script, and I couldn't figure out how to make it execute KP8 when there is no active position on H1 (sort of like having an H1M). If you were only doing four directions, it would be pretty easy, because you could simply program a release action on each direction.
Jared ----- FalconNW MachV, Obutto R3volution
DEFENSOR FORTIS
|
|
#4036842 - 11/17/14 12:05 AM
Re: Warthog Views Script ?
[Re: Lightning]
|
Joined: Dec 2000
Posts: 529
RogueSqdn
USAF Veteran
|
USAF Veteran
Member
Joined: Dec 2000
Posts: 529
Advance, NC
|
I just figured the thing out! Here's the script:
include "target.tmh"
//program startup
int main()
{
if(Init(&EventHandle)) return 1; // declare the event handler, return on error
}
//event handler
int prevKey = -1;
int POVKeys[] = {KP5, KP9, KP6, KP3, KP2, KP1, KP4, KP7};
int EventHandle(int type, alias o, int x)
{
if((&o == &Joystick) & (x == POV))
{
if(prevKey != -1) ActKey(POVKeys[prevKey / 45]);
prevKey = o[x];
if(prevKey != -1) ActKey(KEYON + POVKeys[prevKey / 45]);
o[x] = -1;
if(prevKey == -1) ActKey(KEYON + PULSE+USB[0x60]);
o[x] = -1;
}
else DefaultMapping(&o, x);
}
The added part: if(prevKey == -1) ActKey(KEYON + PULSE+USB[0x60]); o[x] = -1;
Doing this seems to execute KP8 whenever H1 is released, but won't execute it if you're simply moving from one direction to the other. It waits until you completely release the hat. This has been one of my biggest frustrations with TARGET, compared to Foxy.
Last edited by RogueSqdn; 11/17/14 12:09 AM.
Jared ----- FalconNW MachV, Obutto R3volution
DEFENSOR FORTIS
|
|
#4036952 - 11/17/14 10:37 AM
Re: Warthog Views Script ?
[Re: Lightning]
|
Joined: Dec 2000
Posts: 529
RogueSqdn
USAF Veteran
|
USAF Veteran
Member
Joined: Dec 2000
Posts: 529
Advance, NC
|
I didn't want KP8 executing every time the hat changed directions, only when it was completely released. Would your suggestion do that, or would it spit out KP8 as you were moving it around?
Thanks for the script!
Jared ----- FalconNW MachV, Obutto R3volution
DEFENSOR FORTIS
|
|
#4036958 - 11/17/14 11:12 AM
Re: Warthog Views Script ?
[Re: Lightning]
|
Joined: Dec 2000
Posts: 529
RogueSqdn
USAF Veteran
|
USAF Veteran
Member
Joined: Dec 2000
Posts: 529
Advance, NC
|
Ok thanks. I only have one more question about this then. Is it possible to have shifted actions on the hat with this script? It's not the end of the world if I can't, but it would be nice.
For instance, X-Wing has an angle modifier of KP. that lets you look up 45 degrees, and if I can I'd like to put it as H1U, shifted with S3.
Jared ----- FalconNW MachV, Obutto R3volution
DEFENSOR FORTIS
|
|
#4036962 - 11/17/14 11:37 AM
Re: Warthog Views Script ?
[Re: Lightning]
|
Joined: Oct 2010
Posts: 83
Nicu
Junior Member
|
Junior Member
Joined: Oct 2010
Posts: 83
|
You can have shifted actions, in fact you can have whatever you want with the script. I changed the EventHandler to allow S3 as shift (you may change the content of POVKeysShifted as you need): //event handler
int prevKey = -1;
int POVKeys[] = {KP8, KP9, KP6, KP3, KP2, KP1, KP4, KP7};
int POVKeysShifted[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'};
int EventHandle(int type, alias o, int x)
{
if((&o == &Joystick) & (x == POV))
{
if(prevKey != -1) ActKey(prevKey);
if(o[x] != -1)
{
if(Joystick[S3]) prevKey = POVKeysShifted[o[x] / 45];
else prevKey = POVKeys[o[x] / 45];
ActKey(KEYON + prevKey);
}
else ActKey(KEYON + PULSE+USB[0x60]);
o[x] = -1;
}
else DefaultMapping(&o, x);
}
|
|
|
|