1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  3. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  4. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

Question Can an Arduino used as a game controller receive inputs from simtools?

Discussion in 'SimTools compatible interfaces' started by RiftFlyer, Nov 8, 2018.

  1. RiftFlyer

    RiftFlyer Active Member Gold Contributor

    Joined:
    Apr 15, 2014
    Messages:
    198
    Balance:
    1,711Coins
    Ratings:
    +121 / 0 / -0
    My Motion Simulator:
    DC motor
    I have started planning a little side project for a sim peripheral and it will need to be seen as a game controller in windows. I’ll be using a teensey 2 board but could change that to a larger Arduino if need be. Once recognized as a game controller in windows can simtools (Game Dash specifically) still communicate with the board? I’m not much of a programmer so not sure if I need to run a second usb and board for the game output.
  2. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,656Coins
    Ratings:
    +1,839 / 32 / -1
    I think you mean once configured as a game controller in windows can it also still be a serial com device. I don't believe it can but I don't have hands on experience.
    • Agree Agree x 1
    Last edited: Nov 8, 2018
  3. RiftFlyer

    RiftFlyer Active Member Gold Contributor

    Joined:
    Apr 15, 2014
    Messages:
    198
    Balance:
    1,711Coins
    Ratings:
    +121 / 0 / -0
    My Motion Simulator:
    DC motor
    Ok that’ll make things trickier. Thanks for the reply. As an alternative i’ll look into using two arduinos connected to the same switch circuit. One to act as a usb game controller and the second for serial communication with Game Dash.
  4. RiftFlyer

    RiftFlyer Active Member Gold Contributor

    Joined:
    Apr 15, 2014
    Messages:
    198
    Balance:
    1,711Coins
    Ratings:
    +121 / 0 / -0
    My Motion Simulator:
    DC motor
    I’ve decided to use an Arduino Leonardo as the game controller board and an Uno as the game dash board. I’ll use i2c for communication between them. I think I have the protocol and syntax worked out. Thanks again.
  5. RiftFlyer

    RiftFlyer Active Member Gold Contributor

    Joined:
    Apr 15, 2014
    Messages:
    198
    Balance:
    1,711Coins
    Ratings:
    +121 / 0 / -0
    My Motion Simulator:
    DC motor
    Guys I've started coding the game controller (slave) board. It is essentially a button box with six buttons. Before getting into the i2c part of the code I am trying to test using an LED output.

    The LED output needs to go high if any of the six buttons are pressed. Currently I am only getting the LED to light if the button on pin 10 is pressed. The other buttons just cause the LED to flicker once when the button state changes! All six buttons are working in windows game controller properties screen. Could someone take a look at my code and tell me if they can spot where I've gone wrong?

    Code:
    #include <Joystick.h>
    //declare joystick
    Joystick_ Joystick;
    const int ledPin = 15;
    const int pinToButtonMap = 5;
    // Last state of the button
    int lastButtonState[6] = {0,0,0,0,0,0};
    void setup() {
      // put your setup code here, to run once:
      pinMode(5, INPUT_PULLUP);
      pinMode(6, INPUT_PULLUP);
      pinMode(7, INPUT_PULLUP);
      pinMode(8, INPUT_PULLUP);
      pinMode(9, INPUT_PULLUP);
      pinMode(10, INPUT_PULLUP);
      pinMode(ledPin, OUTPUT);
      // Initialize Joystick Library
      Joystick.begin();
    }
    
    void loop()
    {
      // put your main code here, to run repeatedly:
    for (int index = 0; index < 6; index++)
      {
        int currentButtonState = !digitalRead(index + pinToButtonMap);
           if (currentButtonState == HIGH){
        digitalWrite(ledPin, HIGH);}
        else{
          digitalWrite(ledPin,LOW);}
       if (currentButtonState != lastButtonState[index]){
          Joystick.setButton(index, currentButtonState);
          lastButtonState[index] = currentButtonState;}
      }
      delay(50);
    }
    Last edited: Nov 27, 2018
  6. RiftFlyer

    RiftFlyer Active Member Gold Contributor

    Joined:
    Apr 15, 2014
    Messages:
    198
    Balance:
    1,711Coins
    Ratings:
    +121 / 0 / -0
    My Motion Simulator:
    DC motor
    disregard guys. I figured it out. Phase one complete. Now I need to look at i2c and start work on the master board which will communicate with game dash
    • Like Like x 1