Author Topic: mouse thrusters  (Read 2934 times)

0 Members and 1 Guest are viewing this topic.

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
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.

Code: [Select]
#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

« Last Edit: December 02, 2010, 06:05:05 pm by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Dragon

  • Citation needed
  • 212
  • The sky is the limit.
Should that work with default settings, or do I have to adjust something in my CH Manager?

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
in whatever map you use for freespace, you need to configure the thumbstick axes as mouse x and y. only problem is that it seems really unresponsive, seems you only get a fraction of the lateral thrust that is actually available. i actually looked into this and found that the ch virtual mouse was only updating about every 3rd frame. when i used glovepie to convert axes to mouse it worked much better.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Dragon

  • Citation needed
  • 212
  • The sky is the limit.
OK, I've tested it, but it seems that using mouse screwed up main joystick controlls.
Also, you get only a small fraction of available speed and you need to be carefull with the thumbstick while not playing, since it's moving the cursor, which isn't too comfortable.
Would that be possible to make a script which would assign thrusters to a specified (in script or in config) axis?

  

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
i think its entirely an issue with whatever map youre using in your ch software. all my script really does, is take mouse delta, and apply it to the lateral and vertical thrusters. it shouldn't screw with any other controls in the game. so im going to post this:

nukes ch profiles

there are 3 versions. all of them have all the buttons bound directly to the keyboard, so you can reset all controls to defaults and the buttons on the joystick will still work. there are a few that need binding, specifically axes. as for the 3 versions one is the one i normally use. the thumbstick controls the lateral thrusters, but only digitally, and the controls for the thrusters still need to be bound i think. the 2nd and 3rd ones dont do this, one uses the thumbstick as a mouse, and one uses them as 2 more joystick axes, in the vain hope that fs2 will eventually use them. it should be obviouse which is which. mind you they require pro throttle, pro pedals, and a fighterstick.

so i suggest trying the script with my mouse profile in the archive there. it works but not very well. something about ch virtual mouse refresh rate. actually i suggest using the 6 axis profile, then use use something like glovepie to map the 5th and 6th axes to the mouse. for some reason glovepie has a better virtual mouse. i personally dont like the idea of runnig a ch script for the controller, then running a glovepie script for the virtual mouse, then having to run another script in the game to make it sort of work. this is where id like to point out that this script is a dirty hack for letting the player proportionally control their lateral thrusters.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN