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

Thread: Teensy 3.0 : RAW HID + Keyboard

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    2

    Question Teensy 3.0 : RAW HID + Keyboard

    Hi!

    I bought a Teensy 3.0 and I would like to use it in mode "RAW HID + Keyboard".
    Indeed, the RAW HID mode is used in my program to make a communication between the Teensy and the computer. Then I want to print some keystrokes on the computer depending on the data of the communication.

    Unfortunately, we can't configure the Teensy in this mode with Teensyduino.

    I have seen this post : http://forum.pjrc.com/threads/18658-...stom-USB-types. I tried to modify the files as explained but it would not work.

    I tried to modify usb_desc and usb_inst.cpp as described but I guess I have to recompile it if I want to make the update on teensyduino. Any ideas of what is going wrong?

    Thank you very much in advance!

  2. #2
    Senior Member
    Join Date
    Mar 2013
    Posts
    126
    Please post some code and/or a more detailed description of what would not work.
    It is hard to help otherwise.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,563
    Quote Originally Posted by Frisk0 View Post
    I tried to modify usb_desc and usb_inst.cpp as described but I guess I have to recompile it if I want to make the update on teensyduino.
    The files are automatically recompiled when you upload.

    For more visibility about how Arduino is compiling, turn on verbose info while compiling, from File > Preferences.

    Any ideas of what is going wrong?
    Do you really believe anyone could guess what went wrong from only "I tried to modify the files as explained but it would not work"?!

  4. #4
    Junior Member
    Join Date
    Jun 2013
    Posts
    2
    Thank both of you to reply to my message. I'm sorry for not having put the code right away.

    In usb_desc.h, I have copied information from keyboard in the RAW_HID mode :

    Code:
    #elif defined(USB_RAWHID)
      #define VENDOR_ID		0x16C0
      #define PRODUCT_ID		0x0486
      #define RAWHID_USAGE_PAGE	0xFFAB  // recommended: 0xFF00 to 0xFFFF
      #define RAWHID_USAGE		0x0200  // recommended: 0x0100 to 0xFFFF
      #define MANUFACTURER_NAME	{'T','e','e','n','s','y','d','u','i','n','o'}
      #define MANUFACTURER_NAME_LEN	11
      #define PRODUCT_NAME		{'T','e','e','n','s','y','d','u','i','n','o',' ','R','a','w','H','I','D'}
      #define PRODUCT_NAME_LEN	18
      #define EP0_SIZE		64
      #define NUM_ENDPOINTS         6
      #define NUM_USB_BUFFERS	12
      #define NUM_INTERFACE		2
      #define RAWHID_INTERFACE      0	// RawHID
      #define RAWHID_TX_ENDPOINT    3
      #define RAWHID_TX_SIZE        64
      #define RAWHID_TX_INTERVAL    1
      #define RAWHID_RX_ENDPOINT    4
      #define RAWHID_RX_SIZE        64
      #define RAWHID_RX_INTERVAL    1
      #define SEREMU_INTERFACE      1	// Serial emulation
      #define SEREMU_TX_ENDPOINT    1
      #define SEREMU_TX_SIZE        64
      #define SEREMU_TX_INTERVAL    1
      #define SEREMU_RX_ENDPOINT    2
      #define SEREMU_RX_SIZE        32
      #define SEREMU_RX_INTERVAL    2
    
      // The lines I've added to make the Keyboard work in raw_hid
      #define KEYBOARD_INTERFACE    2	// Keyboard
      #define KEYBOARD_ENDPOINT     1
      #define KEYBOARD_SIZE         8
      #define KEYBOARD_INTERVAL     1  
      #define KEYBOARD_DESC_OFFSET	(9 + 9) 
      // End of lines
    
      #define RAWHID_DESC_OFFSET	(9 + 9)
      #define SEREMU_DESC_OFFSET	(9 + 9+9+7+7 + 9)
      #define CONFIG_DESC_SIZE	(9 + 9+9+7+7 + 9+9+7+7)
      #define ENDPOINT1_CONFIG	ENDPOINT_TRANSIMIT_ONLY
      #define ENDPOINT2_CONFIG	ENDPOINT_RECEIVE_ONLY
      #define ENDPOINT3_CONFIG	ENDPOINT_TRANSIMIT_ONLY
      #define ENDPOINT4_CONFIG	ENDPOINT_RECEIVE_ONLY
    In usb_inst.cpp, I've added the usb_keyboard_class Keyboard

    Code:
    #ifdef USB_RAWHID
    usb_keyboard_class Keyboard;
    usb_rawhid_class RawHID;
    usb_seremu_class Serial;
    #endif
    With this modifications, I set the Teensy in Raw_HID mode in Teensyduino. However when I want to compile a line such as :

    Code:
    Keyboard.print("Hello World!");
    I have this error : 'Keyboard' was not declared in this scope

    Once again, thank you for taking the time to reply to me.

  5. #5
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    273
    For the solution see this thread Adding a new USB type courtesy of lhagan

Tags for this Thread

Posting Permissions

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