Jump to content

Zoom-In/Zomm-Out on PAC1 to make your life easier !


PeterP

Recommended Posts

Wanted to share this with all of you because I see often people asking how to use the zoom in a easier/effective way .... so:

 

Zoom-In/Zoom-Out on PAC1 to make your life easier !

(first posted here: http://forums.eagle.ru/showthread.php?p=1293475#post1293475)

Why don't use a macro for zoom-in/zoom-out instead of a slider ...and also automate the zoom in some kind of way?

Following is just a example - you can use it on a toggle-switch/button or bands -It don't has to be a Press/Release command.

 

This is what I did on my TM-Cougar using Foxy:

(read further if you have a Saitek-Controller )

 

BTN TG1  /P KD(p) <KD(KP*) DLY(800) KU(KP*)> 

             /R KU(p) <KD(KP/) DLY(800) KU(KP/)>

Explanation what this macro does:

 

KU = Key up

KD = Key down

DLY(800) = Delay-:hold the state that is posted before this "DLY" command for 800 millisecond (0.8sec) before execute the next state - as long the initial button is pressed

(KP/) - (KP*) = corresponding key-press on the num-pad : "*" and "/" - this is zoom-in and zoom-out in DCS A-10c

<> = what's between this brackets will be executed even if the button is released before the delay is timed out.

KU(p)-KD(p) = Key up "p" -Key down "p" : this initiate and releases the PAC1 state in DCS A-10c

 

I have this on the first stage of my trigger and it zooms in for 0.8sec and also enters the PAC-1 state.

When I release the trigger it releases the PAC-1 and zooms out for 0.8sec .

(Similar like gunsight in IL2)

 

This is very helpful while aiming at the target.

-and after I have fired the guns/rockets I will get back to my default zoom without having to fiddle around with a over-sensitive slider/rotary.

 

And I also use this to get a better look to the Mav/TGP image of the MFCDs when lookong into the cockpit and use it when I'm in the need of binoculars.

 

And you can also use a Toggle modifier (/T) instead the press/release (/P,/R).

But having it on the first stage trigger feels most natural to me.

 

 

 

How to do this on a Saitek Controller:

 

I made a video that explains my macro in the SST and shows how it reacts in DCS-A10c if set to the stage1 trigger:

 

Sorry for the German layout - but if you a smart-guy you will have no problems to follow the steps.

(I programmed it on a Saítek-Throttle-Quadrant - so I have no profile for a X52 to share.)

 

And you can also put it on a rotary or slider using bands. Or use it as a Toggle event.

 

If you have a TM-Warthog and adapt this for yourself and have also the time :

Please post how to do the same on TM-warthog with a small explanation !

 

EDIT:

 

Made autohotkey-script that works with every joystick.

 

Download autohotkey and use this script-

 

Binos-pess and hold.AHK:

 

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Recommended for catching common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

4Joy17:: ; This is my Bino toggle Jostick button = Jostick ID #4 Button 17 -change this to your new "Bino" button. 
        ; Use joystick test from autohotkey help to locate your button

SetKeyDelay, 60, 60

Loop 11 ; "11" is how long it will zoom in - change this to your liking - do the same in line #15
{
sendevent {NumpadMult Down}
} 
sendevent {NumpadMult Up} ; zoom in

KeyWait 4Joy17   ; Wait for the user to release the joystick button.

Loop 11 ; "11" is how long it will zoom out - change this to your liking - do the same in line #11
{
sendevent {NumpadDiv Down}
} 
sendevent {NumpadDiv Up} ; zoom out
return

 

And this is the variant to toggle zoom in/out with one key-press -

 

Toggle Zoom.AHK

 

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Recommended for catching common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.



cycle := 0
4Joy17:: ; This is my toggle Jostick button = Jostick ID #4 Button 17 
        ; change every following "4Joy17" expression to your Button ID! 
        ; Use joystick test from autohotkey help to locate your button

  cycle := cycle + 1

  if (cycle = 1) ; Zoom In

{
Loop 11 ; "11" is how long it will zoom in - change this to your liking - do the same in line #29
{
   Sleep, 10
   Sendevent {NumpadMult Down} ; Auto-repeat consists of consecutive down-events (with no up-events).
}
Sendevent {NumpadMult Up}
}


  if (cycle = 2) ; Zoom Out
  {
Loop 11 ; "11" is how long it will zoom in - change this to your liking - do the same in line #18
{
   Sleep, 10
   Sendevent {NumpadDiv Down} ; Auto-repeat consists of consecutive down-events (with no up-events).
}
Sendevent {NumpadDiv Up}
cycle := 0
}

return

 

Don't forget to edit it to your Button ID you want to use for "Binos"

>>> 4Joy17:: ; This is my Bino toggle Jostick button = Jostick ID #4 Button 17 -change this to your new "Bino" button.

; Use joystick test from autohotkey help to locate your button

 

Download these AHK scripts

 

If you found this useful you may want to check also this:

How to unchain the rudder from trim in DCS-BlackShark

 

How To: Remove centre detend from Saitek Pro Flight Rudder Paddles

 

corrupt calibration? crazy joystick response? Use this tools Fix it:

 

Drag/Drop and Click-able Radio Communication menu

 

Tweaked Cockpit view for DCS A-10C

Zoom in-out AHK script.zip


Edited by PeterP
  • Like 1

Link to comment
Share on other sites

I did this at Peter's request for someone to duplicate his zoom mapping in Target for Warthog owners. Please keep in mind that I am not a programmer and everything I know about Target I have learned in the past few days. With that in mind here is what I came up with.

 

This code uses an include file that defines all of the USB_ variables (util_usb.tmh attached). Put the file in the same folder as your tmc file.

 

You need this line near the top of your tmc file.

[color=black]include “util_usb.tmh" [/color]

Due to the influence and samples, including the attached file, that ivanwfr provided me with, I actually created this structure in multiple files to be included in the main tmc file but it can all be done in one file.

 

First declare some things:

[color=black][color=black]int ZOOMIN=0; int ZOOMOUT=0; int TG1_MO=0; int RTG1_MO=0;[/color]
[/color]

 

If you are going to put this in one file then the above needs to precede the 'int main()' line. The _MO stands for the default layer (Middle Out) but that does not matter in this example.

 

Then the real definitions:

 
// Zoom in and out event definitions.  Lock prevents interruptions

//Press KeyPad Asterisk, hold for 0.8 sec, release
ZOOMIN = CHAIN(LOCK+DOWN+USB_KP_ASTERISK,D(800),UP+USB_KP_ASTERISK,LOCK);

//Press KeyPad Slash, hold for 0.8 seconds, release
ZOOMOUT = CHAIN(LOCK+DOWN+USB_KP_SLASH,D(800),UP+USB_KP_SLASH,LOCK);

// Trigger Stage 1 Button Press and Release event definitions 
TG1_MO = CHAIN(DOWN+USB_P, ZOOMIN);   // Press P and do ZOOMIN event
RTG1_MO = CHAIN(UP+USB_P, ZOOMOUT);   // Release P and do ZOOMOUT event

 

Then the actual mapping of the events to the button:

 
MapKey(&Joystick, TG1, TG1_MO);  //Trigger stage 1 pressed
MapKeyR(&Joystick, TG1, RTG1_MO);  //Trigger stage 1 released

You can pile everything into the MapKey lines but then it is harder to read and keep track of what you are doing.

As I said I am not a programmer so if there is a better way to do this then I am not surprised. Hell, I am surprised that I figured this out. If it were not for ivanwfr, I might not have. Thanks Ivan.:thumbup:

 

I am not sure that this is useful to me. Not sure I want PAC1 engaged anytime I want to zoom in but I have not actually flown with it longer than it took to test.

 

I hope someone finds this useful. It helped me learn some things so it was worth the effort either way.:book:

 

NOTE: You might be able to duplicate this with the Target GUI but that environment is somewhat restrictive so I did not attempt to use it for this.

util_usb.zip


Edited by cichlidfan

ASUS ROG Maximus VIII Hero, i7-6700K, Noctua NH-D14 Cooler, Crucial 32GB DDR4 2133, Samsung 950 Pro NVMe 256GB, Samsung EVO 250GB & 500GB SSD, 2TB Caviar Black, Zotac GTX 1080 AMP! Extreme 8GB, Corsair HX1000i, Phillips BDM4065UC 40" 4k monitor, VX2258 TouchScreen, TIR 5 w/ProClip, TM Warthog, VKB Gladiator Pro, Saitek X56, et. al., MFG Crosswind Pedals #1199, VolairSim Pit, Rift CV1 :thumbup:

Link to comment
Share on other sites

As you said, and it's a smart move on your part, there's always another way to do things and I tried your code just for the fun of testing the auto zoom idea...

 

It works and is kind of fun to play with. But guess what... I had some issues ;)

 

