1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice
Like RaceDepartment on Facebook.

Arduino for keyboard macros...WIP

Discussion in 'F1 2016 - The Game' started by Booth.the.doberman, Oct 12, 2016.

  1. I have a G27. There aren't enough keys accessible on the wheel. There also is no way to build macros to achieve a specific function. For example, say I want to be able to press one button and have the pit boss tell me the time on my last lap.

    Last week, I ordered and received a Teensy Arduino board. With it, I can respond to up to 25 switches and I can program each switch to do whatever I want. For example, I can press the Key1 button and have it send one or numerous keyboard scan codes to F2 2016 (F1 2016, as you have discovered from looking at the action map xml file, responds to key scan codes and virtual scan codes only...you can't send it an ascii sequence).

    Let's say I want my last last time. Right now, I have to press the Talk button and then the MFD button several times and then the down button several times and then the right button to ask the question. I don't know about you, but I'm in the weeds by the time I do all that. With the Teensy, I can program a button to automatically press the Talk Button, press the MFD button twice, press the Down button three times and press the Right button once. One keypress for something I want to know every lap.

    Maybe I'm the only one who cares about a feature like this, but just in case I'm not, I believe I have found a way you can accomplish this. I have tested this on a breadboard and it functions . I am building a prototype this week with 21 buttons that will be located on the wheel. This doesn't include the six G27 buttons, which I find hard to find often without looking.

    I guess I'd like to make this a community project if anyone else is interested. It's not an expensive project. The Teensy is about $25 USD. Besides that you need buttons, and those are relatively inexpensive (about $1 each) and a soldering iron and solder and a plan to mount them to the wheel.

    What the heck? I'll post updates as I make progress and maybe this should be moved to the mods section.
     
  2. fortyfivekev

    fortyfivekev
    Premium Member

    I have made a couple of Arduino based button boxes and apart from needing some patience to solder all the wires they are straightforward. I used an Arduino Leonardo just because they emulate a HID device directly but Teensies are just as good. Mounting a load of buttons to your wheel though would need some kind of mounting plate that you have to buy/make plus you have to deal with cable issues if you are wanting to have the buttons on the actual wheel itself F1 style. Personally I think button boxes are a lot easier especially if you have a rig to permanently mount them to.
     
  3. I've finished this project and it works very well. As my original post said, I wanted more buttons on the wheel and I wanted them to be programmable so I wouldn't have to use the MFD and take my eyes of the road. I've built button boxes using cannibalized numeric keypad controller boards, but I found they were worse than the MFD because they are positioned even further from your field of view.

    So, here's the rundown. I used a piece of 3/8 acrylic from the hardware store to build a plate that can be attached to the wheel. Most of the plates I have seen require you to remove the entire wheel, but I had one mail goal-- do no physical modifications to the wheel itself (so it could be returned to pristine condition if so desired). So I removed the six screws from the Logitech hub and pulled that off. I then made a large "washer" out of spare acrylic and used that to anchor the wheel to the assembly. That "washer" also had a bolt coming out of it and I glued a nut onto the backside of the Logitech hub. The plate is installed on the outside of the washer and the Logitech hub is then screwed on to anchor the plate.

    I used some normally open pushbuttons and mounted them into the plate. To reduce the amount of wire to connect all these switches, I used adhesive-backed copper foil to basically construct a circuit board on the backside of the plate. The controller is a Teensy, that can provide control of more than two dozen buttons. I settled on 21 buttons.

    Programming the Teensy with the Arduino IDE is a very simple matter. You basically tell it that when a specific button is pressed, which keys should be sent to the Directx/DirectInput listener built into F1 2016. For example, I have one button that will ask the pit boss for my last lap time. When I press that button, it sends the Talk button, then the MFD button twice, then the Down button twice and finally the Right button once.

    I previously had suggested a free application called G-Hotkey, but the Teensy works much better and doesn't have the limitations G-Hotkey has (limited number of macros).

    The biggest problem I have that I am not able to resolve yet is having the Teensy know which screen it is on in the MFD. If you're on the first screen and you want to change brake bias forward, you need to go down and then right. But if you're not on the first screen, you need to do something different to get there...you have to first get back to the first MFD screen and then do the Down-Right. If you're in the Tire Wear screen, for example, Down-Right takes you to Fuel Rich. If there were a way to turn off the MFD, that would solve the problem. But there isn't one I know of, so I'm stuck trying to figure out something else. I thought I could set a flag when the MFD button is first pressed to bring up the MFD, but I've noticed the MFD sometimes closes by itself or opens by itself (when you hit something, for example).

    If I resolve that or someone has a way of knowing which MFD screen is currently displayed, I'll post an update. If anyone is interested in anything else, let me know.
     
  4. fortyfivekev

    fortyfivekev
    Premium Member

    Pictures?
     
  5. Okay, here are some photos.
    Plate1 is the center hub. This is made from 3/16 acrylic and holds the wheel onto the rest of the wheel body. It uses the original bolts. This piece has a bolt that is epoxied to it sticking out toward the driver.

    plate-1.jpg

    Plate2 is the plate off-wheel. It, too, is made from 3/16 acrylic and covered with a peel and stick covering made for automobile enhancements.

    plate-2.jpg

    Plate3 is the plate on the wheel. The Logitech hub/cover has a nut glued to the inside and that screws onto the bolt shown in Plate1 to hold the plate onto the wheel. If I want to removed the plate, I simply unscrew the Logitech hub, take off the plate and screw the Logitech cover back on.

    plate-3.jpg

    Programming explanation. First I have to go into the game settings and define keyboard keys for the things I want to be able to do. Pressing the A key activates DRS, M activates MFD, T does Talk and the up/down/left/right buttons around talk are set up as MFD Up, MFD Down, etc.

    In the Teensy programming, when the button marked DNS is pressed, it sends the A keycode to the game, which activates DRS. MFD and Talk work likewise as do the MFD Up/Down/Left/Right buttons. The Bias, Diff and Fuel Buttons are macros. Pressing Fuel + sets the fuel to rich, by doing a MFD Right-MFD Right in the first screen of the MFD window. Pressing Fuel = does MFD Right-MFD Right-MFD Left for standard mix. Bias and Diff work similarly. Pressing the upper Bias button sends a MFD Down-MFD Right-MFD Up. Pressing upper Diff does MFD Down-MFD Down-MFD Right-MFD Up-MFD Up. Each macro goes back up the same number of times as it went down so the selector is always at the top of the first MFD screen. The Time macro sends Talk-MFD-MFD-Down-Down-Right to get to the Last Lap Time question for the pit boss. The six buttons in the lower left haven't been programmed yet. I was going to use them for TIres, Fix Wing and Downforce adjust but I'm just not sure I'll use those features much, especially since now I'm only running 25% races.

    Since the Teensy is easily programmable, I could also have one key act as a Shift key, which could double the number of buttons. For example, Shift MFD could become the Talk button and Shift DRS could become the KERS button (for F1 2013).

    I should note that the original six G27 buttons are still available for use. I use them for Look Left, Look Right, etc.

    That's all I have to report.
     
    Last edited by a moderator: Nov 9, 2016
    • Like Like x 2
  6. fortyfivekev

    fortyfivekev
    Premium Member

    Looks great, very neat job. Where did you buy the acrylic?
     
  7. lowes
     
    • Like Like x 1
  8. I have another photo that I noticed I forgot to post. This is the backside of the board. I used copper foil with conductive adhesive, but I decided to solder the joints because I found I didn't always get a good contact. I also directly soldered the USB cable to the Teensy controller since the micro usb is known as a fragile part and can tear off the board easily. The Teensy is not soldered in...it's in a socket so I can remove it if necessary. I'm going to run it for a while with the copper foil exposed to see if anything breaks. If it works for a week or so, I'm going to coat the backside for protection. I'm kind of thinking about making it bluetooth....[​IMG]
     
    • Like Like x 1
  9. fortyfivekev

    fortyfivekev
    Premium Member

    Bluetooth and a small battery pack and you could drop the cable which would be neat. There are quite a few small boards around now that could emulate a HID device over Bluetooth.
     
  10. The exact one I need is at Adafruit, but it's out of stock. Of course, I don't know if F1 2016 works with a bluetooth keyboard. I'd assume it does, but you never know. I forgot about the battery.
     
  11. fortyfivekev

    fortyfivekev
    Premium Member

    My missus has a SteelSeries bluetooth controller which would work really well although I don't think she would be too happy with me if I dismantled it for parts. :)
     
  12. Graham Laing

    Graham Laing
    ...... mostly harmless Staff

    @Booth.the.doberman

    I've edited your post above so that the 3 images are attached to and displayed within your post. It makes it more readable than just linking to an image host.

    Cheers :thumbsup: