CH Control Manager Scripting

Hey there,

A few months ago I bough a used CH Products HOTAS set consisting of the Fighterstick, the Pro Throttle and the ProPedals.
So far I am happy with it.

Until now I directly mapped the buttons and axis of the three devices directly in the targeted game, which works fine.

I was too lazy to dig into CH Control Manager.

Now I found some spare time and started working with it. Especially the CMS scripting capabilities seem to be very nice.

I have something in mind to “develop” but I cannot seem to get it to work.

Is here anyone capable of scripting with the CH stuff?

Cheers and thanks

Chris

2 Likes

No ised the software and it was poweeful enough without scripting!

What do tou want to do?

Well, i know that I need scripting :wink:
I want to use on of the hats on the throttle to switch modes and additionally let it press a key when the mode is entered depending on the previous mode etc.

the first part is pretty easy (as it is also an example in the documentation). The second part with the stateful button presses is complicated, but should be possible.

I just need a veteran ch guy to push me in the right direction :wink:

What sim are you using? If DCS, you can map a button to change modes.

Ok. This is specifically for the DCS Hornet.
As you probably know, the Hornet AA and AG mode is activated by pressing the respective cockpit button. They are mapped to 1 respectively 2 on the keyboard. Now when you want to leave a mode you just press the button AGAIN (or select the other mode). So from AA back to NAV you press 1 again.

Now I want my HOTAS to do that including the internal mode switching.
Press the HAT up, and enter AA mode (= press “1”). Press it up again, do NOT leave AA mode (= do not press “1”).
Press the HAT forward and leave AA mode (= press “1”) or do nothing if already in that mode.
The internal mode switching is no big deal, but the state keeping and managing is difficult.

I am actually very close but it is not working reliably…

I am quite confident you cannot achieve that with DCS built in functions.

When you say “switch modes”, are you referring only to the DCS aircraft, the CH HOTAS, or both?

Forget the fact that I want to switch the hornet modes…
Maybe a a simpler view:

I want to switch hardware mode (which is easy and implemented) upon a button press on the stick. This is achievable with a simple CMS script. Done.

Upon entering a mode though, I want to press a another key (= press and release a CMS Button) only the first time I enter that mode. Subsequent mode activations must not activate subsequent button presses.

That’s the broken down requirement / use case

That should actually be pretty easy. Try this:

Open CM Editor and copy this script:

// CMS Script File
//
// Game Title:
// Written By:
// Date:
//
script
cms.b1 = jsx.bx;
endScript

Where “x” is your throttle number, probably “3”, and the corresponding hat “button” respectively. Now, open the CMS Controls tab and click “Button 1” under “Buttons”. Now, enter the “Keystroke” you desire for each respective “Mode” under the “Mode” tabs.

That should do it.

Let me know if it works.

Ah yes that is already knowledge i gained :wink:

I have much more of a problem with handling the state of “pressed js1.bx for the first time so press CMS.b1 ” vs “pressed js1.bx for the second or further times so do not press CMS.b1”

OK, so you want the first press to activate CMS.b1, but to ignore CMS.b1 for every press afterwards?

Yes Sir!
Basically

I’ve never tried to do what your describing, but I’ll work on it and see what I can come up with.

Cool, thx dude but no inconveniences please :slight_smile:
I came up with an idea in my head, but did not find time to work on it today:

I simply introduce more CMS buttons with the desired button presses only existing in suitable modes so that I can trigger them as desired.

I actually dont have issues with implementing the desired logic in general (I am a java enterprise Developer) but I struggle with how the scripts are working in general. A simple „press and release CMS.b1 now“ seems to be very counterintuitive…

Argh this is such a stupid nonsense. Nothing I try seem to work. And ZERO useful resources.

I’ve only used the CH CM to combine sticks into one unified device, but it almost sounds like you need to bind it to keyboard functions. What you’re describing should be possible and I’m actually playing around with it now. Are you using it in DX mode?

It seems that the theory should be to make it do one button press the first time, then after that rebind the press on the fly to something not being used.

No, I am using mapped mode.
I am fiddling around with “PULSE” and an OFFDELAY Timer. Might be a step into the right direction :slight_smile:

The script “loop” is not very intuitive when it comes to press buttons from within the script, but I think I might have got my head around it finally.

I will come back with an working example - if I get one :wink:

BANG, Here it comes.

 // CMS Script File
//
//     Game Title:
//     Written By:
//           Date:
//
%DEFINE TIMER_DELAY 2