I won't get into details here but the point was about delays handling when you press the trigger 1 + 2 stage all the way in at once in a very short time.

 

What happens is that the sim gets the second stage "Space" press but misses the release, resulting in Gun sustained firing.

 

I found a solution but with a level of coding using DeferCall() instead of Sleep():

 

The difference is that Sleep() just freezes everything and the Space key input is rushed down to 1 or 2 milliseconds.

 

Instead, DeferCall() is just postponing our zoom keys release and the space pulse keeps its default duration.

 

Another point would be about the effectiveness of this combined actions... as a first impression, it is more about fun than efficiency... but fun is good ;)

 

I included this util/util_PAC.tmc version into attached archive or this thread:

TARGET - Advanced programming

 

// PAC & ZOOM
// Note:
// Using sleep() instead of DeferCall() would make any intervening
// user key input duration down to 1 or 2 millisecond.
// Result is that key release is missed by the sim.
// ... In this case if you press Trigger first stage and second stage at once,
// Gun won't stop firing.

int pac_zoom_state  = 0;

int pac_zoom_toggle() {     // see js/js_MI.tmc for H2U mapping
   pac_zoom_state = (pac_zoom_state == 0); // toggle

   if(pac_zoom_state > 0) {
       flashLED(1);        // see util/util_led.tmc
   } else {
       flashLED(0);
       PAC_out();
   }
}

