Reaper Grimm
Register | User Profile | Member List | F.A.Q | Privacy Policy | New Blog | Search Forums | Forums Home
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Source Ports > HOW TO: Add Mouse Binds to PrBoom (Plus) Using AutoHotKey in Windows
 
Author
All times are GMT. The time now is 08:07. Post New Thread    Post A Reply
HackNeyed
Member


Posts: 383
Registered: 08-04


HOW TO: Add Mouse Binds to PrBoom (Plus) Using AutoHotKey in Windows

* If you would like to open doors/hit switches with a single Right Click or Middle Click then this will help.

* If you would like to use the Mouse Wheel Up and Wheel Down to select a single weapon each then this will help.

* If you have any better ideas, this might help.

At it’s most basic AutoHotKey can remap keyboard, mice and joystick buttons to most any other button yet the program can do so much more. One can even create another program from it’s scripting language and compile into a self contained exe. The self contained exe is a great feature. Any script can be compiled to an exe and ran from anywhere (like a USB stick) without AutoHotKey needing to be installed on the host system.

First, go to http://www.autohotkey.com/ to download the latest version and install it. Be sure to check out the Keyboard, Mouse & Joystick Reference.

Once installed, open Notepad or create a new text file with an .ahk extention and edit it to include the following code. Replace keys as desired.

After you made the file just double click it to run it. A green icon with a white H will appear in the area next to the windows clock. When compiled to an exe you can even specify an icon of your own. Right clicking the icon will give you the option to edit, reload or quit the program though there is little need to quit the program as I'll explain after the code.

code:
#SingleInstance ignore #IfWinActive PrBoom RButton::Space MButton::5 XButton1::1 XButton2::2 *WheelUp:: SendEvent {4 Down} Sleep 200 SendEvent {4 Up} Return *WheelDown:: SendEvent {3 Down} Sleep 200 SendEvent {3 Up} Return *WheelLeft:: SendEvent {7 Down} Sleep 200 SendEvent {7 Up} Return *WheelRight:: SendEvent {6 Down} Sleep 200 SendEvent {6 Up} Return


Ok, from the top.

The command “#SingleInstance ignore” suppresses a warning message that the script is already running when the currently running script is re-launched. This allows me to place a script launch command in a batch file to ensure it is always running when PrBoom is launched.

The next command “#IfWinActive PrBoom” enables the script to function when, and only when, a window with “PrBoom” in the title is active. This means that Windows, Web Browsers etc remain unaffected. Change “PrBoom” as needed to work with other ports or DosBox.

The next 4 commands are simple re-binds for Right Click, Middle (Wheel) Click, 4th and 5th Mouse Buttons to Spacebar, key 5, key 1 and key 2 respectively. Replace 5 with “Tab” (less the quotes) to open/close the Automap with a middle click.

Lastly, since the mouse wheel has no release (Up) event of it's own the last 4 command groups tell the game a key has been pressed (Down) and is held (Sleep) for 200ms and then released (Up). If you have problems with the game not registering the input or the game switches to the SSG and then the SG without you meaning to; adjust the Sleep time up or down.

ISSUES:

Everything should work on Vista/7. Everything but WheelLeft/Right should work on XP. Win9x... not sure.

Right and Middle mouse buttons still perform their PrBoom assigned action unless disabled in PrBoom’s config

code:
mouseb_strafe -1 mouseb_forward -1


Other Shortcuts

If you add the following code you can change levels by pressing Enter and typing cl## and pressing Enter again

code:
::cl01::idclev01 ::cl02::idclev02 ::cl03::idclev03 ::cl04::idclev04 ::cl05::idclev05 ::cl06::idclev06 ::cl07::idclev07 ::cl08::idclev08 ::cl09::idclev09 ::cl10::idclev10 ::cl11::idclev11 ::cl12::idclev12 ::cl13::idclev13 ::cl14::idclev14 ::cl15::idclev15 ::cl16::idclev16 ::cl17::idclev17 ::cl18::idclev18 ::cl19::idclev19 ::cl20::idclev20 ::cl21::idclev21 ::cl22::idclev22 ::cl23::idclev23 ::cl24::idclev24 ::cl25::idclev25 ::cl26::idclev26 ::cl27::idclev27 ::cl28::idclev28 ::cl29::idclev29 ::cl30::idclev30 ::cl31::idclev31 ::cl32::idclev32 ::cl33::idclev33 ::cl34::idclev34 ::cl35::idclev35 ::cl36::idclev36 ::cl37::idclev37 ::cl38::idclev38 ::cl39::idclev39 ::cl41::idclev41 ::cl42::idclev42 ::cl43::idclev43 ::cl44::idclev44 ::cl45::idclev45 ::cl46::idclev46 ::cl47::idclev47 ::cl48::idclev48 ::cl49::idclev49


