Arduino Giga R1 with joystick, how to setup game controler hid

Hi, i'm new.
I want to "Create a sophisticated game controllers", as it's written here :

USB HID

"
It is possible to turn your GIGA R1 board into a Human Interface Device (HID), aka mouse & keyboard, using the USBHID library which is included in the GIGA core.
Among other things, you can:

  • Create a custom keyboard, or a keyboard accessory,
  • Create sophisticated game controllers,
  • Accessories for VR/AR applications.
    "
    so i put a joystick on it, upload a small code, and it's ok, i see the values moving when i move the joystick.

Now, how can i see it like a game controler hid to play with it on PC (windows 10 64bit) ?
And what does' it mean : usbhid "library which is included in the GIGA core" ?

Thanks for your help

how do you will know if you already has one?

Hi kolaha, i don't anderstand your question...
I need to know how i can use it as a game controler, it's only working in Arduino IDE, not in game in windows.
Thanks

Hi @giga-build

"USBHID" is a "platform bundled library". This type of library is distributed as part of an Arduino boards platform (AKA "core"). This means that when you install or update a boards platform via the Arduino IDE "Boards Manager", you also install or update the "platform bundled libraries" of that boards platform. This is different from the standalone libraries we usually install and update via the Arduino IDE "Library Manager".

The "platform bundled libraries" of a boards platform are only accessible when compiling for a board of that platform. It is common for multiple boards platforms to each bundle their own variant of a given fundamental library. Typically this is done when the implementation of a library is very architecture-specific, meaning it is not feasible to make a single universal library that can be used with any Arduino board. Because each of the variants of the library use a standardized API, the same sketch code using the library can be used on boards of different architectures. The user is often not even aware that a different library variant is being used from one board to the next.

Thank you ptillisch.
Do you have an idie about making work it as a HID game controler ?
I see nothing about that. Maybe it's too soon...

Martino Facchin, one of the developers of the library, shared some information here:

There's no gamepad or joystick support with current code. It's used in many applications and I am wondering it's under development or if it's in your plans to be added.

there's no plan right now but the infrastructure is there https://github.com/arduino/ArduinoCore-mbed/tree/master/libraries/USBHID , so HID based libraries can be added very easily (you can check this working library for a very rough but functional Joystick)

So Arduino doesn't have any plans to provide a library for creating game controllers and you should not wait for Arduino to do it for you. The community can build such a library on the "USBHID" library. Martino produced such a library:

I'll provide instructions you can follow to install that library:

  1. Click the following link to open the library's GitHub repository:
    https://github.com/facchinm/USBJoystick
  2. Click the "<> Code ▾" button.
  3. Select Download ZIP from the menu.
  4. Wait for the download to finish.
  5. Select Sketch > Include library > Add .ZIP Library from the Arduino IDE menus.
  6. Select the downloaded file (USBJoystick-master.zip).
  7. Click the Open button.
  8. Wait for Arduino IDE to show a "Successfully installed library ... notification.

You can now use the library in your sketch by adding this line:

#include "USBJoystick.h"

Unfortunately there aren't any examples or formal documentation included with the "USBJoystick" library, but you can study the information in the USBJoystick.h to learn the API provided by the library:

https://github.com/facchinm/USBJoystick/blob/master/USBJoystick.h

There are even a couple of example programs in the comments of that file. Unfortunately they are in the form of C++ programs rather than traditional Arduino sketches. You can extrapolate an Arduino sketch from them though. For example, this example program from the comments:

#include "mbed.h"
#include "USBJoystick.h"

USBJoystick joystick;

int main(void)
{
  while (1)
  {
     joystick.move(20, 0);
     wait(0.5);
  }
}

Would look something like this as a traditional Arduino sketch:

#include <USBJoystick.h>

USBJoystick joystick;

void setup() {}
void loop()
{
  joystick.move(20, 0);
  delay(500);
}

I just did a simple test of that sketch running on my Giga using the Windows game controller test utility and it looks like it does work as expected:

Thank you ptillisch ! I try it.
It's working, i need now to find the good values... And convert : -127 untill + 128 to 0 untill 1023... a mistery for me, i learn a lot.

You are welcome. I'm glad if I was able to be of assistance.

Best wishes for success with your project!
Per

A post was split to a new topic: Help me port Arduino Micro joystick emulation project to GIGA