Interceptor_33 Posted September 17, 2021 Posted September 17, 2021 (edited) Hello, I have built myself a custom "joystick+panel" with buttons that have lights. If I bind a button to the switches in the cockpit for the cockpit lights for example. If I press my panels button it lights up and the cockpit switch turns on. Now I can comfortably see, if the light on my panel is ON that means the switch in game is ON . But if I want to turn OFF the cockpit switch, I press my panels button (and light goes of on my panel, because the button isnt pressed anymore) but the games switch still doesnt change. Only if I press my panels button again (which makes the panesl light go ON again coz the button is pressed again) only then the in-game switch turns OFF. So in short. I always need to press my panels button twice to turn the games switch ON or OFF. How can I change that? I have programmed my panel so, that if its pressed once it keeps the button pressed (and the backlight of that button lights up) if I press it again it stops pressing the button and lights go off. Of course I could change my code to make the button just be pressed once (and not kept pressed) but the lights will be on and only turn off if I press the button again. But is there a way to change this ingame? To make a switch turn on and turn off with a button being pressed and released? What really doesnt make sense to me. If a switch inside the cockpit is flipped. It represents a pressed state. If I use a physical switch on a panel and I flip it. It will be signaled as pressed to, until I flip it back. Wouldnt make any sense to flip a switch twice to toggle an ingame switch. Edited September 17, 2021 by Interceptor_33
HotPursuit Posted September 17, 2021 Posted September 17, 2021 12 hours ago, Interceptor_33 said: Now I can comfortably see, if the light on my panel is ON that means the switch in game is ON This might not be possible as some cockpits have two types of interior lighting. ie. first button press activates instrument lights, second button press turns on flood (spot) lights, third press all interior lights off. So your panel button light would get out of sync in these planes anyway. l cant see away around this unfortunately. 1
Charon Posted September 18, 2021 Posted September 18, 2021 HotPursuit is right about the different types of interior lighting. Use a button or an encoder for that; a switch is always going to be a problem. I do use switches for other things (nav lights, landing lights, landing gear, etc). I've got my button box coded to send two different button presses (B1 when the switch is down, and B2 when the switch is up), and I bind both B1 and B2 to "toggle lights". You'll probably find it necessary to put a small delay between the two button presses. Also make sure to have your device send periodic updates, even if it detected no changes. Otherwise software will get confused the first time you flip a switch and it sees a whole bunch of buttons come alive all at once. 1
Interceptor_33 Posted September 18, 2021 Author Posted September 18, 2021 (edited) 8 hours ago, HotPursuit said: This might not be possible as some cockpits have two types of interior lighting. ie. first button press activates instrument lights, second button press turns on flood (spot) lights, third press all interior lights off. So your panel button light would get out of sync in these planes anyway. l cant see away around this unfortunately. You are right. I didnt play the game for ages so I totally forgot it has multiple functions on some switches. Sadly. 4 hours ago, Charon said: HotPursuit is right about the different types of interior lighting. Use a button or an encoder for that; a switch is always going to be a problem. I do use switches for other things (nav lights, landing lights, landing gear, etc). I've got my button box coded to send two different button presses (B1 when the switch is down, and B2 when the switch is up), and I bind both B1 and B2 to "toggle lights". You'll probably find it necessary to put a small delay between the two button presses. Also make sure to have your device send periodic updates, even if it detected no changes. Otherwise software will get confused the first time you flip a switch and it sees a whole bunch of buttons come alive all at once. I think I have a little different setting than you. I work with Arduinos for my panel. So the workflow is a little different I guess. As I have seen the limitations of the game (even tho they could change that, but probably never will) I have adjusted my code to flip the light on my panel every 2 presses. But then this panel will be limited to IL2 only(Or I reflash it each time for a different game). So I have decided to change the whole thing, put a physical switch on the panel to then switch between IL2 mode and normal mode too ? Will change the interior light to a 3 press cycle so only if all lights are ON inside the cockpit my panels light will be on (pain in the butt) Thanks gyus for the help! Edited September 18, 2021 by Interceptor_33
Charon Posted September 20, 2021 Posted September 20, 2021 On 9/17/2021 at 11:55 PM, Interceptor_33 said: I think I have a little different setting than you. I work with Arduinos for my panel. So the workflow is a little different I guess. As I have seen the limitations of the game (even tho they could change that, but probably never will) I have adjusted my code to flip the light on my panel every 2 presses. But then this panel will be limited to IL2 only(Or I reflash it each time for a different game). So I have decided to change the whole thing, put a physical switch on the panel to then switch between IL2 mode and normal mode too ? Will change the interior light to a 3 press cycle so only if all lights are ON inside the cockpit my panels light will be on (pain in the butt) I'm using an Arduino Leonardo, with the Joystick and Keypad libraries. Here's the relevant snippet: if ( switchbx.key[i].stateChanged ) { switch (switchbx.key[i].kstate) { case PRESSED: case HOLD: Joystick.setButton(switchbx.key[i].kchar + 1, 0); delay(30); Joystick.setButton(switchbx.key[i].kchar, 1); break; case RELEASED: case IDLE: Joystick.setButton(switchbx.key[i].kchar, 0); delay(30); Joystick.setButton(switchbx.key[i].kchar + 1, 1); break; } } Obviously you'll need to be careful in setting up your keymap to leave room. E.g.., if you tell Keypad some switch corresponds to button 5, you also need to reserve button 6 for the "off" position. It works with Il-2 and most other sims, and when I need to, I use Joystick Gremlin to send a keypress on transition, without having to reflash the device (for e.g. Il-2 1946).
Interceptor_33 Posted September 21, 2021 Author Posted September 21, 2021 On 9/20/2021 at 5:35 AM, Charon said: I'm using an Arduino Leonardo, with the Joystick and Keypad libraries. Here's the relevant snippet: if ( switchbx.key[i].stateChanged ) { switch (switchbx.key[i].kstate) { case PRESSED: case HOLD: Joystick.setButton(switchbx.key[i].kchar + 1, 0); delay(30); Joystick.setButton(switchbx.key[i].kchar, 1); break; case RELEASED: case IDLE: Joystick.setButton(switchbx.key[i].kchar, 0); delay(30); Joystick.setButton(switchbx.key[i].kchar + 1, 1); break; } } Obviously you'll need to be careful in setting up your keymap to leave room. E.g.., if you tell Keypad some switch corresponds to button 5, you also need to reserve button 6 for the "off" position. It works with Il-2 and most other sims, and when I need to, I use Joystick Gremlin to send a keypress on transition, without having to reflash the device (for e.g. Il-2 1946). Cool. I am using the Leonardo too for the Joystick. Thanks for the code snippet. And I didnt know of Joystick Gremlin. Looks like a nice tool! Thanks a lot for the ideas!
Interceptor_33 Posted October 3, 2021 Author Posted October 3, 2021 On 9/20/2021 at 5:35 AM, Charon said: I'm using an Arduino Leonardo, with the Joystick and Keypad libraries. Here's the relevant snippet: if ( switchbx.key[i].stateChanged ) { switch (switchbx.key[i].kstate) { case PRESSED: case HOLD: Joystick.setButton(switchbx.key[i].kchar + 1, 0); delay(30); Joystick.setButton(switchbx.key[i].kchar, 1); break; case RELEASED: case IDLE: Joystick.setButton(switchbx.key[i].kchar, 0); delay(30); Joystick.setButton(switchbx.key[i].kchar + 1, 1); break; } } Obviously you'll need to be careful in setting up your keymap to leave room. E.g.., if you tell Keypad some switch corresponds to button 5, you also need to reserve button 6 for the "off" position. It works with Il-2 and most other sims, and when I need to, I use Joystick Gremlin to send a keypress on transition, without having to reflash the device (for e.g. Il-2 1946). Hi, me again Do you know if there is any API or scripting in IL2 that gives access to the game states of buttons, switches and other information, like in DCS?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now