|
|
|
#3568566 - 05/06/12 11:49 PM
Help needed: Thrustmaster TARGET programming: axis with keystrokes
|
Junior Member
Registered: 05/06/12
Posts: 2
Loc: Slovenia
|
I am a returning flight sim pilot, after 10 years. Back in the day, I owned a set of Thrustmaster F16 FLCS + F16 TQS and CH Pedals, and this awesome setup got me through Flight Unlimited (1, 2 and 3), MS Flight simulator, Eurofighter, Falcon 3.0 and several great space sims such as Wing Commander 3, 4, 5, Privateer 2 etc. Alas, I had to sell that setup, but now, 10 years later, I decided to return, and in style:
I am about to get a TM Hotas Warthog + Saitek Pro Flight Combat rudder pedals. Later, TrackIR and maybe Cougar panels.
Anyway, as I'd like to revisit those great days of nostalgia, I am now making a TARGET profile for Wing Commander IV (don't worry, other more serious flight sims are also on the agenda).
The problem is: the game does not support analogue throttles and the only commands for throttle control it understands is 'Backspace' (throttle to zero), '+' and '-' for throttle control (which is very inprecise) and '\' (throttle to full), plus afterburners.
The TARGET software allows two different methods of programming keystrokes onto an analogue axis (such as the throttle).
1. Axmap1: you set the keystroke for when you're pushing the throttle up and a different one for when you're pulling it back; you also set the number of keystrokes, which get distributed along the axis (for instance, 5 means you'll get 5 keystrokes from idle to full). This method is great as you can set different keystrokes for pushing the throttle forward or pulling it back. Example: when you push forward, the throttle gives a series of '+' keystrokes. When you pull the throttle back, it gives a series of '-' keystrokes. This is great, but WCIV '+' and '-' is very inprecise and I have no idea how many 'pulse' keystrokes it takes to dial the throttle to full in the game - I would like the throttle to use the full range of its axis and at the same time I would like to get enough keystrokes to be able to push the engines to 100% or back to 0%.
2. Axmap2: you set 'zones'; for instance: at throttle 0-10% you can set 'Backspace', 90-100% you can set \. This gives you zero throttle at the idle position and full throttle at maximum. However, I can't find a way to make the middle zone work like Axmap1 (to get '+' keystrokes when pushing the throttle forward and get '-' keystrokes when pulling it back), as this method is intended for setting different keystrokes along the axis (for instance, you can set a series of 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, if the simulation uses those keys for incremental throttle control; as you move the throttle along the axis, it always presses the same keystroke at the same position, regardless of whether you're pushing the throttle forward or pulling it back).
What I would like to get: when I pull the throttle back to 0-10%, I'd like to get a 'Backspace' command so the throttle tells the game to stop engines. when I push the throttle forward from 10% to 90%, I want a sequence of 20 keystrokes of '+', evenly distributed along those 80% of the axis. - this should provide a smooth acceleration. when I pull the throttle back from 90% to 10%, I want a sequence of 20 keystrokes of '-', evenly distributed along those 80% of the axis. - this should provide a smooth DEceleration. when I push the throttle forward, over 90% (and up to 100%), I want to get a '\' command, which should tell the game to push the engines to full throttle.
From what I see, the ideal thing would be to somehow combine both methods of programming (Axmap1 and 2). I don't know if this is possible (or HOW to do it, atleast not within the GUI), but an ideal way would be to create (in Axmap2) three separate zones (0-10% for Backspace, 90-100% for \, and the third zone in between), and somehow apply the Axmap1 routine (+ and -, depending on the direction of movement of the throttle) to the middle zone.
If there's anyone on this forum with the know-how of the TARGET software and Thrustmaster script programming, I'd greatly appreciate it if you could take a look at my little problem here...
|
|
Top
|
|
|
|
#3576776 - 05/21/12 02:36 PM
Re: Help needed: Thrustmaster TARGET programming: axis with keystrokes
[Re: ishtmail]
|
Member
Registered: 03/08/07
Posts: 293
|
Well, I am new to Target also, I have no much experience.
Partial solution:
The Warthog as an Idle button, you can program it to stop the engines.
If I recall correctly, you can read the axis current value, if it reaches 100 then you can send the afterburner command.
Possible solution:
Maybe It could be possible to have both commands Axmap1 and Axmap2 on the same file. I suspect those functions read the axis position and then generate the keystrokes, so both call are independent, but will produce merged outputs.
|
|
Top
|
|
|
|
#3647322 - 09/19/12 11:41 PM
Re: Help needed: Thrustmaster TARGET programming: axis with keystrokes
[Re: ishtmail]
|
Member
Registered: 03/08/07
Posts: 293
|
Try this:
float AxisValue;
int Zone;
int EventHandle(int type, alias o, int x)
{
//add event handling code here
if ((&o == &Throttle) & (x == THR_RIGHT)) // Isolate the event. Use only right throttle.
{
AxisValue = Throttle[THR_RIGHT]; // Get the axis value;
if (AxisValue > 11000)
{
if (Zone != 21)
ActKey(PULSE+KEYON+'/');
Zone = 21; // AfterBurner
}
if ((AxisValue >= 8090) & (AxisValue < 10240))
{
if (Zone != 20)
{
if (Zone == 19)
{
ActKey(PULSE+KEYON+'+');
}
Zone = 20; // Last Normal Zone
}
}
if ((AxisValue >= 5940) & (AxisValue < 8090))
{
if (Zone != 19)
{
if (Zone == 18)
{
ActKey(PULSE+KEYON+'+');
}
else
{
ActKey(PULSE+KEYON+'-');
}
Zone = 19;
}
}
if ((AxisValue >= 3790) & (AxisValue < 5940))
{
if (Zone != 18)
{
if (Zone == 17)
{
ActKey(PULSE+KEYON+'+');
}
else
{
ActKey(PULSE+KEYON+'-');
}
Zone = 18;
}
}
// Other Zones, decrease each by 2150.
if ((AxisValue >= -30610) & (AxisValue < -28460))
{
if (Zone != 2)
{
if (Zone == 1)
{
ActKey(PULSE+KEYON+'+');
}
else
{
ActKey(PULSE+KEYON+'-');
}
Zone = 2;
}
}
if (AxisValue < -30610)
{
if (Zone != 1)
{
if (Zone == 2)
{
ActKey(PULSE+KEYON+'-');
}
Zone = 1; // First Normal Zone;
}
}
};
DefaultMapping(&o, x);
}
Edited by Aullido (09/19/12 11:45 PM)
|
|
Top
|
|
|
|
#3647430 - 09/20/12 05:47 AM
Re: Help needed: Thrustmaster TARGET programming: axis with keystrokes
[Re: ishtmail]
|
Junior Member
Registered: 10/31/10
Posts: 40
|
int tfn(int down)
{
if(down)
if(Throttle[THR_LEFT]*5 < -4*AMAX) ActKey(KEYON + PULSE + BSP);
else ActKey(KEYON + PULSE + USB[86]);
else
if(Throttle[THR_LEFT]*5 > 4*AMAX) ActKey(KEYON + PULSE + '\\');
else ActKey(KEYON + PULSE + USB[87]);
}KeyAxis(&Throttle, THR_LEFT, 0, AXMAP1(LIST(0,10,14,18,22,26,30,34,38,42,46,50,54,58,62,66,70,74,78,82,86,90,100), EXEC("tfn(0);"), EXEC("tfn(1);")));
|
|
Top
|
|
|
|
#3663750 - 10/16/12 08:47 AM
Re: Help needed: Thrustmaster TARGET programming: axis with keystrokes
[Re: ishtmail]
|
Junior Member
Registered: 10/31/10
Posts: 40
|
If the axis is quickly moved, the key rate may be such as not all key pulses are generated (because the pulse duration is bigger than the interval between keys). In this case, a circular key queue can be implemented, as follows: include "target.tmh"
define QSIZE 64 // queue size
//program startup
int main()
{
if(Init(&EventHandle)) return 1; // declare the event handler, return on error
//add initialization code here
AutoRepeat(0, kb_delay, &qget, &queue); // continuously poll the queue. <kb_delay> contains the default pulse duration, defined in <target.tmh>
KeyAxis(&Throttle, THR_LEFT, 0, AXMAP1(LIST(0,10,14,18,22,26,30,34,38,42,46,50,54,58,62,66,70,74,78,82,86,90,100), EXEC("tfn(0);"), EXEC("tfn(1);")));
}
int tfn(int down)
{
if(down)
if(Throttle[THR_LEFT]*5 < -4*AMAX) qput(&queue, KEYON + PULSE + BSP); // put the key in queue, instead pressing it with ActKey
else qput(&queue, KEYON + PULSE + USB[86]); // put the key in queue, instead pressing it with ActKey
else
if(Throttle[THR_LEFT]*5 > 4*AMAX) qput(&queue, KEYON + PULSE + '\\'); // put the key in queue, instead pressing it with ActKey
else qput(&queue, KEYON + PULSE + USB[87]); // put the key in queue, instead pressing it with ActKey
}
struct sQueue
{
int head;
int tail;
int q[QSIZE];
}
sQueue queue = {0,0};
int qput(alias q, int v) // put a key in queue
{
int t = (q.tail + 1) % QSIZE;
if(t == q.head) return 0;
int pq; Map(&pq, &&q.q); Dim(&pq, QSIZE);
pq[q.tail] = v;
q.tail = t;
}
int qget(alias q) // get a key from queue and press it
{
if(q.head == q.tail) return 0;
int pq; Map(&pq, &&q.q); Dim(&pq, QSIZE);
ActKey(pq[q.head]);
q.head = (q.head + 1) % QSIZE;
}
//event handler
int EventHandle(int type, alias o, int x)
{
DefaultMapping(&o, x);
//add event handling code here
}
Edited by Nicu (10/16/12 08:55 AM)
|
|
Top
|
|
|
|
|
|
| |