📬❄️📦Adafruit Holiday Shipping Deadlines 2019: Please place all UPS 3 Day orders by 11am ET Friday December 13 📬❄️📦
0

Configuring NeoTrellis M4 Express as HID Joystick
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Configuring NeoTrellis M4 Express as HID Joystick

by dakinepuaa on Fri Oct 18, 2019 7:56 pm

I have done a lot of work using the Arduino Micro (using the Arduino IDE) as an HID Joystick connected to Windows10 via USB. I have used the ArduinoJoystickLibrary by MHeironimus to implement button consoles for games such as Star Citizen and Elite Dangerous. I was excited so see that statements concerning the NeoTrellis M4 Express asserts, "It comes with a micro-USB connector that is used for power. It also allows you to connect it to a computer and have it detected as a removable disk drive. You can also configure it to act as a generic USB-HID device like a keyboard, mouse, or joystick, or have it act like a MIDI device."

I purchased the M4, configured it for the Arduino IDE and loaded my code but the Joystick Library will not compile. I've stripped my code down to the M4 KeyPad demo and the Joystick Library to zero in on the problem which condenses to a bunch of HID stuff not being present. I've looked for the missing files (USBAPI.h, PluggableUSB.h, and DynamicHID.h) with no success.

Error message,
"Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Adafruit Trellis M4 (SAMD51), Enabled, 120 MHz (standard), Small (-Os) (standard), 50 MHz (standard), Arduino, Off"

Build options changed, rebuilding all
In file included from C:\Users\srcarter\Documents\Arduino\libraries\Joystick\src/Joystick.h:24:0,
from C:\Users\srcarter\Documents\Arduino\My_keypad_test2\My_keypad_test2.ino:2:
C:\Users\srcarter\Documents\Arduino\libraries\Joystick\src/DynamicHID/DynamicHID.h:37:28: fatal error: PluggableUSB.h: No such file or directory
#include "PluggableUSB.h"
^
compilation terminated.
exit status 1
Error compiling for board Adafruit Trellis M4 (SAMD51).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Sample code:
Code: Select all | TOGGLE FULL SIZE
#include "Adafruit_NeoTrellisM4.h"
#include <Joystick.h>
// The NeoTrellisM4 object is a keypad and neopixel strip subclass
// that does things like auto-update the NeoPixels and stuff!
//Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID, JOYSTICK_TYPE_JOYSTICK, 32, 0,
//                   true, true, true, true, true, true,
//                   false, false, false, false, false);

Adafruit_NeoTrellisM4 trellis = Adafruit_NeoTrellisM4();
boolean *lit_keys;

void setup(){
  Serial.begin(115200);
   trellis.begin();
  trellis.setBrightness(80);
  Serial.println("toggle keypad test!");
  lit_keys = new boolean[trellis.num_keys()];
  for (int i=0; i<trellis.num_keys(); i++) {
    lit_keys[i] = false;
  }
}
 
void loop() {
  int key;
  // put your main code here, to run repeatedly:
  trellis.tick();
  while (trellis.available()){
    keypadEvent e = trellis.read();
    if (e.bit.EVENT == KEY_JUST_PRESSED) {
      key = e.bit.KEY;  // shorthand for what was pressed
      Serial.print(key); Serial.println(" pressed");
      lit_keys[key] = !lit_keys[key];
      if (lit_keys[key]) {
        trellis.setPixelColor(key, Wheel(random(255)));
      } else {
        trellis.setPixelColor(key, 0);
      }     
    } else {
      key = e.bit.KEY;
      Serial.print(key); Serial.println(" released");
    }
  }
 
  delay(10);
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return trellis.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return trellis.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return trellis.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

##############################
Any help to get HID Joystick via the Joystick Library on the NeoTrellis M4 Express (8x4 buttons) will be greatly appreciated.
-src
Last edited by franklin97355 on Fri Nov 08, 2019 12:53 pm, edited 1 time in total.
Reason: Added CODE tags. Please use code tags when posting code or logs to the forums. It preserves formatting and makes it easier for everyone to read the code. Click the code button above the reply box and paste your code between the tags created.

dakinepuaa
 
Posts: 5
Joined: Sun Apr 07, 2019 5:40 am

Re: Configuring NeoTrellis M4 Express as HID Joystick

by dakinepuaa on Fri Nov 08, 2019 12:46 pm

The forum has judged me and I am beyond help. Thanks anyway (still no solution). -src

dakinepuaa
 
Posts: 5
Joined: Sun Apr 07, 2019 5:40 am

Re: Configuring NeoTrellis M4 Express as HID Joystick

by franklin97355 on Fri Nov 08, 2019 12:55 pm

Do you have "PluggableUSB.h" installed in your libraries?

franklin97355
 
Posts: 21362
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Configuring NeoTrellis M4 Express as HID Joystick

by dakinepuaa on Fri Nov 08, 2019 11:10 pm

There is not a "pluggableUSB.h" available in the Library Manager. There is a USBBlaster (Installed) and USBMIDI (not installed). These libraries work with the Arduino Micro and I can't find any specific "pluggableUSB" for the SAMD51 (NeoTrellis M4 chip). If I'm missing something please teach me. I'm anxious to learn. -src

dakinepuaa
 
Posts: 5
Joined: Sun Apr 07, 2019 5:40 am

Re: Configuring NeoTrellis M4 Express as HID Joystick

by franklin97355 on Sat Nov 09, 2019 2:25 am

Where did you get the joystick library?

franklin97355
 
Posts: 21362
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Configuring NeoTrellis M4 Express as HID Joystick

by dakinepuaa on Sat Nov 09, 2019 1:58 pm

This is the location. I just checked and it is still there and kicking. Thanks for the help.

https://github.com/MHeironimus/ArduinoJoystickLibrary

dakinepuaa
 
Posts: 5
Joined: Sun Apr 07, 2019 5:40 am

Re: Configuring NeoTrellis M4 Express as HID Joystick

by dakinepuaa on Fri Nov 22, 2019 4:41 pm

Are you still there, franklin97355??

dakinepuaa
 
Posts: 5
Joined: Sun Apr 07, 2019 5:40 am

Please be positive and constructive with your questions and comments.