Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Teensy 2.0 USB Keyboard+Mouse in C?

  1. #1
    Junior Member
    Join Date
    Jul 2016
    Posts
    2

    Teensy 2.0 USB Keyboard+Mouse in C?

    Hello, this is likely a duplicate post but I've just spent the last couple hours searching with no luck.

    I'm trying to work the usb_keyboard, usb_mouse, and uart examples into one so that when I plug the teensy in, two devices appear and I can control both over serial from another machine. So far I've gotten the mouse and uart projects merged and can control those just fine. But natrually the mouse/kbd projects don't merge nicely as there is a lot of duplicate code and some conflicts that are unclear (to me) how to sort out. In particular, I don't know enough about USB yet to know how to modify the static data to specify multiple endpoints etc.

    This looks a lot simpler with the teensyduino path but I'm trying to do this using straight C. Is there an example out there somewhere that does mouse+keyboard at the same time for Teensy 2.0? If not, where is the best place to go to learn about how I might understand the USB stuff so that I know what changes are needed? Or if this is answered already can someone please post a link to the other threads?


    Patrick

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,600
    Quote Originally Posted by pmcmorris View Post
    Is there an example out there somewhere that does mouse+keyboard at the same time for Teensy 2.0?
    Yes, it's build into Teensyduino.

    Even if you never intend to really use Arduino, at the very least give it a quick try. Look at the examples in File > Examples > Teensy > USB_Keyboard and USB_Mouse.

    The actual USB code can be found in hardware/teensy/avr/cores/usb_hid. If using a Mac, control-click Ardiuno and "Show Package Contents" to access the folders inside Arduino. You'll see it's a newer version of those old C-only examples. The low-level USB code answers you seek are there in those files.

    But before you dig into all that, why not just quickly run some of those Arduino examples. It's so incredibly easy. Even if you never use Arduino again, having a working sample for comparison might really help?

  3. #3
    Junior Member
    Join Date
    Jul 2016
    Posts
    2
    Much appreciated. I'll try that out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •