Modify USB profile to remove serial port - just want keyboard

I'm trying to do a deployment where my device is just a USB Keyboard using the Keyboard library. I can't install any drivers on the destination computer. How can I disable the serial port and mouse and have it just detect the keyboard? I've been playing around in the /arduino/hardware/arduino/cores/arduino section but don't know enough about USB to know what I'm doing.

What Arduino are you using?

...R

You can only use the keyboard libary on the Micro and the Lenardo all the others are fixed with serial.

Sorry, I should have been more clear. This is with an Atmega32u4 (Leonardo). I am using the Keyboard function, but I need for it to only enumerate as a keyboard. Normally the bootloader enumerates a keyboard, mouse, and serial port, and calls the serial port an Arduino Lenoardo. I need for it to just appear to be a keyboard only. I'm using an AVRISPMKII as a hardware programmer, so I don't necessarily need the bootloader, but I do need to be able to do a USB keyboard.

Have a look at the snippets in this message: Leonardo doesn't talk to serial monitor in windows 7 - #8 by PeterVH - Installation & Troubleshooting - Arduino Forum. It is about leaving out the hid device and keeping only serial. You want to do the opposite, but that is a similar task.

If this is for use with windows, you'll also need to create a .inf file that instructs windows to use the generic hid driver when it sees your usb 'product'. It is best to use a product id different from the leonardo's, such that windows can handle correctly both a standard serial+hid leonardo and your customized one. (note you can use arduino's vendor id only for personal use, experimentation).
On linux this is all transparent, it will pick the right driver based on the usb class info your firmware exposes.

Normally the bootloader enumerates a keyboard, mouse, and serial port,

Actually the bootloader exposes serial port only, it is the sketch that is started afterwards that exposes serial + hid.

Thanks for the link. The application is an installation on computers where I don't have administrative rights. We're only being allowed to plug in a USB keyboard (think devices where credit card PCI compliance is important), so it has to appear as a USB Keyboard and we can't install anything on the computer it's being installed in. That means no additional .inf files, and no serial ports.

I did manage to find a solution, based in part on the link you provided. Posting it here for posterity. The example sketch of USB > KeyboardMessage is sufficient to test (You can just remove the button part and have it delay every loop, too):

  1. Go to C:\Program Files\Arduino\hardware\arduino\cores\arduino (or the appropriate location on your mac or whatever).
  2. Open USBDesc.h
  3. Comment out line 19. It should read:
    //#define CDC_ENABLED //REMOVED BY BOB TO ALLOW ONLY USB KEYBOARD
    
  4. On line 46 and 47, comment out the junk in the Define and replace with 1. They should read:
    #define HID_INTERFACE 1//(CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT) //CHANGED TO 1 BY BOB TO ALLOW ONLY USB KEYBOARD
    #define HID_FIRST_ENDPOINT 1//(CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT //CHANGED TO 1 BY BOB TO ALLOW ONLY USB KEYBOARD
    
  5. Save and close.

Once you have made these changes to the USBDesc.h file, you can open the IDE and upload any sketch using an external programmer.

Note that this will affect ANY sketches you upload from this computer, so be aware of that. From now on, the USB of any Leonardo board is going to be forced to be a USB keyboard.

I tried this and it didn't work for me. I was using IDE v1.6.9.

I have an application where I need to simulate mouse movement (over 5 pixels and back 5 pixels).

In this application, I don't want the Arduino serial device showing in device manager or /dev/ttyACM0 showing on a linux machine either.

I only want the Arduino Micro to show as an HID Mouse and that's all. How can I achieve this?

Here's my sketch:

#include <HID.h>
#include <Mouse.h>

void setup() {
Mouse.begin();
}

void loop() {
// move the mouse:
Mouse.move(5, 5, 0);
delay(120000);
Mouse.move(-5, -5, 0);
delay(30000);
}

I do not care about reprogrammability once the sketch is written. I need to disable the arduino from enumerating as a serial device (along with the HID Mouse) Needs to be HID Mouse only. Is there a way to do this? The teensy 2.0 can do this, but the Arduino Pro Micro is a fraction of the price of the teensy 2.0

Help please.

bobbaddeley:
I did manage to find a solution, based in part on the link you provided. Posting it here for posterity.

Hello! Can you tell me, which version of IDE you are using? I have 1.8.0 IDE, and USBDesc.h has different content.

Thanks!

I also am looking for information about this. I’m using the MIDIUSB library to make a midi device, which works great, but it seems to require a driver on Windows. Does anyone have any more/new information about how to have it enumerate as only a MIDI device? Also, if this can be accomplished, can it still be reflashed from the IDE, or will the IDE no longer be able to see it? Many thanks for the help!

how can i get numlock's code if im use Keyboard.h?