You don't have a stick?
If you really mean LOMAC and not Flaming Cliffs I have no idea.
Sorry I didn't mean it like that.
LOMAC is very old, after searching the web just now I couldn't find any way to use the mouse for flight controls.
from System import Int16
from ctypes import windll, Structure, c_ulong, byref
class POINT(Structure):
_fields_ = [("x", c_ulong), ("y", c_ulong)]
if starting:
# From 0 to 1. E.G. 0.1 = 10% dead zone in each direction.
deadzone = 0
vJoy0_stat = 0
vjoy_min = -16382
vjoy_max = vjoy_min + Int16.MaxValue
vJoy[0].x = 0
vJoy[0].y = 0
mouse_x = 0
mouse_y = 0
screen_x = windll.user32.GetSystemMetric s(0)
screen_y = windll.user32.GetSystemMetric s(1)
pt = POINT()
x_min = (screen_x - screen_y) / 2
x_max = x_min + screen_y - 1
swd = False
swu = False
if keyboard.getPressed(Key.CapsLock): # enable/disable mouse vJoy X/Y control by pressing CapsLock
if vJoy0_stat == 0: vJoy0_stat = 1
else: vJoy0_stat = 0
if vJoy0_stat == 1:
windll.user32.GetCursorPos(byref(pt))
mouse_x = pt.x
mouse_y = pt.y
vJoy[0].x = filters.deadband(filters.ensureMapRange(mouse_x, x_min, x_max, vjoy_min, vjoy_max), deadzone, vjoy_min, vjoy_max)
vJoy[0].y = filters.deadband(filters.ensureMapRange(mouse_y, 0, screen_y -1, vjoy_min, vjoy_max), deadzone, vjoy_min, vjoy_max)
vJoy[0].setButton(0, mouse.leftButton)
vJoy[0].setButton(1, mouse.rightButton)
vJoy[0].setButton(2, mouse.middleButton)
if mouse.wheelDown and not swd:
vJoy[0].setButton(3, True)
swd = True
if filters.stopWatch(swd, 32):
vJoy[0].setButton(3, False)
swd = False
if mouse.wheelUp and not swu:
vJoy[0].setButton(4, True)
swu = True
if filters.stopWatch(swu, 32):
vJoy[0].setButton(4, False)
swu = False
vJoy[0].setButton(5, mouse.getButton(3))
vJoy[0].setButton(6, mouse.getButton(4))
There must be several options for that problem. I know there must be a solution using a software called FreePIE (http://andersmalmgren.github.io/FreePIE/) in conjunction with another software called vJoy (http://vjoystick.sourceforge.net/site/). The idea is: You install a virtual joystick (vJoy) that your game will respond to. With freePIE you move the virtual axes of the virtual joystick according to some scripted logic. In this case: move the x and y axes copying the movements of the mouse (within screen limits).
I searched and found a FreePIE script that does that:
http://www.mtbs3d.com/phpBB/viewtopic.php?f=139&t=20801
I made some modifications to it. Now there should be no need to calibrate, a deadzone can be set and mouse buttons/wheel can act as "virtual joystick" buttons.
So:
1- Install vJoy
2- Install freePIE
3- Open FreePIE. File-> new. Paste the script below. File -> Save. Script -> run script.
4- Press capslock to enable/disable the axes/buttons while the script is running.
5- Try to map the axes/buttons in game.
6- Tell us if it worked :)
Note: The leading whitespace (indentation) must be preserved when copying.
unexpected token 's'Quote
screen_x = windll.user32.GetSystemMetric s(0)
screen_y = windll.user32.GetSystemMetric s(1)
from System import Int16
from ctypes import windll, Structure, c_ulong, byref
class POINT(Structure):
_fields_ = [("x", c_ulong), ("y", c_ulong)]
if starting:
# Activate/deactivate script.
# Type Key. and FreePIE editor will show key suggestions.
toggle_key = Key.ScrollLock
# From 0 to 1. E.G. 0.1 = 10% dead zone in each direction: x+, x-, y+, y-.
deadzone = 0
# -1 to invert axes
x_direction = 1
y_direction = 1
# 0 or None to disable. You can set a key or a key combination.
# If you want a key combination such as Ctrl+Shift+u for right mouse button,
# for example, it would be:
# right_mouse = (Key.LeftControl, Key.LeftShift, Key.U)
left_button = None
right_button = None
middle_button = None
forward_button = None
back_button = None
wheel_up = None
wheel_down = None
# 0 or 1. Disables wheel_up and wheel_down mappings above, if set.
wheel_is_z_axis = 1
# -1 or 1
z_direction = 1
# This disables the mapping for the button if set above and wheel_is_axis is 1.
# Set to None/0 to disable.
reset_to_center_button = "middle_button"
# Percent in each direction: +z and -z (Sensitivity)
percent_increment_per_wheel_step = 10
# Initialization logic.
vJoy0_stat = 0
vjoy_min = -16382
vjoy_max = vjoy_min + Int16.MaxValue
zero_offset = 2
vJoy[0].x = vJoy[0].y = vJoy[0].z = zero_offset
mouse_x = mouse_y = 0
screen_x = windll.user32.GetSystemMetrics(0)
screen_y = windll.user32.GetSystemMetrics(1)
pt = POINT()
x_min = (screen_x - screen_y) / 2
x_max = x_min + screen_y - 1
btns = [None] * 5
wheel_increment = ((Int16.MaxValue + 1)/ 200.0 *
percent_increment_per_wheel_step )
button_n = {"left_button": 0, "right_button": 1,
"middle_button": 2, "forward_button": 3, "back_button": 4}
rtc_button = button_n.get(reset_to_center_button)
limits = (None, vjoy_max, vjoy_min)
for k, button in enumerate(
(left_button, right_button, middle_button, forward_button, back_button)):
if k == rtc_button and wheel_is_z_axis: continue
elif isinstance(button, tuple):
btns[k] = button
else:
btns[k] = (button, ) if isinstance(button, Key) else None
if not isinstance(wheel_down, tuple):
wheel_down = (wheel_down, ) if isinstance(wheel_down, Key) else ()
if not isinstance(wheel_up, tuple):
wheel_up = (wheel_up, ) if isinstance(wheel_up, Key) else ()
# Loop logic.
if keyboard.getPressed(toggle_key):
if vJoy0_stat == 0:
vJoy0_stat = 1
button_status =
- * 5
z_val = zero_offset
else:
vJoy0_stat = 0
vJoy[0].x = vJoy[0].y = vJoy[0].z = zero_offset
for k, pressed in enumerate(button_status):
if pressed:
for key in reversed(btns[k]):
keyboard.setKeyUp(key)
if vJoy0_stat == 1:
windll.user32.GetCursorPos(byref(pt))
mouse_x = pt.x if x_direction == 1 else screen_x - pt.x
mouse_y = pt.y if y_direction == 1 else screen_y - pt.y
vJoy[0].x = int(round(filters.deadband(
filters.ensureMapRange(mouse_x, x_min, x_max, vjoy_min, vjoy_max),
deadzone, vjoy_min, vjoy_max)))
vJoy[0].y = int(round(filters.deadband(
filters.ensureMapRange(mouse_y, 0, screen_y -1, vjoy_min, vjoy_max),
deadzone, vjoy_min, vjoy_max)))
for k, keys in enumerate(btns):
if keys == None: continue
button_pressed = mouse.getButton(k)
if button_pressed != button_status[k]:
for key in keys:
keyboard.setKey(key, button_pressed)
button_status[k] = button_pressed
if wheel_is_z_axis:
if reset_to_center_button and mouse.getButton(rtc_button):
vJoy[0].z = z_val = zero_offset
elif mouse.wheel != 0:
if mouse.wheel > 0 and (
round(z_val) * z_direction < z_direction * limits[z_direction]):
z_val += wheel_increment * mouse.wheel / 120 * z_direction
elif mouse.wheel < 0 and (
round(z_val) * z_direction > z_direction * limits[-z_direction]):
z_val += wheel_increment * mouse.wheel / 120 * z_direction
vJoy[0].z = limits[1] if z_val > limits[1] else (
limits[2] if z_val < limits[2] else int(round(z_val)))
else:
if mouse.wheelDown:
for k in wheel_down:
keyboard.setPressed(k)
if mouse.wheelUp:
for k in wheel_up:
keyboard.setPressed(k)
if stopping:
vJoy[0].x = vJoy[0].y = vJoy[0].z = zero_offset
It seems when I pasted the script here a space was added between the c and the s in the lines:
It seems there is a bug in the forum software or something I don't understand. In the new script I pasted below I had to set some words to bold or the same would happen. I should have checked that what I post works, sorry. If script gives errors it is not running, so obviously the game won't see activity for the vJoy device.
In the meantime I changed more things. Now instead of "pressing" virtual buttons you "press" keys or key combinations. Easier to map controls in game that way: just map the keys. I tested this with Falcon BMS and I could eject no problem. :) . Axes don't work in AH for some reason, though. :(
I mapped the mouse wheel to the z axis. For throttle or rudder.
Big chance there are still bugs, need someone to find them! :D.
P.S. I changed the default key to enable the script. Now it is Scroll Lock.
P.S.2 They virtual joystick should show up and move in windows "game controllers" properties.