// switch definition for mode switching
%DEFINE MODE_SWITCH_NONE JS1.B9
%DEFINE MODE_SWITCH_AA JS1.B12
%DEFINE MODE_SWITCH_AG JS1.B10
%DEFINE MODE_SWITCH_GROUND JS1.B11

// buttons on the CMS that will be pressed
%DEFINE BUTTON_AA_MODE CMS.B1
%DEFINE BUTTON_AG_MODE CMS.B2

// state variables if a button must be pressed
%DEFINE PRESS_AA_MODE B1
%DEFINE PRESS_AG_MODE B2

// state variables in which mode we are.
%DEFINE IN_AA_MODE B3
%DEFINE IN_AG_MODE B4

// device variables that connect everything.
%DEFINE AA_MODE_PULSE D1
%DEFINE AG_MODE_PULSE D2
%DEFINE AA_MODE_TIMER D3
%DEFINE AG_MODE_TIMER D4


script
// cause ONE pulse when the "press_xy" variable goes true.
PULSE( AA_MODE_PULSE ) = PRESS_AA_MODE;
PULSE( AG_MODE_PULSE ) = PRESS_AG_MODE;

// leave the xy_timer variable true for "timer_delay" cycles when the pulse is toggled.
TIMER( OFFDELAY, AA_MODE_TIMER, TIMER_DELAY ) = AA_MODE_PULSE;
TIMER( OFFDELAY, AG_MODE_TIMER, TIMER_DELAY ) = AG_MODE_PULSE;

// press the respective CMS button when the timer variable goes to true.
BUTTON_AA_MODE = AA_MODE_TIMER;
BUTTON_AG_MODE = AG_MODE_TIMER;

// if mode "none"
if(MODE_SWITCH_NONE) then
  // bring everything to physical MODE1
  CURRENTMODE = MODE1;
  // no need to press anything initially.
  PRESS_AA_MODE = FALSE;
  PRESS_AG_MODE = FALSE;
  // if coming from AA Mode
  if(IN_AA_MODE) then
    // press AA Mode Button again.
    PRESS_AA_MODE = TRUE;
    // not in AA Mode anymore.
    IN_AA_MODE = FALSE;
  endif
  // Same But for AG Mode.
  if(IN_AG_MODE) then
    PRESS_AG_MODE = TRUE;
    IN_AG_MODE = FALSE;
  endif
endif

// Now if we want AA Mode.
if(MODE_SWITCH_AA) then
  // bring everything to physical MODE2
  CURRENTMODE = MODE2;
  // No need to press AG button
  PRESS_AG_MODE = FALSE;
  // definetly not in AG anymore.
  IN_AG_MODE = FALSE;
  // if already in AA, press nothing
  if(IN_AA_MODE) then
    PRESS_AA_MODE = FALSE;
  else
    // if not, let's enter AA Mode and press AA Button.
    PRESS_AA_MODE = TRUE;
    IN_AA_MODE = TRUE;
  endif
endif

// 100% the same logic but for AG!
if(MODE_SWITCH_AG) then
  CURRENTMODE = MODE3;
  PRESS_AA_MODE = FALSE;
  IN_AA_MODE = FALSE;
  if(IN_AG_MODE) then
    PRESS_AG_MODE = FALSE;
  else
    PRESS_AG_MODE = TRUE;
    IN_AG_MODE = TRUE;
  endif
endif


endScript

Difficult to read without the nice syntax colors…

What it essentially does is (for AA for example)

Register a PULSE bound to the “PRESS_AA_MODE” variable.
When this variable becomes TRUE, it will cause ONE Pulse on the AA_MODE_PULSE variable.
This will cause a timer to run for 2 cycles which will pull the AA_MODE_TIMER variable to TRUE.
This is necessary because the PULSE is too short to be reigstered as a command (you find this stuff in the help docs…).

Now the AA-CMS Button is connected to the AA_MODE_TIMER variable, hence it will be pressed as long as the TIMER is TRUE (for 2 cycles it is…)

The “if-else” Logic covers when which PRESS_XY_MODE variable must be set to TRUE to cause a PULSE…

What it really does is useful for the DCS Hornet:
You press the MODE_SWITCH_AA, and will trigger a press for the Key “1” (which is AA Mode in the plane).
Now if you press the switch again, you don’t wann press “1” again, as it would leave the plane’s AA Mode.
Instead, you want to press “1” only if you LEAVE the plane’s AA Mode (as it works like this).

Stateful Mode switching you can call it.

Have fun whoever needs this :wink:

1 Like