View Full Version : [TEC] Tutorial for mapping commands to keys?
panthercules
07-31-07, 11:35 AM
I know there's got to be one out there somewhere, but I couldn't find it when I searched so I hope someone can point me to it here. There are lots of commands listed in the command.cfg file that don't seem to have keys mapped to them, and I'd like to map a few to be able to use them with voice recognition.
Can someone point out how to go about mapping some of these commands to keys? (such as the following one, for example):
[Cmd152]
Name=Propulsion_recharge
Ctxt=1
MnID=0x3F0F0002
CaptainCox
07-31-07, 01:34 PM
This is a pretty good tut
http://www.subsim.com/radioroom/showthread.php?t=113354
and this written by myself :p (example of adding the "weather report button")
http://www.subsim.com/radioroom/showthread.php?t=118548
Then you need to do the graphics of the button if you want to do it properly
All the buttons are found here
C:\Program Files\Ubisoft\Silent Hunter 4 Wolves of the Pacific\Data\Menu\Gui\Layout
Called Hud.dds
panthercules
07-31-07, 08:38 PM
Capt - thanks for the response and the links to the buttons tutorials.
Unfortunately, I must not have been clear enough - I'm not looking to make new buttons at all here. Just looking to be able to assign some commands to keys (so I can then use the speech recognition program that works by recognizing a spoken command and outputting a key stroke signal). In my example above, I was looking to be able to assign a key to toggle "recharge batteries", so I could speak a command to do that instead of having to push the button for it.
I know it's fairly easy to re-assign keys for game commands that have already been assigned to keys (e.g., changing "fire" to be "Ctrl+Enter" instead of just "Enter"), but I'm not sure how to do it for a command that hasn't been assigned to a key in the first place.
Any ideas?
DirtyHarry3033
07-31-07, 09:02 PM
Panthercules, do this:
1) Download and install SetKeys 1.11 for SH3, it's in the download section here at subsim.
2) Make a copy of your commands.cfg file somewhere else on your drive. That is important, you don't want to edit your real commands.cfg with SetKeys as there are some keys it will break in SH4 (it was written for SH3...)
3) Point SetKeys to the copy you made. Locate the commands you want and assign keys to them, then save the file.
4) Open up your edited copy in Notepad or your favorite editor, and open the real commands.cfg in another session of your editor.
5) Locate and copy/paste the commands you changed in the copied/edited commands.cfg into the real commands.cfg. Then save and enjoy!
Of course, back up your live commands.cfg 1st in case something goes wrong ;) I've done a number of keymappings this way and it works great!
HTH!
DH
Fearless
07-31-07, 09:49 PM
I for one go into the Commands.cfg and look for key commands that have been disabled with the ; then
I check to make sure that key hasn't been re-allocated to some other command.
If it hasn't, I copy that key command line and paste it where I want to activate a particular command.
Eg,
[Cmd152]
Name=Propulsion_recharge
Ctxt=1
MnID=0x3F0F0002
SetKey=0x34D,,"T"
At work now so can't fully remember what the key= line looks like but is similar to that I think.
DirtyHarry3033
07-31-07, 10:06 PM
That's the cool thing about SetKeys, it will tell you if there's a conflict with the key you picked. Also it gives the right hex-code for the key and the right syntax, so it is a no-brainer for a brain-dead moron like me :rotfl:
Only prob is, as I mentioned, if you edit the live SH4 commands.cfg with it, some keys get broken. Two that I noticed were, gramophone and radio. Neither keys nor buttons would work. But if you edit a copy of commands.cfg and then just paste in only the changed commands to the live file, it's no problem at all. Nothing breaks and you don't have to worry about hex codes or syntax!
DH
That's the cool thing about SetKeys, it will tell you if there's a conflict with the key you picked. Also it gives the right hex-code for the key and the right syntax, so it is a no-brainer for a brain-dead moron like me :rotfl:
Only prob is, as I mentioned, if you edit the live SH4 commands.cfg with it, some keys get broken. Two that I noticed were, gramophone and radio. Neither keys nor buttons would work. But if you edit a copy of commands.cfg and then just paste in only the changed commands to the live file, it's no problem at all. Nothing breaks and you don't have to worry about hex codes or syntax!
DH
I was never able to get SetKeys to work for me with SHIII. I know what you mean about editing the commands.cfg and breaking commands. I got so fed up with this I went through the entire file and deleted every command that had been remarked out (and there were a bunch of them). After cleaning up the file like that, I can edit at will now without losing a single command. :up:
panthercules
07-31-07, 11:34 PM
I for one go into the Commands.cfg and look for key commands that have been disabled with the ; then
I check to make sure that key hasn't been re-allocated to some other command.
If it hasn't, I copy that key command line and paste it where I want to activate a particular command.
Problem I have is with the commands where there just isn't any key line (disabled or otherwise), like the one below:
[Cmd152]
Name=Propulsion_recharge
Ctxt=1
MnID=0x3F0F0002
Does the SetKeys thing work for those kinds of commands which never had key lines? If so, guess I'll give that setkeys thing a try - I remember seeing some posts about it during the SH3 days, but I never messed with it so this will be another adventure :D
Thanks for the tips on how to protect my real file - I suspect that will prove to be very sage advice :yep:
Fearless
07-31-07, 11:53 PM
Problem I have is with the commands where there just isn't any key line (disabled or otherwise), like the one below:[Cmd152]
Name=Propulsion_recharge
Ctxt=1
MnID=0x3F0F0002
Does the SetKeys thing work for those kinds of commands which never had key lines? If so, guess I'll give that setkeys thing a try - I remember seeing some posts about it during the SH3 days, but I never messed with it so this will be another adventure :D
Thanks for the tips on how to protect my real file - I suspect that will prove to be very sage advice :yep:
That's true. Thing is if no key has been disabled then I'm assuming that not all keys are used bearing in mind that I'm trying to visualise the keyboard un-assigned keys from memory :hmm: One key that does prop up is the 'G' key. Now I don't know what the hex code id for the 'G' key is but may well be worth trying to copy a SetKey line then placing it against that [Cmd152] location, change the letter to 'G' and see what happens. Worst thing that could happen the way I see it is that because of the hex id code for the key that was copied could cause a conflict with the original SetKey command.
A brainwave :know:
Copy a SetKey line like as per my example above ie:
SetKey=0x34D,,"T" then use the shift or ctrl as an addition, then you can use the same SetKey command but it now looks like:
SetKey=0x34D,s,"Shift+T" or
SetKey=0x34D,c,"Ctrl+T"
You still need to check that those combinations haven't already been used. You therefore then use the shift or control key as well.:)
panthercules
08-01-07, 12:52 AM
Well, didn't have much luck with that effort. I figured out that SetKey seems to want the commands file named the same as it was in SH3, so I renamed my copy of my SH4 commands.cfg file as "commands_en.cfg" and SetKey found it and opened it up, so I thought everything was going well. I found and added a few key mappings to commands that didn't seem to have any yet, and that all seemed to go well too, BUT when I tried to save and exit SetKey it threw off a bunch of error messages about not being able to find the right path or something, and when I quit I checked my copy of the file and no changes had been made to it :cry:
Any idea what's going wrong with this? It seemed like it was gonna be so easy once I got it pointed to the right file, but something obviously went wrong.
Fearless
08-01-07, 01:19 AM
I'll try it out myself when I get home from work otherwise I've reached the end of my limited skills I have got with tweaking stuff.
CaptainCox
08-01-07, 04:25 AM
@panthercules. I think I was a bit drunk when answering this yesterday :p I re-read the topic now and see my mistake.
DirtyHarry3033
08-01-07, 05:39 AM
Well, didn't have much luck with that effort. I figured out that SetKey seems to want the commands file named the same as it was in SH3, so I renamed my copy of my SH4 commands.cfg file as "commands_en.cfg" and SetKey found it and opened it up, so I thought everything was going well. I found and added a few key mappings to commands that didn't seem to have any yet, and that all seemed to go well too, BUT when I tried to save and exit SetKey it threw off a bunch of error messages about not being able to find the right path or something, and when I quit I checked my copy of the file and no changes had been made to it :cry:
Any idea what's going wrong with this? It seemed like it was gonna be so easy once I got it pointed to the right file, but something obviously went wrong.
What's the exact error msg? I just put my copy of Commands.cfg in the same folder with SetKeys.exe and never had any problems saving. Maybe something got corrupted when you downloaded it?
One thing I totally forgot to mention is, if you don't rename to "Commands_en.cfg" the file open dialog won't automatically show the file. A way to get around that without renaming is to type "*.cfg" in the file name box and hit "Enter", then Commands.cfg will show up in the dialog.
DH
panthercules
08-01-07, 06:23 PM
Well, didn't have much luck with that effort. I figured out that SetKey seems to want the commands file named the same as it was in SH3, so I renamed my copy of my SH4 commands.cfg file as "commands_en.cfg" and SetKey found it and opened it up, so I thought everything was going well. I found and added a few key mappings to commands that didn't seem to have any yet, and that all seemed to go well too, BUT when I tried to save and exit SetKey it threw off a bunch of error messages about not being able to find the right path or something, and when I quit I checked my copy of the file and no changes had been made to it :cry:
Any idea what's going wrong with this? It seemed like it was gonna be so easy once I got it pointed to the right file, but something obviously went wrong.
What's the exact error msg? I just put my copy of Commands.cfg in the same folder with SetKeys.exe and never had any problems saving. Maybe something got corrupted when you downloaded it?
One thing I totally forgot to mention is, if you don't rename to "Commands_en.cfg" the file open dialog won't automatically show the file. A way to get around that without renaming is to type "*.cfg" in the file name box and hit "Enter", then Commands.cfg will show up in the dialog.
DH
Well, I had figured out the renaming thing when the file didn't show to SetKey up initially, but I had created a separate folder for my backup copy of the commands file - I'll try putting the renamed comands file in the same folder as the SetKey program and see if that does the trick. Thanks for the suggestions.
panthercules
08-01-07, 06:38 PM
Wow - that's definitely weird. Based on the error message (really long, but dealt with not being able to find part of the path blah blah blah...), I was able to figure out that in addition to renaming the commands file to commands_en.cfg and putting the renamed commands file in the same folder as SetKey is in, you also have to create a copy of the commands file in that same folder and call it "commands_en.bak".
Once that was done, SetKey saved the changes down just fine, without error messages.
Now, just have to compare the changed file to the old one and see if it made all the changes I asked it to without breaking something inside the file.
[EDIT] Good suggestion to just find the specific commands that got changed and then paste the new key lines into a clean copy of the SH4 commands.cfg file, because SetKey really does screw up/change a bunch of unintended stuff inside that file when it's doing its thing. However, just pasting in to a clean copy only the changed key line in the specific commands you know you changed worked just fine. I was able to map a key to "get depth below sub keel" and use the key in game just fine.
(Note for those interested - there is also a command called "report depth below keel" or something like that. I tried that first, but while the mapping worked and the key called up a report in game, the answer was always wrong - it always said depth below keel was 0. So you need to use the one that starts with "get" - using the key mapped to that command brought back the same answer that clicking the depth-below-keel button did.)
Now to map the other commands and get them entered into the speech recognition program files, then it's out to sea again :)
DirtyHarry3033
08-01-07, 08:03 PM
Glad you got it working now!
Actually after I made that last post, I got what I think was the exact same error you mentioned when I shut down SetKeys. I had made several "nested" folders and put Commands.cfg at the bottom level, opened it, made a change and saved, to see if maybe the depth of folders had something to do with it. Worked fine, so I deleted the folders I'd set up. Then, when I quit SetKeys it popped up an error dialog complaining about a missing path, was like 8 or 10 lines long. Bet it was the same error you saw ;)
So, I'm wondering if you accidentally deleted something SetKeys expected to see, before you saved?
BTW, my experience is that SetKeys makes the Commands_en.bak when you save. It's a backup of the original file in case your mods don't work. You can just rename it and undo your changes. Shouldn't be necessary for you to create it yourself to make SetKeys save your changes!
OK, now that you've got it working all you need to do is open your edited copy in one text editor, and your live file in another. Then for each command you mapped to a key, copy the new "Key0=" line from the edited file, and paste it into the live file as the last line for the relevant command. Then save, and you should be able to use the new keymap to execute the command!
One thing to keep in mind is, if you add a mod that affects Commands.cfg it will blow away all your hard work. I always replace the mod's Commands.cfg with my custom one before installing the mod. That way I can keep my keymap! If there are newly-mapped keys in the mod that I want, I add them to my Commands.cfg before I do that, that way I get the best of both worlds.
Good luck, hope you get it working like you want - that voice recog absolutely rules! I use Shoot! and won't think of playing without it :up:
DH
panthercules
08-01-07, 09:45 PM
I've taken to creating my own JSGME-ready mods with just my tweaked config files in them (e.g., menu_1024_768.ini, menu.txt, cameras.dat, etc. - and now commands.cfg) - that way, I can install and uninstall them just like any other mod, which has saved me a tremendous amount of time during testing and saved me from losing any of the work when I install or uninstall other mods. Just have to keep track (which I usually do in a readme or the title of my mod folder) of which mods formed the basis/starting point for my tweaks - so I can distinguish the stock 1.3-based ones from the RFB-based ones, for example. Things can get so confusing, but this has really helped me keep things straight while I'm doing all this experimenting and other folks' mods are still getting updated.
I'm not sure what the problem with the .bak files was, but for some reason SetKeys didn't create its own .bak copy but worked as soon as I created one for it to detect/use. In any event, it seems to be working fine now, and I've successfully added mapped keys to about 6 or 7 of my most-wanted commands, so I'm looking forward to getting them loaded into the speech recognition files and using them on patrol.
It's been a while since I used Shoot (back in my heavy SH3 days) - does it allow you to assign multiple spoken commands to the same game action/key output? (i.e., can you set it up so it will recognize 3 different ways to give the "dive" command, or is it limited to a one-to-one arrangement?) I never really thought about doing that when I was using it, so I don't think I ever actually tested that, but I had the impression for some reason that you couldn't tell it to output the same letter if it heard "this" or "that". Maybe I was just thinking too narrowly at the time.
DirtyHarry3033
08-02-07, 05:22 AM
Shoot! lets you set up as many statements for a command as you want. Here's my commands for the attack scope for example:
-------------------------------------------------------------------------
<command name="Go To Attack Periscope 1" phrase="attack scope">
<key type="F4"/>
</command>
<command name="Go To Attack Periscope 2" phrase="attack periscope">
<key type="F4"/>
</command>
<command name="Go To Attack Periscope 3" phrase="go to attack scope">
<key type="F4"/>
</command>
<command name="Go To Attack Periscope 4" phrase="go to attack periscope">
<key type="F4"/>
</command>
<command name="Go To Attack Periscope 5" phrase="scope">
<key type="F4"/>
</command>
<command name="Go To Attack Periscope 6" phrase="periscope">
<key type="F4"/>
</command>
<command name="Go To Attack Periscope 7" phrase="go to periscope">
<key type="F4"/>
</command>
<command name="Go To Attack Periscope " phrase="go to scope">
<key type="F4"/>
-------------------------------------------------------------------------
So that's 8 different ways to say it, you could have 80 if you wanted ;)
If you're gonna use Shoot, you might also want to get the profile editor here:
http://clans.gameclubcentral.com/shoot/
Makes it a lot easier to write a profile, especially if you're starting from scratch instead of modifying an existing one!
DH
Digital_Trucker
08-02-07, 09:12 AM
Yep, not only can you make multiple statements for a command, you can make multiple commands for a statement (with pausing to allow for actions to happen). For instance, you can set one statement to issue a crash dive command, wait for a specified number of milliseconds, then rudder hard to port/starboard, wait again, deploy decoys, and go silent. The only problem with this kind of command set is that I don't think Shoot will accept any more commands until it is done with the group.
DH is right about the editor, too. I wouldn't want to make an SH profile without it (that's why I wrote it to begin with, I got tired of :damn: trying to code commands:lol: ).
The one thing Shoot doesn't do that would really be helpful is mouse movement/actions. Given all the hassle that you would have to go through for different screen resolutions, I can understand why that function is not there, though.
vBulletin® v3.8.11, Copyright ©2000-2024, vBulletin Solutions Inc.