Dudikoff Posted August 17, 2016 Posted August 17, 2016 (edited) Just got some TM MFD's so I'm playing around with the Target scripting and immediately ran into a problem. If I invoke multiple key pulse presses in a loop (so the number of times it is invoked varies according to some variable), it only gets invoked once for some reason. Is there a way this can be done without having to CHAIN them? E.g. I map an MFD key to invoke a function which has a while loop as so: define SomeKey USB[whatever] int counter = 0; int main() { MapKey(&LMFD, OSB1, EXEC("doSomething();")); } int doSomething() { while (counter < 2) { ActKey(PULSE+KEYON+SomeKey); counter = counter + 1; } } I added some printf's and saw that the loop part does get invoked twice, but the key only gets pressed once for some reason. And if I use ActKey(KEYON+SomeKey); ActKey(SomeKey); it gets pressed twice, but the DCS doesn't catch it as presumably the key press is rather short. I also tried the DeferCall(100,&ActKey,PULSE+KEYON+SomeKey); but no dice. I'm thinking I could CHAIN two pulses or these on/off presses with some delay in between, but AFAIK I can't invoke CHAIN directly (only as part of the MapKey definition) and I'm not aware of how to insert a delay in the code (the "Generating keystrokes with pure script" chapter doesn't really go further than what I've tried already). Is there a way to do this within these functions or I have to ditch the loop and then invoke either a single key press or a chained one depending on the exact variable value? Thanks :) BTW, I saw some code examples like "&Joy = GetIndexJoy (SelectUsbDevice ("VID_044F&PID_B10A"));". I don't suppose it might be possible to use e.g. a Saitek joystick's DX key press as a shift switch in Target in some way? Edited August 17, 2016 by Dudikoff i386DX40@42 MHz w/i387 CP, 4 MB RAM (8*512 kB), Trident 8900C 1 MB w/16-bit RAMDAC ISA, Quantum 340 MB UDMA33, SB 16, DOS 6.22 w/QEMM + Win3.11CE, Quickshot 1btn 2axis, Numpad as hat. 2 FPH on a good day, 1 FPH avg. DISCLAIMER: My posts are still absolutely useless. Just finding excuses not to learn the F-14 (HB's Swansong?). Annoyed by my posts? Please consider donating. Once the target sum is reached, I'll be off to somewhere nice I promise not to post from. I'd buy that for a dollar!
Thermal Posted August 18, 2016 Posted August 18, 2016 Have a look at this: http://forums.eagle.ru/showthread.php?t=161759 Its not doing a "while", and you cannot interrupt it once it executes. But if you simply wish to "chain" some commands, that will do it. int counter = 0; int main() { MapKey(&LMFD, OSB1, EXEC("doSomething();")); } int doSomething() { while (counter < 200) { ActKey(DeferCall(counter, &ActKey, PULSE+KEYON+F3 )); counter = counter + 100; } counter = 0; }
Dudikoff Posted August 18, 2016 Author Posted August 18, 2016 Have a look at this: http://forums.eagle.ru/showthread.php?t=161759 I'll try that tonight, thanks. i386DX40@42 MHz w/i387 CP, 4 MB RAM (8*512 kB), Trident 8900C 1 MB w/16-bit RAMDAC ISA, Quantum 340 MB UDMA33, SB 16, DOS 6.22 w/QEMM + Win3.11CE, Quickshot 1btn 2axis, Numpad as hat. 2 FPH on a good day, 1 FPH avg. DISCLAIMER: My posts are still absolutely useless. Just finding excuses not to learn the F-14 (HB's Swansong?). Annoyed by my posts? Please consider donating. Once the target sum is reached, I'll be off to somewhere nice I promise not to post from. I'd buy that for a dollar!
Dudikoff Posted August 19, 2016 Author Posted August 19, 2016 It worked if I introduced a variable delay in the consecutive invocations of the DeferCall. I suppose the software or the driver is intentionally filtering out key invocations of the identical type to avoid unintended double-taps. i386DX40@42 MHz w/i387 CP, 4 MB RAM (8*512 kB), Trident 8900C 1 MB w/16-bit RAMDAC ISA, Quantum 340 MB UDMA33, SB 16, DOS 6.22 w/QEMM + Win3.11CE, Quickshot 1btn 2axis, Numpad as hat. 2 FPH on a good day, 1 FPH avg. DISCLAIMER: My posts are still absolutely useless. Just finding excuses not to learn the F-14 (HB's Swansong?). Annoyed by my posts? Please consider donating. Once the target sum is reached, I'll be off to somewhere nice I promise not to post from. I'd buy that for a dollar!
Recommended Posts