[Help] Help with Mouse and Keyboard Controls

Any issues with the XWAU or X-Wing Alliance? Please let us know here!
Post Reply

[Help] Help with Mouse and Keyboard Controls

MrDrTaco
Recruit
Posts: 1
Joined: Tue Jul 06, 2021 6:49 am

Post by MrDrTaco » Tue Jul 06, 2021 6:51 am

Hello everyone. I just purchased the game and installed the XWA and TFTC mod today. My issue is that I have no idea how to map the controls to effectively play on Keyboard and Mouse. If someone could assist me in setting up the controls that would be great thanks!

User avatar
AngeI
Lieutenant JG
Posts: 528
Joined: Sun Jan 24, 2016 5:27 pm

Post by AngeI » Tue Jul 06, 2021 7:53 pm

Hi @MrDrTaco to enable KB + Mouse flight controls, you need to enable Joystick Emulation by running the Babu Frik Configurator. Here you can turn it on and set the mouse sensitivity. Binding keys to different functions can then be done in game through the ESC menu.

ChaosFoxOverlord
Recruit
Posts: 1
Joined: Wed Jan 17, 2024 2:57 pm

Post by ChaosFoxOverlord » Wed Jan 17, 2024 3:01 pm

Although this is an old thread, the problem persists - the DDRAW Emulation used by Babu Friks Configurator is not ideal -, so I have written a guide which I hope will be of use. You can find the latest version in the Guides to XWA on the appropriate Steam-Community Website:

https://steamcommunity.com/sharedfiles/ ... 3139443027

Please see there for the latest version and further and more detailed information.

In short:

1. Install vJoy as virtual Joystick driver and FreePIE as bridge between vJoy and your input device.
2. Configure vJoy Device No. 1 with X/Y/Z/Rx/Ry/Rz axis and 2 Buttons
3. Run the following script in FreePIE (File->New, Paste, Save, Press F5):

########## FreePIE Script Start ##########
## !!!!! REPLACE ALL OCCURENCES of "____" (four consecutive underscores )
## with four consecutive spaces or
## a single tab before attempting to run !!!!!

#Initialization
if starting:
____rmbKey = Key.X #Key bound to right mouse botton
____#Higher values = faster centering
____centreX = 0.015
____centreY = 0.03
____#Sensitivities
____sensX = 50
____sensY = 50
____sensZ = 10
____viewSens = 50
____#Timings
____system.setThreadTiming(TimingTypes.HighresSystemTimer)
____system.threadExecutionInterval = 20
____#Initial values of axis / latches /etc.
____x = 0
____y = 0
____z = -vJoy[0].axisMax
____rx = 0
____ry = 0
____timeKeyPressed = 0
____freelook = False
____viewLatch = False
____moveLatch = False
____rmbLatch = False

#Freelook via Numpad mapped to mouse while middle mouse button pressed
if freelook:
____if timeKeyPressed <= 0:
________timeKeyPressed = viewSens
____
________#rx += mouse.deltaX * viewSens
________if mouse.deltaX > 0:
____________keyboard.setKey(Key.NumberPad6, True)
____________keyboard.setKey(Key.NumberPad6, False)
________if mouse.deltaX < 0:
____________keyboard.setKey(Key.NumberPad4, True)
____________keyboard.setKey(Key.NumberPad4, False)
____________
________#ry += mouse.deltaY * viewSens
________if mouse.deltaY > 0:
____________keyboard.setKey(Key.NumberPad2, True)
____________keyboard.setKey(Key.NumberPad2, False)
________if mouse.deltaY < 0:
____________keyboard.setKey(Key.NumberPad8, True)
____________keyboard.setKey(Key.NumberPad8, False)
____else:
________timeKeyPressed -= system.threadExecutionInterval
________if timeKeyPressed < 0:
____________timeKeyPressed = 0