int PAC_in() {              // see js/js_MO.tmc for TG1_MO press
   ActKey(KEYON+ USB_P);   // PRESS [P] "Gun Trigger (first stage)" [HOTAS]
   if(pac_zoom_state > 0) zoom_in();
}

int PAC_out() {             // see js/js_MO.tmc for TG1_MO release
   if(pac_zoom_state > 0) zoom_out();
   ActKey(       USB_P);   // RELEASE
}

// ---------------
// PAC ZOOM IN-OUT
// ---------------
define ZOOM_PRESS_TIME  800
define ZOOM_IN_KEY      USB_KP_ASTERISK
define ZOOM_OUT_KEY     USB_KP_SLASH

int zoom_in() {
   ActKey(KEYON+ ZOOM_IN_KEY);
   DeferCall(ZOOM_PRESS_TIME, &deferedKeyRelease, ZOOM_IN_KEY);
}

int zoom_out() {
   ActKey(KEYON+ ZOOM_OUT_KEY);
   DeferCall(ZOOM_PRESS_TIME, &deferedKeyRelease, ZOOM_OUT_KEY);
}

int deferedKeyRelease(int key) {
   ActKey(key);
}


Edited by ivanwfr
Link to comment
Share on other sites

I must admit, it was late when I figured out what I was doing wrong and I never pulled the trigger beyond pac1 when I tried it out.

 

Also, I have not digested the parts of the manual beyond where is says "EXEC: Opening Pandora's Box".

 

I am still rather pleased with myself.:P

ASUS ROG Maximus VIII Hero, i7-6700K, Noctua NH-D14 Cooler, Crucial 32GB DDR4 2133, Samsung 950 Pro NVMe 256GB, Samsung EVO 250GB & 500GB SSD, 2TB Caviar Black, Zotac GTX 1080 AMP! Extreme 8GB, Corsair HX1000i, Phillips BDM4065UC 40" 4k monitor, VX2258 TouchScreen, TIR 5 w/ProClip, TM Warthog, VKB Gladiator Pro, Saitek X56, et. al., MFG Crosswind Pedals #1199, VolairSim Pit, Rift CV1 :thumbup:

Link to comment
Share on other sites

  • 1 month later...

Made autohotkey-script that works with every joystick.

 

Download autohotkey and use this script-

 

Binos-pess and hold.AHK:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Recommended for catching common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

4Joy17:: ; This is my Bino toggle Jostick button = Jostick ID #4 Button 17 -change this to your new "Bino" button. 
        ; Use joystick test from autohotkey help to locate your button

SetKeyDelay, 60, 60

Loop 11 ; "11" is how long it will zoom in - change this to your liking - do the same in line #15
{
sendevent {NumpadMult Down}
} 
sendevent {NumpadMult Up} ; zoom in

KeyWait 4Joy17   ; Wait for the user to release the joystick button.

Loop 11 ; "11" is how long it will zoom out - change this to your liking - do the same in line #11
{
sendevent {NumpadDiv Down}
} 
sendevent {NumpadDiv Up} ; zoom out
return

And this is the variant to toggle zoom in/out with one key-press -

 

Toggle Zoom.AHK:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Recommended for catching common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.



cycle := 0
4Joy17:: ; This is my toggle Jostick button = Jostick ID #4 Button 17 
        ; change every following "4Joy17" expression to your Button ID! 
        ; Use joystick test from autohotkey help to locate your button

  cycle := cycle + 1

  if (cycle = 1) ; Zoom In

{
Loop 11 ; "11" is how long it will zoom in - change this to your liking - do the same in line #29
{
   Sleep, 10
   Sendevent {NumpadMult Down} ; Auto-repeat consists of consecutive down-events (with no up-events).
}
Sendevent {NumpadMult Up}
}


  if (cycle = 2) ; Zoom Out
  {
Loop 11 ; "11" is how long it will zoom in - change this to your liking - do the same in line #18
{
   Sleep, 10
   Sendevent {NumpadDiv Down} ; Auto-repeat consists of consecutive down-events (with no up-events).
}
Sendevent {NumpadDiv Up}
cycle := 0
}

return

Don't forget to edit it to your Button ID you want to use for "Binos"

>>> 4Joy17:: ; This is my Bino toggle Jostick button = Jostick ID #4 Button 17 -change this to your new "Bino" button.

; Use joystick test from autohotkey help to locate your button

 

Download these AHK scripts


Edited by PeterP

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...