To display a different tray icon.

Place this code at the top of your script. It simply tells AutoHotKey to look in the script's working folder for an icon (or in this case, inside prboom-plus.exe and select the 1st icon). There are 6 icons inside prboom-plus.exe, change the 1 to a 2 or a 3 etc. Optionally, place an icon whatever.ico in the folder with the script and change code from “prboom-plus.exe” to “whatever.ico”

code:
#Persistent Menu, Tray, Icon, prboom-plus.exe, 1 return


This also works when the script is compiled as an exe, unfortunately, either way “prboom-plus.exe” or “whatever.ico” must be in the same folder as the script or compiled exe or it will error out unless the icon is added during the process of compiling an exe.

To Compile an exe.

Those wishing to create a standalone exe (and optionally skip installing AutoHotKey entirely by downloading their Zip file instead.)

Locate the “Compiler” folder found in the install folder or extracted from the root of the zip file. Launch Ahk2Exe.exe and browse for your script file. Optionally you can select an output file destination and name as well as an icon file. Once ready hit convert and your script is now a standalone exe that does not require AutoHotKey to be installed or an icon file in the working folder.


Hope that helps.


-EDIT- Bit of Quake Info.

If you want mouselook you might have to create a text file named autoexec.cfg in your id1 folder and add the " +mlook " command.

To disable mouse acceleration in many Quake engines without resorting to system wide registry hacks is it necessary to add -dinput to the command line. Unfortunately -dinput has the side effect of disabling mouse wheel function in game. To remedy this we can create an ahk file to remap keyboard bindings to the mouse wheel.

In quake and my autoexec.cfg I have set page up and page down to scroll my weapons from powerful to weak respectively, similar to ZDoom's default behavior. However pgup and pgdn can be changed to any number/letter that has a weapon or command bound to it. Since quake is a little more responsive with the mouse wheel then PrBoom was we are going leave out the sleep command from the code.

code:
#SingleInstance ignore #IfWinActive , WinQuake , <-- Change to name of Engine, check window name or taskbar. *WheelUp:: SendEvent {pgup Down} SendEvent {pgup Up} Return *WheelDown:: SendEvent {pgdn Down} SendEvent {pgdn Up} Return


In my quake autoexec.cfg / config.cfg I have set the following for weapon scroll up and down.

bind "PgUp" "impulse 10"
bind "PgDn" "impulse 12"

Last edited by HackNeyed on 06-21-10 at 19:00

Old Post 03-27-10 08:39 #
HackNeyed is offline Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
entryway
Forum Staple


Posts: 2733
Registered: 01-04


I did some quick dirty hacks in m_menu/misc.c. Is it even better?

http://prboom-plus.sourceforge.net/...trols-win32.zip

Probably now you can bind mouse for 'use' (directly), 'move backward' and 'strafe left/right'. Also probably you can remove a bind by pressing the same key/button.

Is it really necessary to have ability to bind any action to any mouse button?

Last edited by entryway on 04-23-10 at 02:22

Old Post 04-23-10 02:07 #
entryway is online now Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
HackNeyed
Member


Posts: 383
Registered: 08-04


Thank you very much for looking into this! It would be great to not depend on AutoHotKey anymore.

I tried the prboom-plus-2.5.0.7.test_controls-win32.zip and it works great with Fire on Left and Use on Right with Middle unbound however when I exit the program and start it again my Fire and Use are bound to the Left button and Right is unbound.


entryway said:
Is it really necessary to have ability to bind any action to any mouse button?


I mostly just want single click Use on Right/Middle buttons while disabling Strafe/Forward on the mouse. I toyed with putting the Automap on the Middle button and later a user on Doomworld was asking if that was possible so a range of functions would be appreciated by some users here.