else:
____# Mouse axis as Joystick via vJoy-Driver
____if mouse.deltaX:
________moveLatch = True
________x += mouse.deltaX * sensX
________if abs(x) > vJoy[0].axisMax:
____________x = vJoy[0].axisMax * x / abs(x)
____else:
________x /= (1.0 + centreX)
____
____if mouse.deltaY:
________moveLatch = True
________y += mouse.deltaY * sensY
________if abs(y) > vJoy[0].axisMax:
____________y = vJoy[0].axisMax * y / abs(y)
____else:
________y /= (1.0 + centreY)

# recenter
if (not freelook and viewLatch):
____rx = 0
____ry = 0
____viewLatch = False

#keyboard override mouse
#if (moveLatch and keyboard.getPressed(Key.Space) or keyboard.getPressed(Key.Z)):
#____x = 0
#____y = 0
#____moveLatch = False

#right mouse button
if (mouse.getPressed(1) or mouse.rightButton):
____if (not rmbLatch):
________keyboard.setKey(rmbKey, True)
________keyboard.setKey(rmbKey, False)
____rmbLatch = True
else:
____rmbLatch = False
____
#code for hold freelock
freelook = mouse.getButton(2) or mouse.middleButton
#if (mouse.getPressed(3)):
#____viewLatch = True
____
#code for toggle freelook
#toggle = keyboard.getPressed(Key.CapsLock)
#if (toggle):
#____freelook = not freelook

#Throttle via Z-Axis mapped to mouse wheel
if (mouse.wheel):
____z += mouse.wheel * sensZ
____if abs(z) > vJoy[0].axisMax:
________z = vJoy[0].axisMax * z / abs(z)
________
##### vJoy mapping #####

### Standard mapping ###
#vJoy[0].rx = rx
#vJoy[0].ry = ry
#vJoy[0].x = x
#vJoy[0].y = y
#vJoy[0].z = -z

### X-Wing Alliance default "weird" mapping ###
vJoy[0].rx = 0
vJoy[0].ry = 0
vJoy[0].rz = x
vJoy[0].x = 0
vJoy[0].y = -y
vJoy[0].z = -z

#Joystick buttons mapped to mouse buttons
vJoy[0].setButton(0, mouse.getButton(0) or mouse.leftButton)
vJoy[0].setButton(1, mouse.getButton(1) or mouse.rightButton)

#Diagnostics
diagnostics.watch(vJoy[0].x)
diagnostics.watch(vJoy[0].y)
diagnostics.watch(vJoy[0].z)
diagnostics.watch(vJoy[0].rx)
diagnostics.watch(vJoy[0].ry)
diagnostics.watch(vJoy[0].rz)
diagnostics.watch(freelook)
diagnostics.watch(moveLatch)
diagnostics.watch(mouse.getButton(0) or mouse.leftButton)
diagnostics.watch(mouse.getButton(1) or mouse.rightButton)
diagnostics.watch(mouse.getButton(2) or mouse.middleButton)
diagnostics.watch(vJoy[0].axisMax)

########## FreePIE Script End ##########

Once you have completed the above steps, you should be able to control your ship with your mouse movements, use the mouse wheel as throttle, fire your weapons with the left mouse button, (un)link your weapons using the right mouse button and free-look while holding the middle mouse button.

What I like about this solution is that it is not limited to a specific game or even gaming. With FreePIE you can work with the RAW inputs and have full control over all operations. Of course, you can change the example script to make the inputs softer by setting centerX and/or centerY to lower values - or discard automatic centering altogether.

According to the FreePIE documentation, you can also use this method to modify the inputs of your hardware joystick, transfer them to vJoy and thus solve problems such as wrong axes or other inconveniences.

What can be inconvenient with this solution is that you need some programming knowledge to make customizations.

CrisGer
Cadet 2nd Class
Posts: 71
Joined: Fri Oct 17, 2008 10:23 pm
Contact:

Post by CrisGer » Sun Mar 31, 2024 9:44 pm

thank you for this guide. Since i have no clue how to set the peramiters of my joy stick i hope to use Keyboard and mouse following your guide. I have the Joy and Free both instlaled. but had a question.

it says to start the script with F5 do we have to do that each time we start the game?

thanks again for the help.
Director and Lead Admin
3D World and Game Developers Group LInkedin
"We Build Worlds"

Post Reply