jenx Posted September 28, 2009 Posted September 28, 2009 (edited) does anyone here have know how i setup a 3 position switch to simulate the same as in game? Im using the BU0836. Things like the weapon mode switch(long med short) is keystroke S. In the game when cycling the button, S moves the switch to short-> med-> long->short it doesnt go back through medium. This then gets the mechanical switch out of position with the simulated. Its the same thing with the landing light retract off and on and NDB inner auto and outer. I can get my switches to work but after that 1st run through the range and the sim missing the middle position they become out of sync I hope this makes sense to someone and there is a way around it. Edited September 29, 2009 by jenx Duo Core E8500, 8 GB ram, Win 7, GTX 260, TH2Go, 3x 22in LG W2252TQ monitors, Hotas cougar, TrackIR4, Buttkicker
Oakes Posted September 28, 2009 Posted September 28, 2009 Well, you need to calculate the number of steps needed to get to where you want. So if you physical switch is in the long position and you move it to the med position you need to send 2x S etc. You can do this by catching the Joy buttons from the BU0836 with autohotkey and then send the S key the appropriate times. Or maybe I misunderstood your question? /Oakes
JG14_Smil Posted September 28, 2009 Posted September 28, 2009 If you use two switch bits and can use on/off function calls, it is very simple to keep the switch in sync with the sim.
jenx Posted September 28, 2009 Author Posted September 28, 2009 Im still unsure, maybe i should try to explain it again.. the switch starts in the up position as does the sim. Once the switch is moved to the middle position (a single S)-the sim switch jumps 2 places to the down position the next switch move is to the down position (a single S) - the sim switch is now in the middle position the next switch move is to the middle position (a single S) - the sim switch is now in the up position the nxt switch move is to the up position (a single S) - the sim jumps 2 positions again and is down Duo Core E8500, 8 GB ram, Win 7, GTX 260, TH2Go, 3x 22in LG W2252TQ monitors, Hotas cougar, TrackIR4, Buttkicker
JG14_Smil Posted September 29, 2009 Posted September 29, 2009 (edited) not sure of your code, but with my Epic, the simplest way to do it would be... (I say simple as it does not use any position checking and user remembers to move switch in proper order - this means you can get out of sync with the sim) void f_pnl.burst_lngth_S.On(void) {khit(S);} //(this is the start position of the switch) (off command for above is not used as you don't need the switch to move until ...) void f_pnl.burst_lngth_L.On (void) {khit(S);} //(top switch position) void f_pnl.burst_lngth_L.Off (void) {khit(S);} //(middle switch position and the 'M' burst length) -so- if 'burst_lngth_S' switch uses bit 0 and 'burst_lngth_L' switch uses bit 1, they are separate, but are coded to send the same keystrokes. You flip the 2 way toggle up and nothing happens until it enters the "L" position and BS gets a keystroke. You return switch to middle, and the switch off command sends the BS switch to center position. You move it to the "S" position and the switch On command moves the toggle, then repeating. There are other methods that use physical switch position compared to the last switch position that can then send the up or down switch function, or multiple S keyhits to keep the BS switch in sync, as I believe Oakes touched on in his reply. It will then stay in sync with the sim, no matter which way it is switched, but it takes a bit more code with a variable defined. I have some untested examples. if you can toggle the center position in your code, I believe you could wire it up with one bit and let the toggling center (off position that 'flips' the data bit) keep things in sync. Edited September 29, 2009 by JG14_Smil
Oakes Posted September 29, 2009 Posted September 29, 2009 Jenx, I'm a little l bit unclear on how you have connected your switch to the sim. Are you using any software or are you just mapping the physical switch directly as a joystick button within DCS? Can you explain this in some detail, since you are using the BU0836 I was assuming that you do not use Export.lue etc to interface with the sim. /Oakes
jenx Posted September 29, 2009 Author Posted September 29, 2009 Jenx, I'm a little l bit unclear on how you have connected your switch to the sim. Are you using any software or are you just mapping the physical switch directly as a joystick button within DCS? Can you explain this in some detail, since you are using the BU0836 I was assuming that you do not use Export.lue etc to interface with the sim. /Oakes gday Oakes, at the moment im using SVMapper. i havent got into any export stuff yet. I was going to build and use up to 4 BU0836's first then go on to start looking at using export data later. I have tried wiring the switch 2 different ways. 1st i connected the center switch contact to col1 and the other 2 sides of the switch both to row 1. I have now split the switch by using the centre contact to col1 and the other side of the throw to row1 and row2. Im sure theres a way ive just gotta keep looking. Duo Core E8500, 8 GB ram, Win 7, GTX 260, TH2Go, 3x 22in LG W2252TQ monitors, Hotas cougar, TrackIR4, Buttkicker
Oakes Posted September 29, 2009 Posted September 29, 2009 Hi Jenx Here is a scritp for Autohotkey that should solve your problem. You need to replace the "1Joy1" and "1Joy2" parts to match the buttons you have connected the switch to. Format is "(Joystick Number)Joy(JoystickButton)". The Joystick Number is simply the number the BU0836 has in the controllers list under Settings/Control Panel/Game Controllers. I'm not sure if the switch uses S or s but you can change this as well in the script below. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. ; Get the initial state when we run the ahk script if GetKeyState("1Joy1") ; The button is still, down, so keep waiting. { SetTimer, WaitForButtonUp1, 10 } if GetKeyState("1Joy2") ; The button is still, down, so keep waiting. { SetTimer, WaitForButtonUp2, 10 } 1Joy1:: Send, SS ; Sends 2x SS to the application SetTimer, WaitForButtonUp1, 10 return WaitForButtonUp1: if GetKeyState("1Joy1") ; The button is still, down, so keep waiting. return ; Otherwise, the button has been released. Send, S ; Sends S to the appliation SetTimer, WaitForButtonUp1, off return 1Joy2:: Send, S ; Sends S to the application SetTimer, WaitForButtonUp2, 10 return WaitForButtonUp2: if GetKeyState("1Joy2") ; The button is still, down, so keep waiting. return ; Otherwise, the button has been released. Send, SS ; Sends 2x S to the appliation SetTimer, WaitForButtonUp2, off return /Oakes
jenx Posted September 29, 2009 Author Posted September 29, 2009 Hi Jenx Here is a scritp for Autohotkey that should solve your problem. You need to replace the "1Joy1" and "1Joy2" parts to match the buttons you have connected the switch to. Format is "(Joystick Number)Joy(JoystickButton)". The Joystick Number is simply the number the BU0836 has in the controllers list under Settings/Control Panel/Game Controllers. I'm not sure if the switch uses S or s but you can change this as well in the script below. /Oakes thanks ill give it a try in the next day or 2. ill put some pics of the progress so far in another thread once i get its working also. Duo Core E8500, 8 GB ram, Win 7, GTX 260, TH2Go, 3x 22in LG W2252TQ monitors, Hotas cougar, TrackIR4, Buttkicker
Gadroc Posted September 29, 2009 Posted September 29, 2009 To really fix your issue you will have to do some programing. You either need to query current state of the switch in the virtual cockpit or explicitly send position, both of these require lua code in the export script and an external controller program. The following lua lines should set absolute switch position. I can't check the values right now, so I may have short and long swapped. // Set Short Burst GetDevice(12):performClickableAction(3004,0.0); // Set Med Burst GetDevice(12):performClickableAction(3004,0.1); // Set Long Burst GetDevice(12):performClickableAction(3004,0.2);
Recommended Posts