Forum Rule: Always post complete source code & details to reproduce any issue!
Page 9 of 9 FirstFirst ... 7 8 9
Results 201 to 207 of 207

Thread: Many axis joystick

  1. #201
    Quote Originally Posted by Marco67 View Post
    I appropriately modified the usb_desc.c.
    Thanks for sharing the solution!

  2. #202
    Senior Member
    Join Date
    Mar 2015
    Posts
    159
    Where is the correct usb_desc.c to be modified located??

    Teensy 4.0 Teensyuino 1.53, I can delete it from Teensy4 and Teensy3 folders and makes no difference, nor the changes I do on them.

  3. #203
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    9,214
    I think this is the same question you asked in the usb descriptor fun thread...

    If building for Teensy 4.x you use the files in cores\teensy4

    If you delete the files I doubt it will build

    The joystick stuff again depends on how you build the system and what the USB type is set to.

    And again for joysticks. if you change the HID format in usb_desc.c (and .h) then you must also update the code that generates and sends the data.
    which is in same core directory (usb_joystick.h and .c)

    And if you change the actual size of the data (number of bytes) you will need to generate a new section in there as the code is setup like:
    #if JOYSTICK_SIZE == 12
    #elif JOYSTICK_SIZE == 64

    And make sure you stuff the raw data into the right bits of the right bytes

    Again this size needs to match the actual size of your data...

  4. #204
    Senior Member
    Join Date
    Mar 2015
    Posts
    159
    "If building for Teensy 4.x you use the files in cores\teensy4"

    The problem is exactly that I can delete usb_desc.c from the teensy4 directory and it builds (and joystick works). The usb_desc.h on the same directory can not be deleted and the edits on that are effective.

  5. #205
    Senior Member
    Join Date
    Mar 2015
    Posts
    159
    Here is a video the usb_desc.c has been renamed usb_desc_d.c there is no usb_desc.c

    The joystick name has been edited on the usb_desc.h that is on the same directory, so the directory should be correct.

    https://vimeo.com/555199322



    So the question is, where should I edit the stuff that is on usb_desc.c so that it is effective?
    Last edited by Garug; 05-26-2021 at 01:45 PM.

  6. #206
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    9,214
    Note renaming a usb_desc.c to usb_desc_d.c

    Makes 0 differences to the build. You could call it foo.c and it would still build. The build system will compile every .c .cpp file within that directory.

    If you actually setup your system to do verbose builds, you would see that it built usb_desc_d.c and as such satisfied any external references needed.

  7. #207
    Senior Member
    Join Date
    Mar 2015
    Posts
    159
    I do not understand. That is very strange, but seems to be the case. I removed the file form the directory, and still compiles just fine.

    But after restarting Arduino environment does not compile any more, so clearly it notice now that the file is missing.


    But this is also pretty frustrating, do I always need to restart the Arduino environment after changing the usb_desc.c?

    and also the problem maybe was that I did a usb_desc_copy.c before editing the usb_desc.c and left it on the same directory, so maybe it used that instead of the usb_desc.c... This does not feel smart. Really, is it not caring about the file names at all, but good to know, I could not have figured that out without help, thanks Kurt.

    verbose build, what is that and why is it not default.

    And hey, it worked. actually what I edited before provided the wanted result, only 10 buttons shown

    Click image for larger version. 

Name:	Screenshot 2021-05-26 at 17.24.46.jpg 
Views:	14 
Size:	77.2 KB 
ID:	24915

    Code:
    #if JOYSTICK_SIZE == 12
    static uint8_t joystick_report_desc[] = {
    
            0x05, 0x01,                     // Usage Page (Generic Desktop)
            0x09, 0x04,                     // Usage (Joystick)
            0xA1, 0x01,                     // Collection (Application)
    
            0x05, 0x09,                     //   Usage Page (Button)
            0x19, 0x01,                     //   Usage Minimum (Button #1)
            0x29, 0x0A,                     //   Usage Maximum (Button #32) was 0x20, reduced to 10 buttons 0x0A
            0x15, 0x00,                     //   Logical Minimum (0)
            0x25, 0x01,                     //   Logical Maximum (1)
            0x75, 0x01,                     //   Report Size (1)
            0x95, 0x0A,                     //   Report Count (32) was 0x20, reduced to 10 buttons 0x0A
    
    
    
            0x81, 0x02,                     //   Input (variable,absolute)
    
            0x75, 0x01,                     //   Report Size (1)
            0x95, 0x16,                     //   Report Count (22) to fill the original 32 buttons
            0x81, 0x01,                     //   Constant
    
    
            0x15, 0x00,                     //   Logical Minimum (0)
            0x25, 0x07,                     //   Logical Maximum (7)
            0x35, 0x00,                     //   Physical Minimum (0)
            0x46, 0x3B, 0x01,               //   Physical Maximum (315)
            0x75, 0x04,                     //   Report Size (4)
            0x95, 0x01,                     //   Report Count (1)
            0x65, 0x14,                     //   Unit (20)
    
            0x05, 0x01,                     //   Usage Page (Generic Desktop)
            0x09, 0x39,                     //   Usage (Hat switch)
            0x81, 0x42,                     //   Input (variable,absolute,null_state)
    
            0x05, 0x01,                     //   Usage Page (Generic Desktop)
            0x09, 0x01,                     //   Usage (Pointer)
            0xA1, 0x00,                     //   Collection ()
            0x15, 0x00,                     //     Logical Minimum (0)
            0x26, 0xFF, 0x03,               //     Logical Maximum (1023)
            0x75, 0x0A,                     //     Report Size (10)
            0x95, 0x04,                     //     Report Count (4)
            0x09, 0x30,                     //     Usage (X)
            0x09, 0x31,                     //     Usage (Y)
            0x09, 0x32,                     //     Usage (Z)
            0x09, 0x35,                     //     Usage (Rz)
            0x81, 0x02,                     //     Input (variable,absolute)
            0xC0,                           //   End Collection
            0x15, 0x00,                     //   Logical Minimum (0)
            0x26, 0xFF, 0x03,               //   Logical Maximum (1023)
            0x75, 0x0A,                     //   Report Size (10)
            0x95, 0x02,                     //   Report Count (2)
            0x09, 0x36,                     //   Usage (Slider)
            0x09, 0x36,                     //   Usage (Slider)
            0x81, 0x02,                     //   Input (variable,absolute)
            0xC0                            // End Collection
    
    
    };
    Last edited by Garug; 05-26-2021 at 02:26 PM.

Posting Permissions

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