i decided i would release a stand alone script that does the same thing as a certain feature from the cockpit features demo. this lets you control your ships lateral and vertical thrusters with the mouse. this is useful for anyone who has a hotas with a mouse feature, such as the trackpoint mouse on the x52 or the thumbstick on ch throttle. should also work on joysticks with extra axes which have been mapped to mouse axes with a 3rd party application (like glovepie). this is the preliminary version, i may add config file parsing later. i want testers with all kinds of mice (both those integrated in the joystick and stand alone mice). also this only works for ships that actually are equipped with thrusters, though you could probibly get a quick test with the terran mara or any other shivan fighter.
#Global Hooks
$GameInit:
[
--tweakable settings (edit these till i can implement the parser)
--mouse sensitivity negative inverts axis
mouse_sensitivity_x = 120
mouse_sensitivity_y = 120
--sets the sensitivity curve must (be > 0)
mouse_gain_x = 0.9
mouse_gain_y = 0.9
--non-tweakable vars
screen_center_w = gr.getScreenWidth()/2
screen_center_h = gr.getScreenHeight()/2
gametime, oldgametime = 0,0
ms_x, ms_y = 0,0
--sorta like the default freespace mouse behavior. this is sorta based off the one from wanderer's mouse script
--call it once per frame only and not in a render to texture context!
function mouselook(senx,seny,gainx,gainy)
local xdelta = (io.getMouseX()-screen_center_w)/senx
local ydelta = (io.getMouseY()-screen_center_h)/seny
local xmul, ymul = 1, 1
if xdelta < 0 then xdelta, xmul = math.abs(xdelta), -1 end
if ydelta < 0 then ydelta, ymul = math.abs(ydelta), -1 end
if xdelta > 1 then xdelta = 1 end
if ydelta > 1 then ydelta = 1 end
xdelta, ydelta = xdelta^gainx, ydelta^gainy
io.forceMousePosition(screen_center_w,screen_center_h)
return xdelta*xmul, ydelta*ymul
end
--takes 2 axis valuse and returns the one wit the highest magnitude
function mix_axis(ax1,ax2)
local aax1 = math.abs(ax1)
local aax2 = math.abs(ax2)
if aax1 > aax2 then
return ax1
else
return ax2
end
end
]
#end
#Conditional Hooks
$State: GS_STATE_GAME_PLAY
$On Frame:
[
--disable mouse toggle from options
io.MouseControlStatus = false
--do some timing stuff
oldgametime = gametime
gametime = mn.getMissionTime()
--only get mouse axes when mission time has progressed (makes mouse useable in interface)
if gametime ~= oldgametime then
ms_x, ms_y = mouselook(mouse_sensitivity_x,mouse_sensitivity_y,mouse_gain_x,mouse_gain_y)
end
--debug print
--ba.print("mouse axis x:"..ms_x..", y:"..ms_y.."\n")
--make game controls available
ba.setControlMode(LUA_FULL_CONTROLS)
local ctrls = ba.getControlInfo()
--do thrusters
ctrls.Sideways = mix_axis(ms_x, ctrls.Sideways)
ctrls.Vertical = mix_axis(-ms_y, ctrls.Vertical)
]
#end