Advertisement
Guest User

Untitled

a guest
Dec 24th, 2022
4,879
3
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.99 KB | None | 3 0
  1. // This code makes your Arduino act as a 3DConnexion SpaceMouse (32u4-based board required).
  2. // To make this work you also need to set the USB Vendor ID and Product ID to values matching a real 3DConnexion device.
  3. // You can do this by editing appropriate entries in the boards.txt file in your Arduino installation.
  4. // Example values: vid=0x256f, pid=0xc631 (SpaceMouse Pro Wireless (cabled))
  5. // Then install the 3DxWare software from 3DConnexion on your computer and you can use you Arduino device in software like Fusion 360 as it it were a real SpaceMouse.
  6.  
  7. #include "HID.h"
  8.  
  9. static const uint8_t _hidReportDescriptor[] PROGMEM = {
  10.   0x05, 0x01,           //  Usage Page (Generic Desktop)
  11.   0x09, 0x08,           //  0x08: Usage (Multi-Axis)
  12.   0xa1, 0x01,           //  Collection (Application)
  13.   0xa1, 0x00,           // Collection (Physical)
  14.   0x85, 0x01,           //  Report ID
  15.   0x16, 0x00, 0x80,     //logical minimum (-500)
  16.   0x26, 0xff, 0x7f,     //logical maximum (500)
  17.   0x36, 0x00, 0x80,     //Physical Minimum (-32768)
  18.   0x46, 0xff, 0x7f,     //Physical Maximum (32767)
  19.   0x09, 0x30,           //    Usage (X)
  20.   0x09, 0x31,           //    Usage (Y)
  21.   0x09, 0x32,           //    Usage (Z)
  22.   0x75, 0x10,           //    Report Size (16)
  23.   0x95, 0x03,           //    Report Count (3)
  24.   0x81, 0x02,           //    Input (variable,absolute)
  25.   0xC0,                 //  End Collection
  26.   0xa1, 0x00,           // Collection (Physical)
  27.   0x85, 0x02,           //  Report ID
  28.   0x16, 0x00, 0x80,     //logical minimum (-500)
  29.   0x26, 0xff, 0x7f,     //logical maximum (500)
  30.   0x36, 0x00, 0x80,     //Physical Minimum (-32768)
  31.   0x46, 0xff, 0x7f,     //Physical Maximum (32767)
  32.   0x09, 0x33,           //    Usage (RX)
  33.   0x09, 0x34,           //    Usage (RY)
  34.   0x09, 0x35,           //    Usage (RZ)
  35.   0x75, 0x10,           //    Report Size (16)
  36.   0x95, 0x03,           //    Report Count (3)
  37.   0x81, 0x02,           //    Input (variable,absolute)
  38.   0xC0,                 //  End Collection
  39.  
  40.   0xa1, 0x00,           // Collection (Physical)
  41.   0x85, 0x03,           //  Report ID
  42.   0x15, 0x00,           //   Logical Minimum (0)
  43.   0x25, 0x01,           //    Logical Maximum (1)
  44.   0x75, 0x01,           //    Report Size (1)
  45.   0x95, 32,             //    Report Count (24)
  46.   0x05, 0x09,           //    Usage Page (Button)
  47.   0x19, 1,              //    Usage Minimum (Button #1)
  48.   0x29, 32,             //    Usage Maximum (Button #24)
  49.   0x81, 0x02,           //    Input (variable,absolute)
  50.   0xC0,
  51.   0xC0
  52. };
  53.  
  54. void setup() {
  55.   static HIDSubDescriptor node(_hidReportDescriptor, sizeof(_hidReportDescriptor));
  56.   HID().AppendDescriptor(&node);
  57. }
  58.  
  59. void send_command(int16_t rx, int16_t ry, int16_t rz, int16_t x, int16_t y, int16_t z) {
  60.   uint8_t trans[6] = { x & 0xFF, x >> 8, y & 0xFF, y >> 8, z & 0xFF, z >> 8 };
  61.   HID().SendReport(1, trans, 6);
  62.   uint8_t rot[6] = { rx & 0xFF, rx >> 8, ry & 0xFF, ry >> 8, rz & 0xFF, rz >> 8 };
  63.   HID().SendReport(2, rot, 6);
  64. }
  65.  
  66. void loop() {
  67.  
  68. }
Advertisement
Comments
  • Gissmo50
    326 days
    # text 0.14 KB | 0 0
    1. i think im missing something with this i can get the 3dconnexion software to register the arduino as a space mouse pro but not control anything
Add Comment
Please, Sign In to add comment
Advertisement