Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

MouseLook mode for BF2


  • Please log in to reply
18 replies to this topic
gungho
  • Members
  • 4 posts
  • Last active: Jul 18 2005 08:38 PM
  • Joined: 07 Jul 2005
If you play BF2, you will be as annoyed as me that it does not support HAT switches in planes & helicopters. So heres a script to do it for you !

; HatMouse script
; by Dave Derrick.
; Enables Joystick HAT switch to operate MouseLook POV mode
; in various games, e.g. BattleField 2


; Joystick to use
JoystickNumber = 1

; The delay in milliseconds to check state of HAT control
HatDelay = 100

; Amount to move mouse by
MoveBy = 10

; Speed to move mouse at, 0 - 100
MoveSpeed = 10

;MouseLook key
MouseLookOn = {LCTRL Down}
MouseLookOff = {LCTRL Up}

ButtonLeft = 1

#SingleInstance

; define a hotkey that does nothing, to stop script exitting
Hotkey, %JoystickNumber%Joy%ButtonLeft%, ButtonLeft

GetKeyState, JoyInfo, %JoystickNumber%JoyInfo
IfInString, JoyInfo, P  ; Joystick has POV control
	SetTimer, HatMouse, %HatDelay%

return  ; End of auto-execute section.

ButtonLeft:
return

HatMouse:
GetKeyState, JoyPOV, %JoystickNumber%JoyPOV
if JoyPOV = -1  ; No angle.
{
	Send %MouseLookOff%
	return
}
else
{
	Send %MouseLookOn%
}
if JoyPOV = 0 ; Up
{
  MouseMove,0,-%MoveBy%,%MoveSpeed%,R
}
else if JoyPOV = 4500 ; up/right
{
  MouseMove,%MoveBy%,-%MoveBy%,%MoveSpeed%,R
}
else if JoyPOV = 9000 ; right
{
  MouseMove,%MoveBy%,0,%MoveSpeed%,R
}
else if JoyPOV = 13500 ; right/down
{
  MouseMove,%MoveBy%,%MoveBy%,%MoveSpeed%,R
}
else if JoyPOV = 18000 ; down
{
  MouseMove,0,%MoveBy%,%MoveSpeed%,R
}
else if JoyPOV = 22500 ; down/left
{
  MouseMove,-%MoveBy%,%MoveBy%,%MoveSpeed%,R
}
else if JoyPOV = 27000 ; left
{
  MouseMove,-%MoveBy%,0,%MoveSpeed%,R
}
else if JoyPOV = 31500 ; left/up
{
  MouseMove,-%MoveBy%,-%MoveBy%,%MoveSpeed%,R
}
return

Its my 1st script for AutoHotkeys, so dont be too harsh ;)
Posted Image

  • Guests
  • Last active:
  • Joined: --
This is something i've been looking for quite a while! But where exactly do i add these lines? Which file should be edited?

gungho
  • Members
  • 4 posts
  • Last active: Jul 18 2005 08:38 PM
  • Joined: 07 Jul 2005
I have a better version of the script, go here -
http://www.milagro.p... ... Mouse.html

Here's how you get it working.
1) Download & Install AutoHotKey.
2) Download & save my script, I save all my scripts to C:\Program Files\Autohotkey\Scripts
3) Right click my script file & select "Compile script" from the pop-up menu.
4) When the compiler finishes, you have a file called HatMouse.exe, just run this & your done !

Any problems, give me a shout.
Posted Image

Lanser
  • Guests
  • Last active:
  • Joined: --
Nice work Gungho, I was using JoyToKey to accomplish the same thing. I haven't tried your script yet but intend to try it later.

Would it be possible to only have the POV mode using the hat active when you have a certain Joystick button pressed, say key 6 or 7 for instance. I would prefer the Hat keys default function to be switching between Chase Rear, Chase Front and Fly-by views and only have the POV mode kick in when another button in pressed.

Great work though.

BigMan21
  • Guests
  • Last active:
  • Joined: --
Thanks very much for this. me and a buddy were discussing how usefull a HAT controlled POV would be in a plane when chasing someone... glad someone else felt the same way 8)

  • Guests
  • Last active:
  • Joined: --
can u change the up and down
so that up is down and down is up

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
I guess you have to invert the up/down values of MouseMove in the above script. You can do it yourself.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

  • Guests
  • Last active:
  • Joined: --
yer i tryed that and it didnt work, thats y i asked if u could
cos i tryed and didnt work

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Does the original code work?

If it does, you have to invert the sign of the second parameter of the MouseMove commands, e.g.
MouseMove,%MoveBy%,-%MoveBy%
to
MouseMove,%MoveBy%,%MoveBy%
and
MouseMove,%MoveBy%,%MoveBy%
to
MouseMove,%MoveBy%,-%MoveBy%
regardless of what is in the first parameter
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

  • Guests
  • Last active:
  • Joined: --
yer that top code works i just dont know how to get it to work the way im asking,


ps i have no idea what im doing
so asked if someone could make it for me

watar
  • Members
  • 1 posts
  • Last active: Feb 16 2006 11:25 AM
  • Joined: 16 Feb 2006
This script is just what I've been looking for since BF2 came out :D Made my life as a heli-pilot so much easier when I actually can keep an eye out for trees, buildings, enemies... Thank you 8)

My problem/question is that I would like to add a few functions from other bf2 scripts I've found on this forum but when I do the hat looses all mouselook functions. Since I'm a complete AHK newb I must do something wrong and would love it if someone could help figure it out.

I'm using the script above with this addon at the end.
; Use Joy4 to report spotted enemies
$Joy4:: 
   Send, {Q Down} 
   Sleep 100 
   MouseClick, left, , , , D 
   Sleep 100 
   MouseClick, left, , , , U 
   Sleep 100 
   Send, {Q Up} 
return

; Use Joy5 to say Sorry for TK 
$Joy5:: 
   Send, {q Down} 
   Sleep 100 
   MouseMove, 30, 1, , R 
   Sleep 100 
   MouseClick, left 
   Sleep 100 
   Send, {q Up} 
return 
If I combine these script to one file the joystick buttons works as they should but not the hat. If I compile them as two seperate .EXEs both functions work but not as one combined .exe. Could someone help me figure this one out?

/W

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

If I combine these script to one file the joystick buttons works as they should but not the hat.

Generally, your hotkeys should appear beneath the auto-execute section, which is the top part of the script that executes automatically when you launch the script. In this case, it is probably safest to put your joystick hotkeys at the bottom of the script.

For details, see http://www.autohotke...ocs/Scripts.htm

towlie65
  • Guests
  • Last active:
  • Joined: --
i know this is off topic by alot but i have been searching the net for a while and this is the closest forum i have come to for my answer. is there a way that you can asign a key so you can leave a squad in bf2? for example as default 'insert' creates a squad ...is there a way that someone could asign 'end' to leave the squad? is there a way to do it just by editing the controls file in bf2? or can you do it with one of those programs? thanks in advance

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
If the game doesn't have a built-in way to do it, you might be able to do it with a hotkey that sends keystrokes or mouse clicks. For details, see the Hotkeys page and the Quick-start Tutorial.

  • Guests
  • Last active:
  • Joined: --
This is a message for watar who post his problem above.

Can you post us a copy of the working script with both the mouse hat trick from above as well as your radio binds working as well,

I sure am interested.

:)

awaiting your soonest response, RickyRayRay