RaceDepartment Store

Do you ever race in VR?

  • Yes

    Votes: 400 35.1%
  • No

    Votes: 738 64.9%

Upcoming Events

AC events on Simracing.GP ACC events on Simracing.GP R3E events on Simracing.GP Weekly rFactor 2 events Join TCR Virtual today!

How to make a command depend on the position of a toggle switch?

All, I am looking for a way to use toggle switches 'correctly' for things like ignition, lights, wipers etc. this would apply to AMS, AMS2, AC and ACC primarily.

There are a number of commands that are 'toggle' by default, by which I mean you press the same button to change the state; an example is ignition in ACC, you press once to turn it on, then press again to turn it off. What I want is to either have a separate command for on and for off (which has a potential issue I will discuss further down) or that the command is conditional on being constantly pressed to activate the particular command.

In the original rFactor there was a checkbox that was 'hold for gear' which did exactly that, so that unless you actually had the gear button pressed it would default back to neutral. In a similar way, having the ignition set so that when the ignition switch is in the on position the ignition is live, then off when moved away from the on position is what I want.

The alternative of having separate on and off commands allocated to the individual switch positions is also OK, except I am worried that the continual pressing of that command by having the switch fixed in that position may cause issues in the control setup (I know AMS has that issue from a controller probelm I had) and also I am worried that in game the constant pressing of the command may conflict with other commands. I think I may be able to resolve this particular issue with capacitors, I would have to test to see.

In the flight sim I use (DCS) there is a way that you can edit the .lua file to do this, but it appears to have been designed from the outset to allow that. Not sure if there is any way that AMS / AMS2 / AC / ACC can deal with this. So, either setting a separate command for the off selection, or a hold for command is basically what I want.

Cheers

Les
 
You can use Autohotkey macro program to do same. There are also some other programs which does same. You need to check what Joystic your controller device is so that you use correct parameters.
Here in example below controller device id is 2 and button 17. In game it has been configured that 0 is left indicator and 9 right indicator.

You need to make sure Autohotkey script is running when you use software. However if/when game API dont have interface to read controller switch status and use it directly in software like DCS has in its LUA you always need to "reset" switch when you start game client or new session. DSC has actually very advanced LUA for controller and i personally love it :D


#InstallKeybdHook
2Joy17::
Send {0} ; Should start blinker and it actually starts it
KeyWait 2Joy17 ; Wait for the user to release the joystick button.
Send {0} ; When returning toggle to center off position should stop blinker
return
2Joy18::
Send {9} ; Should start blinker and it actually starts it
KeyWait 2Joy18 ; Wait for the user to release the joystick button.
Send {9} ; When returning toggle to center off position should stop blinker
return
 
Last edited:
Upvote 0
Let's suppose you want to turn on and off the headlights like in a real car, with a 2-position switch (up=lights on and down=lights off).

Now, this is a problem, because a switch in a computer device such a button box would work like up = button hold and down = button released. However, I don't know any simulator that that can map buttons or keys like that.

You could use a switch with 3 positions: up, not pressed and down. In this case the simulator should offer the possibility to map 2 controls for the headlights: headlights on and headlights off. This is not common and most of them just have 1 control wich works as a toggle to turn headlights on and off. In this case you could map the same control to up and down, but if you press up when this lights are on, the lights would turn off and the cycle would be reversed.
 
Last edited:
Upvote 0
Let's suppose you want to turn on and off the headlights like in a real car, with a 2-position switch (up=lights on and down=lights off).

Now, this is a problem, because a switch in a computer device such a button box would work like up = button hold and down = button released. However, I don't know any simulator that that can map buttons or keys like that.

You could use a switch with 3 positions: up, not pressed and down. In this case the simulator should offer the possibility to map 2 controls for the headlights: headlights on and headlights off. This is not common and most of them just have 1 control wich works as a toggle to turn headlights on and off. In this case you could map the same control to up and down, but if you press up when this lights are on, the lights would turn off and the cycle would be reversed.
Autohotkey Script what i provided Works excactly like so that it enable on/off swithes to Ganes where something like lights are turned on or off with on button press.

Iracing like examples also true toggle switches which hae on/off state. It was been supported few years
 
Last edited:
Upvote 0
Top