Author Topic: To Anyone who played/plays Lock On:Modern Air Combat  (Read 2149 times)

Offline Phoenix3107

  • Copper Member
  • **
  • Posts: 224
To Anyone who played/plays Lock On:Modern Air Combat
« on: March 16, 2015, 01:42:19 PM »
Is there any way at all to configure the mouse to take control of the flight stick instead of the keyboard buttons? Been trying to do so for a long time, but nothing seems to work. It seems every time the Options>Input menu devices just reads "Keyboard". :bhead
GameID:Phoenix

Also can be found under my DA name
"Lonewolf32097" at www.deviantart.com.

Offline Mar

  • Gold Member
  • *****
  • Posts: 2185
Re: To Anyone who played/plays Lock On:Modern Air Combat
« Reply #1 on: March 16, 2015, 02:03:58 PM »
You don't have a stick?

If you really mean LOMAC and not Flaming Cliffs I have no idea.

𝒻𝓇𝑜𝓂 𝓉𝒽𝑒 𝓈𝒽𝒶𝒹𝑜𝓌𝓈 𝑜𝒻 𝓌𝒶𝓇'𝓈 𝓅𝒶𝓈𝓉 𝒶 𝒹𝑒𝓂𝑜𝓃 𝑜𝒻 𝓉𝒽𝑒 𝒶𝒾𝓇 𝓇𝒾𝓈𝑒𝓈 𝒻𝓇𝑜𝓂 𝓉𝒽𝑒 𝑔𝓇𝒶𝓋𝑒

  "Onward to the land of kings—via the sky of aces!"
  Oh, and zack1234 rules. :old:

Offline Phoenix3107

  • Copper Member
  • **
  • Posts: 224
Re: To Anyone who played/plays Lock On:Modern Air Combat
« Reply #2 on: March 16, 2015, 02:18:16 PM »
You don't have a stick?

If you really mean LOMAC and not Flaming Cliffs I have no idea.

Shouldn't surprise you Mar. Just because I fly AH with a mouse doesn't or shouldn't make me or any other mouse flier any different than those who fly with sticks. The fact is that this game was made to have fun in WW1/WW2 era simulators. The end.

As for LOMAC, yes, it's what it sounds like, but it looks like it's a lost cause then.
« Last Edit: March 16, 2015, 02:39:18 PM by Phoenix3107 »
GameID:Phoenix

Also can be found under my DA name
"Lonewolf32097" at www.deviantart.com.

Offline Mar

  • Gold Member
  • *****
  • Posts: 2185
Re: To Anyone who played/plays Lock On:Modern Air Combat
« Reply #3 on: March 16, 2015, 03:25:15 PM »
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.
𝒻𝓇𝑜𝓂 𝓉𝒽𝑒 𝓈𝒽𝒶𝒹𝑜𝓌𝓈 𝑜𝒻 𝓌𝒶𝓇'𝓈 𝓅𝒶𝓈𝓉 𝒶 𝒹𝑒𝓂𝑜𝓃 𝑜𝒻 𝓉𝒽𝑒 𝒶𝒾𝓇 𝓇𝒾𝓈𝑒𝓈 𝒻𝓇𝑜𝓂 𝓉𝒽𝑒 𝑔𝓇𝒶𝓋𝑒

  "Onward to the land of kings—via the sky of aces!"
  Oh, and zack1234 rules. :old:

Offline Phoenix3107

  • Copper Member
  • **
  • Posts: 224
Re: To Anyone who played/plays Lock On:Modern Air Combat
« Reply #4 on: March 16, 2015, 03:32:17 PM »
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.

No hard feelings. Just had to clarify. Fresh start.

I'll take that as a yes, it's a lost cause.
« Last Edit: March 16, 2015, 04:22:48 PM by Phoenix3107 »
GameID:Phoenix

Also can be found under my DA name
"Lonewolf32097" at www.deviantart.com.

Offline Sombra

  • Copper Member
  • **
  • Posts: 203
Re: To Anyone who played/plays Lock On:Modern Air Combat
« Reply #5 on: March 17, 2015, 07:21:34 PM »
There must be several options for that problem. I know there must be a solution using a software called FreePIE in conjunction with another software called vJoy.  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.
Quote
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))

Offline Phoenix3107

  • Copper Member
  • **
  • Posts: 224
Re: To Anyone who played/plays Lock On:Modern Air Combat
« Reply #6 on: March 18, 2015, 06:24:36 PM »
There must be several options for that problem. I know there must be a solution using a software called FreePIE in conjunction with another software called vJoy.  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.

Got it installed, ran the script, opened up the game, tried to set it for vJoy device, but still no response. The problem is that when I close the input options menu, then open it up again, its automatically set as "Keyboard", in the input section. I tried to calibrate the axes, but I'm not so sure that'll work. Is there any way to set the devices to vJoy device instead of "Keyboard"?

Also, I got this message in the error section of the script runner:
Quote
unexpected token 's'
Quote
« Last Edit: March 18, 2015, 06:28:13 PM by Phoenix3107 »
GameID:Phoenix

Also can be found under my DA name
"Lonewolf32097" at www.deviantart.com.

Offline Sombra

  • Copper Member
  • **
  • Posts: 203
Re: To Anyone who played/plays Lock On:Modern Air Combat
« Reply #7 on: March 19, 2015, 02:14:59 PM »
It seems when I pasted the script here a space was added between the c and the s in the lines:
Quote
   screen_x = windll.user32.GetSystemMetric s(0)
   screen_y = windll.user32.GetSystemMetric s(1)

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.

Quote
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 = [0] * 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
« Last Edit: March 19, 2015, 04:50:23 PM by Sombra »

Offline Phoenix3107

  • Copper Member
  • **
  • Posts: 224
Re: To Anyone who played/plays Lock On:Modern Air Combat
« Reply #8 on: April 01, 2015, 01:01:09 PM »
 :( After minutes and minutes of figuring out how to work this thing, it seems nothing is getting through either the configuration or the installations. I don't think this is going well at all. At this point in time, I'm throwing in the towel on this effort.
GameID:Phoenix

Also can be found under my DA name
"Lonewolf32097" at www.deviantart.com.

Offline tahzib

  • Zinc Member
  • *
  • Posts: 1
Re: To Anyone who played/plays Lock On:Modern Air Combat
« Reply #9 on: October 16, 2022, 09:54:36 AM »
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.


hey, sorry to bump an ancient topic - but i stumbled upon this while searching for mouse stick to use in CFS3...the X and Y axis work out of the box, but i have problem with the Z axis because in CFS3 there is no Z axis, instead there's a throttle axis and a rudder axis and none is accepting the mouse wheel no matter how much i scroll up and down....if i want to rename the wheel as throttle axis instead of Z axis how should i assign the variable and the data input?
and if i want X axis to work both as rudder and roll, what should i do? i dont know python so even if i wanted to tinker with this code, i wont be able to