Jump to content
The simFlight Network Forums

Assigning an axis to a button


Recommended Posts

So, I finally broke my piggy bank and sprung for a new Winwing Orion 2 F-16 stick and FA-18 throttle. I got into FSUIPC 6 and figured out how to set it up for specific aircraft in P3D and it all works for the most part. Primarily I need it for the VRS Superbug. I got pretty much everything set up except for one thing; the TDC cursor slew. I would really like to use an X/Y axis for this function as the real FA-18 works like that and it just works better. However, the controls for that funstion in the VRS aircraft are buttons. Specifically, the up/down/left/right arrow keys. I can kinda see where I should be able to assign an axis to a key press... I think. But I can't get it to work. So what am I missing? Is this possible in FSUIPC? Can I assign a joystick axis to a keyboard key, and if so, how is it done?

Link to comment
Share on other sites

When you assign to an axis, the axis value is sent to the control/event that it is assigned to. It doesn't really make much sense assigning an axis to a button, unless this is for a specific purpose (e.g. centering the axis).

6 minutes ago, brettt777 said:

However, the controls for that funstion in the VRS aircraft are buttons. Specifically, the up/down/left/right arrow keys. I can kinda see where I should be able to assign an axis to a key press...

Such controls (up/down/left/right) are best assigned to a hat switch. If you have a spare hat switch, you can use that. Otherwise, it may be possible to overload your view control hat switch to send these controls when another button/switch is pressed, and to control the view when not. This is called a conditional assignment and is described in the Advanced User guide.

But what makes you think these are axes controls? Up/Down/left/right are not axes controls, and if they are assigned to keys then they are certainly not axes controls....

21 minutes ago, brettt777 said:

However, the controls for that funstion in the VRS aircraft are buttons. Specifically, the up/down/left/right arrow keys. I can kinda see where I should be able to assign an axis to a key press...

If the controls are on a button, they are not axes controls. What controls do you see logged when you press these? You can just assign your buttons to the same controls.

11 minutes ago, brettt777 said:

I would really like to use an X/Y axis for this function as the real FA-18 works like that and it just works better. However, the controls for that funstion in the VRS aircraft are buttons. Specifically, the up/down/left/right arrow keys.

This also doesn't make much sense to me. How are you expecting to control two directions (left/right and up/down) on one axis? And this also sounds like you want to assign non-axis controls (up/down/left/right) to an axis, which is the opposite of the title of this post.

Normally there are corresponding inc/dec controls for each axis control. If not using the axis controls, you would assign to two buttons, one to increment the axis value and another to decrement.

What are the controls logged, if any, when you change the TDC cursor slew in the VC?

Link to comment
Share on other sites

  • 2 weeks later...
32 minutes ago, TimSteve said:

FSUIPC does not provide direct support for assigning a joystick axis to a keyboard key.

Of course not - that makes no sense. You can assign a key press or button to an axis control, but you need to provide the axis value which would be fixed. If you wanted to assign a key or button to increment or decrement an axis value by a defined amount, you would normally use an offset that holds the axis value and use the offset inc/dec controls to do this.

Link to comment
Share on other sites

Hello, 

I have a practical application of this functionality - mapping an axis to a button press - that I have been trying to solve for a couple years and would appreciate any help. 

I fly without rudder pedals and use a button press for ground braking. I find the brakes incedibly too strong, or way too weak when using a button for braking in MSFS. 

Is there a way I can map a button my keyboard to left and right brake axis that meet the following conditions:

1) When button is pressed the brake axis only goes to let's say 25 or 50%

2) When button is released the brake axis goes back to zero. 

 

Thanks for any help, been trying to figure this out for literally years!

 

Thanks

Adam

 

Link to comment
Share on other sites

I believe I figured out how to do this, 

Set the keyboard key to the Right axis brake, parameter about 4000, and 0 for the parameter upon key release.

...last step is trying to figure out how to assign the left axis brake to the same exact button.

I believe I will need to edit the ini manually to accomplish this. 

Link to comment
Share on other sites

16 hours ago, BetterPilot said:

Set the keyboard key to the Right axis brake, parameter about 4000, and 0 for the parameter upon key release.

Yes, that is the way to do it. 

16 hours ago, BetterPilot said:

...last step is trying to figure out how to assign the left axis brake to the same exact button.

You do  this by manually editing the ini file. Find the right brake axis assignment and duplicate this line, incrementing the line index number (to give it a unique index number) and then change the control number (not the comment) from 66388 (AXIS_RIGHT_BRAKE_SET) to 66387 (AXIS_LEFT_BRAKE_SET). Do this either when FSUIPC is not running, or if it is running do this with FSUIPC open showing the button assignments tab, and click the reload button when you have saved your ini file changes.

Note that once you have overloaded your button assignment, you will only see one assignment in the assignments panel and this will be grayed-out and you cannot change it - any changes must be done  directly in the ini file.

John

Link to comment
Share on other sites

Hi John, 

 

Thanks for the reply. I was able to figure out how to do exactly what you mentioned in the .ini file yesterday and spent about 8-9 hours trying to tune the brakes to a suitable strength. The results were a bit underwhelming due to the ground physics of MSFS and not FSUIPC. 

Is there a way I can program the key assigned to the brake axis to engage in 2 or 3 staged intensities based on how long I hold the brake key?

 

For example setting the brakes to trigger at values -3000, -6000, -10000. 

Initial value when key is pressed = -3000

Second value when key is held for .5 seconds = -6000

Third value when key is held for .5 seconds more = -10000

Something like this might make a world of a difference for me while impatiently wait for MSFS to re-write the ground physics modeling 🙂

Thanks,

Adam 

Link to comment
Share on other sites

13 hours ago, BetterPilot said:

Is there a way I can program the key assigned to the brake axis to engage in 2 or 3 staged intensities based on how long I hold the brake key?

 

For example setting the brakes to trigger at values -3000, -6000, -10000. 

Initial value when key is pressed = -3000

Second value when key is held for .5 seconds = -6000

Third value when key is held for .5 seconds more = -10000

You can do that using a lua script. You can use the event.key function to register a function to be called when the key is pressed (and released) and send the initial brake value, and also set a timer using event.timer to call a second function to apply the 2nd and subsequent values. The event.key function should cancel the timer function with event.cancel on key release.

There are also other ways to do this, e.g. see this User Contribution lua script for smooth braking using a button - this can also be used on a key: 

 

Link to comment
Share on other sites

Hi John, 

 

Thank you for the lua suggestion, this looks exactly what I've been searching for all these years! I've got it in my sim however it doesn't seem to be functioning to trigger the brakes. I will post my log and .ini in the OP that provided the lua. 

Thanks again for this incredible suggestion!

Adam

Link to comment
Share on other sites

You have set the key press to start the lua script:

Quote

2=PE,11,CL1:R,211     -{Lua Smooth_Brake}-

So when you press the key, it kills the script and starts it again,

Re-read the post - you need to set the keypress to LuaSet Smooth Brake  (not Lua Smooth Brake) with a parameter of 211

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.