Finally, weapons would be really nice even if it is only on the Right/Middle buttons. I remember that Quasar posted somewhere about wanting to add full mouse (wheel, 4th & 5th button) support to Eternity but that it would take a while because of all the work involved due to limitations in SDL and old DOS code still in Eternity. So I could see myself wanting to bind Fists or Rocket launcher to the Middle button along side the keyboard bind of course if the 4th mouse button isn't supported.

Old Post 04-23-10 03:37 #
HackNeyed is offline Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
Quasar
Moderator


Posts: 6088
Registered: 08-00


The mouse has been fully bindable in EE for a quite a while now, barring 4th & 5th button business, which Gez has sent me a fix for. I just have to decide where I'm going to map those virtual keys. I think that I need to redesign the entire thing now that it shouldn't be strictly limited to 256 codes.

Old Post 04-23-10 18:58 #
Quasar is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Mike.Reiner
Senior Member


Posts: 1187
Registered: 01-05



entryway said:

Is it really necessary to have ability to bind any action to any mouse button?


Being able to properly bind use is all I really want. The ability to unbind is great, too. Thanks for looking into this.

Old Post 04-24-10 01:06 #
Mike.Reiner is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
VinceDSS
Senior Member


Posts: 1295
Registered: 11-02


Interesting, I was actually looking at a the possibility to remap keystrokes to the mouse buttons, just like intellimouse driver does. Except that the last intellimouse driver for windows 98 only handles 3 buttons mice and only a few specific Microsoft 5 buttons mice)

The problem is that: will it work in Windows 98 ? and will it work from a within Win98 command line for Doom2.exe/heretic.exe ?

I'll try your script under 98 and get back here.
If not I wish there was a proper win98 tool out there to remap keys just like intellimouse did.

EDIT : it doesnt work ... mouse remap is not available in win98 ... but it's possible since intellimouse does it. I would pay to have something like this that actually works. Anybody up to the task ? :D

Last edited by VinceDSS on 05-01-10 at 16:36

Old Post 05-01-10 15:48 #
VinceDSS is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
HackNeyed
Member


Posts: 383
Registered: 08-04



VinceDSS said:
it doesnt work ... mouse remap is not available in win98


The Good News: entryway might be working on making this native in PrBoom-Plus (YAY) but since it isn't ready yet I looked at the Docs again and it said for Win9x "The recommended method is to use Send and KeyWait." So try this please. Delete the contents of your .ahk file and add or make a new one with only the following to test if Right Mouse acts as Spacebar.

code:
#SingleInstance ignore #IfWinActive PrBoom RButton:: Send {Space Down} KeyWait RButton Send {Space Up} return


If it works I have made Italic the key name we are 'mapping to' and Bold the key name we are 'mapping from' so you can easily see what to edit if you wish. MButton is the name of the Middle/Wheel Click.

Now.

The Bad News: The Docs also state that Wheel support is only NT/2000/XP or later and XButton1/2 (4th/5th mouse buttons) are only supported in 2000/XP or later. Part of it is probably because Windows 9x has no native driver support for 4th/5th mouse buttons.

Old Post 05-01-10 18:05 #
HackNeyed is offline Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
VinceDSS
Senior Member


Posts: 1295
Registered: 11-02


Well, intellimouse 4.12 (for win98) support remapping keystrokes to 4 & 5. That's what I use for my doom2.exe / heretic.exe setup.
Intellimouse was not detecting the 4th and 5th button when it was plugged on the USB, changed to PS2 and now it works.

Anyhow, I was very interested in the mousewheel side of this.
Yet again for command line apps in Win98, not prboom-plus. A prboomplus port for heretic 1.3 would be interesting though.

Old Post 05-01-10 18:30 #
VinceDSS is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
All times are GMT. The time now is 08:07. Post New Thread    Post A Reply
 
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Source Ports > HOW TO: Add Mouse Binds to PrBoom (Plus) Using AutoHotKey in Windows

Show Printable Version | Email this Page | Subscribe to this Thread

 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are OFF
[IMG] code is ON
 

< Contact Us - Doomworld >

Powered by: vBulletin Version 2.2.5
Copyright ©2000, 2001, Jelsoft Enterprises Limited.