Page 1 of 6 123 ... LastLast
Results 1 to 10 of 55

Thread: Command / key-press macros

  1. #1
    Crew Chief Mega Corp CEO mr_belowski's Avatar
    Join Date
    Feb 2017
    Posts
    1,815

    Command / key-press macros

    Guys,

    In the latest release we've added the ability to send sequences of key presses from the app to the game (PC only), in response to voice commands (or in a couple of special cases, triggered by events in the game). This is all a work in progress and has no pretty user interface - it's all driven by a configuration file.

    The app includes some common macros for Raceroom and ProjectCars2, but I expect the list to grow (a lot), so if there are any common sequences of key presses you're having to make to do stuff in-game these could be incorporated into the default macro configuration. Stuff like requesting a pit stop, selecting pit actions, etc.


    Here's the text from the help file, which explains it a bit more:

    Command macros
    --------------
    The app can send sequences of key presses in response to voice command or some specific (hard-coded) in-game events. These can be used for anything you like, but their primary function is to ease the pain of navigating the awkward in-game pit menus. The app comes with a default set of command macros which (at the time of writing) are for PCars2 and Raceroom only. More will be added for other games. The default commands can be found in [install folder]/saved_command_macros.json. If you want to make your own, copy this file to a your Documents folder, in a subfolder called CrewChiefV4 (i.e. Documents/CrewChiefV4/saved_command_macros.json) and edit it as you like.


    The first thing you need to do is to update your key assignments in-game so they match the keys that the command macro will send.




    Raceroom


    default key bindings:
    "Pit Menu Toggle": q
    "Pit Menu Select": e
    "Pit Menu Up": w
    "Pit Menu Down": s
    "Pit Menu Decrease": a
    "Pit Menu Increase": d
    "Pit Request Toggle": r
    "Real-time Chat": c


    Ensure that there's a least one Pitstop Preset defined (from the in-game pit menu).


    You can request a pit stop by saying "pit request", "in this lap" or "box this lap". This will open the pit menu, select 'pit request' and close it again after a few seconds delay. When you enter the pitlane the app will automatically open select 'confirm pit actions' from the pit menu so you don't have to fumble around.


    You can also cycle pit presets with the voice commands "next strategy", "next pit preset", "previous strategy", "previous pit preset".


    If you want to manually navigate the pit menu with voice commands, use "pit menu toggle", "pit menu up", "pit menu down", "pit menu left", "pit menu right" and "pit menu select".




    PCars2


    default key bindings:
    "Car Management": e
    "ICM Menu Up": w
    "ICM Menu Down": s
    "ICM Menu Left": a
    "ICM Menu Right": d
    "Pit Request Toggle": q
    "In-game Chat Box": t


    You can request a pit stop by saying "pit request", "in this lap" or "box this lap". This will open the pit menu, select 'pit request' and close it again.


    You can select strategies with the voice commands "strategy one" / "strat one", up to "strategy four" / "strat four".


    If you want to manually navigate the pit menu with voice commands, use "pit menu toggle", "pit menu up", "pit menu down", "pit menu left" and "pit menu right".



    Advanced command macros
    --------------

    As you can see from the previous section, key press macros are complicated and a bit dumb - the app has no idea what state the pit menu is in so it has to either make lots of assumptions or work quite hard to put the menu into a known state.


    There are 2 macros for adding fuel. In both cases, for them to work in R3E the selected pit preset must have fuel *selected* (i.e. highlighted green). One uses the logic of the app's 'Fuel' event to calculate how much fuel is needed to finish the race ("fuel to the end" voice command), the other uses the amount of fuel requested in the voice command ("add fuel, 100 litres" or whatever). These macros opens the pit menu, navigate to the fuel option and attempt to reset it to zero litres. Because they can't know how much fuel might already be set on this menu they have to press the 'decrease' button lots (150) times. This ensure it's at zero before they then add the calculated or requested amount of fuel.


    *Note that these will only work correctly if you use Litres as your unit*.


    Another point to note here is that these fuelling macros press 'decrease' 150 times quite quickly to ensure the fuel amount is zero before they start increasing it. When things are configured correctly it works well, but it's a lot of key presses and if something goes wrong the end result may be undesirable.


    The macro feature can also be used to automate chat messages. There are examples for pCars2 and R3E. Again, these just send sequences of key presses.


    There are a few special key press commands in save_commands_macros.json to help ease the pain of wiring these things up. The "actionSequence" element is the list of key presses. These usually refer to action items in the keyBindings section at the top of the file. However, they can also be plain keys - e.g. [..., "a", "b", "c", ...].


    - To send a fixed number of multiple key presses use "{MULTIPLE,153}Pit Menu Decrease" (presses the Pit Menu Decrease key 153 times).
    - To send a number of multiplekey presses based on some app logic, use "{MULTIPLE,Fuel}ICM Menu Right" (presses ICM Menu Right however many times the Fuel event told it to). This requires specific application code to work but i'm happy to take requests .
    - To send a number of multiple presses based on the voice command that triggered the macro, the voice command needs to use a special format with the number range to recognise in curly braces - e.g. "add fuel, {1,150} litres" (recognises "add fuel 0 litres" up to "add fuel 150 litres", in steps of 1). Use "{MULTIPLE,VOICE_TRIGGER}Pit Menu Increase" to press (in this example) Pit Menu Increase the number of times recognised in the voice command.
    - To send a sequence of key presses from some free text, use "{FREE_TEXT}sorry, my bad". Each of the keys after {FREE_TEXT} will be pressed in sequence. Only letters, commas, hypens and full-stops are supported. This is to make chat macros more straightforward (e.g. ["Real-time Chat", "{FREE_TEXT}good pass", "ENTER"]).


    The file saved_commands_macros.json in your app's installation folder has examples of all this stuff and lots of comments that should further demystify the process. Alternatively just get the correct in-game key bindings and just use the stuff I've already configured.

    Hopefully the game devs will make these menus or the actions they trigger easier to use for 3rd party apps. But until they do, these complicated automated interactions are always going to be flaky.
    Attached Images Attached Images  

  2. #2
    Junior Member Paul Bee's Avatar
    Join Date
    Dec 2017
    Posts
    2
    I need help to understand this please.

    I'm a sim racer of 'more mature years' and have, until now, restricted my racing activities to the PS4 platform, most notably with the original Project Cars and Crew Chief on an Android device. However, with some rather disappointing 'issues' in the new Project Cars release, I've made the move to a PC platform within the past 2 weeks and am currently in the middle of a very steep learning curve.

    I downloaded Raceroom and have even managed to get Crew Chief set up..... The next phase, when December 25th comes along, will be my first venture in to VR and so I have read your post on voice commands with great interest.

    Do I need to install and set up voice command software? Voice Attack or somesuch? I'm running Windows 10 which I believe has a voice command function. Should I spend time learning setting this up and when done, will I be able to adopt your voice command functions?

    Any help would be much appreciated.

    Thanks
    Paul

  3. #3
    Crew Chief Mega Corp CEO mr_belowski's Avatar
    Join Date
    Feb 2017
    Posts
    1,815
    Crew Chief voice recognition uses Microsoft Speech Recognition. This is *not* the same as Windows Speech Recognition. To use voice recognition with Crew Chief, you need to install the recognition engine:

    https://www.microsoft.com/en-gb/down....aspx?id=27225

    and then install a speech recognition language pack:

    https://www.microsoft.com/en-gb/down....aspx?id=27224


    that's all you need to do - no training or anything. You mic needs to be the default audio recording device.

  4. #4
    Junior Member Paul Bee's Avatar
    Join Date
    Dec 2017
    Posts
    2
    Thank you. I'll look in to it.

  5. #5
    Junior Member
    Join Date
    Dec 2017
    Posts
    3
    Mr. Belowski-
    I wanted to be able to send messages in Assetto Corsa text chat using speech, so I forked the repository to find out how I could add that behavior. I thought GrammarBuilder.AppendWildcard() [or maybe DictationGrammar and SetDictationContext] might let me grab any text following some initial marker phrase (e.g., "Say "), and then I could use SendKeys() to send the keystrokes to AC.

    This was until I found saved_command_macros.json

    Is the design of saved_command_macros flexible enough to allow me to send arbitrary words as keystrokes to AC?
    Last edited by Danny; 17-02-2018 at 02:07.

  6. #6
    Crew Chief Mega Corp CEO mr_belowski's Avatar
    Join Date
    Feb 2017
    Posts
    1,815
    The speech recognition engine is grammar based, not trained. It's not designed to recognise free speech - you have to limit the stuff it listens for otherwise the search space becomes too big and it gets very unreliable.

    If there is a fixed list of chat messages you want to send, then that can be done with saved_command_macros.

    If you want free diction here, you'll need to integrate the windows built in speech recognition engine

  7. #7
    Junior Member
    Join Date
    Feb 2018
    Posts
    3
    Hi my friend. Love your app.

    I used DRE before but yours is much better. I also donated so uou can continue to enhance and aupport it. :]

    One question related to macros. I use iracing and need to program 2 commands via voice or wheel button

    1) tear off(to clean my visor). Default iracing keys are alt+t
    2) trigger whipers. Default iacing is ctrl+shift+w

    How do i do that in crew chief

  8. #8
    Crew Chief Mega Corp CEO mr_belowski's Avatar
    Join Date
    Feb 2017
    Posts
    1,815
    If you need to assign an action to a key-combination (alt-t or whatever), CC doesn't (yet) support that. The macros are single-key press only.

    If you want to reconfigure iRacing so your tear-off is triggered by, say, just the 't' key, you'd need to add this key to the iRacing key bindings:

    Code:
    {
            "description": "iRacing command mappings - these are the key assignments in the Options -> Controls",
            "gameDefinition": "IRACING",
            "keyBindings" : [
            {
                "action": "Lap Timing Black Box",
                "key": "F1"
            },
    .....
                   {            "action": "Tear off",
                "key": "KEY_T"
            }

    and then make a macro in the 'macros' section:

    Code:
    {
            "name": "Tear off",
            "description": "Presses T",
            "voiceTriggers": [ "tear off" ],
            "commandSets": [
            {
                "description": "iRacing only",
                "gameDefinition": "IRACING",
                "actionSequence": [ "Tear off" ],
                "keyPressTime": 10,
                "waitBetweenEachCommand": 200
            }]
        },
    .....
    Last edited by Sparten; 01-03-2018 at 16:17.

  9. #9
    Junior Member
    Join Date
    Feb 2018
    Posts
    3
    Thanks a million.

    It's almost there.

    I rather not change the default since it's used across multiple of my apps...

    I can wait. Your app is getting better and better...for now, I am running voice attack simultaneously to send a few extra commands...

  10. #10
    Junior Member
    Join Date
    Feb 2018
    Posts
    2
    I've attempted to add the "tear off" comand like the example above, it kinda works but doesn't actually do the tear off.
    I have the "T" key configured in options to do the visor tear off.
    Thanks for any help of what I've done wrong, details are below\

    Jay

    When I start Crew Chief I get this
    Code:
    17:41:00.523 : Loading user-configured command macros from Documents/CrewChiefV4/ folder
    17:41:00.716 : Action Tear off not recognised
    17:41:00.720 : Loaded 17 macro voice triggers into the speech recogniser
    then when I say "tear off" I get
    Code:
    17:58:53.887 : recognised : tear off confidence = 0.9245504
    17:58:53.895 : Sending actions Tear off
    so it "works" I think, but the visor tear off does not occur in iRacing

    what I've configured in my json file
    Code:
    {
    		    "action": "Tear off",
    			"key": "T"
    		},
    
    .....
    and the macro part
    Code:
    	{
            "name": "Tear off",
            "description": "Presses T",
            "voiceTriggers": [ "tear off" ],
            "commandSets": [
            {
                "description": "iRacing only",
                "gameDefinition": "IRACING",
                "actionSequence": [ "Tear off" ],
                "keyPressTime": 10,
                "waitBetweenEachCommand": 200
            }]
        },
    Last edited by jtfreels; 28-02-2018 at 23:58.

Page 1 of 6 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •