Keight Posted August 31, 2022 Report Posted August 31, 2022 Hi. Is there a possibility on the registered version to set the mouse macros but make them work the way round? I mean you press the button in the cockpit that will activate the assigned key or a combination. For instance clicking the PTT button in VC to command CTRL key press which assigned as PTT in vpilot. Thanks.
John Dowson Posted August 31, 2022 Report Posted August 31, 2022 What aircraft are you using, and does the PTT button in the VC actually work? I thought this was inoperative on most, if not all, aircraft... If there is a functioning PTT button in the VC, you need to see if activating this emits an event (it will be a custom event - there are no standard events for PTT) or changes a simvar or lvar. If so, you could use a lua script to pick up this change and then send the key press - which would go to the FS, vPilot would have to have this registered as a hot key to pick this up. If you let me know what FS and what aircraft you are using (and if I have this aircraft), I could take a look to see what, if anything, is emitted or changed.
Keight Posted August 31, 2022 Author Report Posted August 31, 2022 I am using P3Dv5, FSLabs and all jet PMDG aircraft. Not sure what you mean by functioning PTT but there are RAD/INT or MIC/INT switches on the radio management panel. They are animated but doing nothing. I am too far away from programming and for me lua script or lvar are just strange words, but I know using mouse macros one can assign a key or a joystick button for pretty much any button or switch in the VC. So my question is, is it possible to make that working in a way round, you press a button in VC and it sends a key press? It also may find application in using UGCX from FS2Crew, they are also offering hotkeys for initiation, PTT, mic mute/unmute etc. So you can bind RAD for vpilot and INT for UGCX.
John Dowson Posted September 1, 2022 Report Posted September 1, 2022 16 hours ago, Keight said: So my question is, is it possible to make that working in a way round, you press a button in VC and it sends a key press? But I already answered this...this is only possible if pressing the button emits an event or changes something (i.e. simvar or lvar) that can be picked-up by FSUIPC, and you would need a lua script to intercept that and send the key press. FSUIPC does not react to mouse operations in the FS, only to the data it receives from the result if that mouse operation, usually an event. If the switches are animated, then the first thing you should try is to set logging for Events (non-axis controls) and flip the switches in the VC and see if any event is logged. The PMDG aircraft for P3D use custom controls, and the FSLabs uses the Rotor Brake control with the parameter indicating the switch and the mouse action, See if any of those are logged. If so, then a simple lua script can intercept these and send the key press. 16 hours ago, Keight said: Not sure what you mean by functioning PTT Many aircraft (GA) have a PTT button on the yoke, but this generally doesn't do anything as default ATC does not require this (it uses menu options). Toy would assign this by button to PTT for the ATC system you are using.
Keight Posted September 1, 2022 Author Report Posted September 1, 2022 1 hour ago, John Dowson said: If so, then a simple lua script can intercept these and send the key press. Could you please give an example of this lua script?
John Dowson Posted September 1, 2022 Report Posted September 1, 2022 29 minutes ago, Keight said: Could you please give an example of this lua script? Nothing complex - something along the following lines - where <controlnum> is the control/event received when you press the button in the VC, and <keycode> is the key press you want to send: myEventFunction(controlnum, param) -- send keypress here - may need to check the control' parameter first if a Rotor Brake control ipc.keypress(<keycode>) end -- Wait for control to be received event.control(<controlnum>, myEventFunction) But as I keep saying, you can only do this if some sort of control/event is sent when press the button in the VC.
Keight Posted September 1, 2022 Author Report Posted September 1, 2022 (edited) 1 hour ago, John Dowson said: But as I keep saying, you can only do this if some sort of control/event is sent when press the button in the VC. Here what I get clicking INT/RAD switch to RAD: 1304219 *** EVENT: Cntrl= 66587 (0x0001041b), Param= 77715 (0x00012f93) ROTOR_BRAKE the swtich is springloaded when it gets back to center position: 1304219 *** EVENT: Cntrl= 66587 (0x0001041b), Param= 77717 (0x00012f93) ROTOR_BRAKE now I want to assign M key to that switch and keep sending keypress while holding on RAD position. so the script should look like this? myEventFunction(controlnum, param) -- send keypress here - may need to check the control' parameter first if a Rotor Brake control ipc.keypress(77,8) end -- Wait for control to be received event.control(66587, 77715, myEventFunction) Edited September 1, 2022 by Keight
John Dowson Posted September 1, 2022 Report Posted September 1, 2022 (edited) 4 hours ago, Keight said: now I want to assign M key to that switch and keep sending keypress while holding on RAD position. so the script should look like this? myEventFunction(controlnum, param) -- send keypress here - may need to check the control' parameter first if a Rotor Brake control ipc.keypress(77,8) end -- Wait for control to be received event.control(66587, 77715, myEventFunction) No...please read the lua library documentation - and also the template I showed you. It would be more like this: myEventFunction(controlnum, param) -- Check parameter of Rotor Brake control to see if if param == 7715 then ipc.control(1071,77) -- send 'M' key (77) press elseif param == 7717 then ipc.control(1072,77) -- send 'M' key (77) release end end -- Wait for control to be received event.control(66587, "myEventFunction") If you want to send separate press and release, you need to use the separate FSUIPC added controls to send the key press (1071) and then the key release (1072) - ipc.keypress would send them both together. Note also that you need to have the lua running - it should be started from the [Auto] or, better, [Auto.xxx] (where xxx is the profile name) section of your FSUIPC7.ini. Again, consult the documentation if not sure (Advanced User guide). John Later: Btw, I used 77 (the 'M' key) as that is what you were using, You change this value to any other key or key+modifier - see the Advanced User guide for the keycode and shifts/modifier codes/numbers. Edited September 1, 2022 by John Dowson Later added
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