Procházet zdrojové kódy

refractor, add wheel for mouse demo

hathach před 12 roky
rodič
revize
c4fef827b1
3 změnil soubory, kde provedl 14 přidání a 10 odebrání
  1. 8 3
      demos/host/src/mouse_app.c
  2. 3 4
      demos/host/src/msc_app.c
  3. 3 3
      tinyusb/class/hid.h

+ 8 - 3
demos/host/src/mouse_app.c

@@ -143,12 +143,17 @@ static inline void process_mouse_report(tusb_mouse_report_t const * p_report)
   {
   {
      // example only display button pressed, ignore hold & dragging etc
      // example only display button pressed, ignore hold & dragging etc
     printf(" %c%c%c ",
     printf(" %c%c%c ",
-       p_report->buttons & HID_MOUSEBUTTON_LEFT   ? 'L' : '-',
-       p_report->buttons & HID_MOUSEBUTTON_MIDDLE ? 'M' : '-',
-       p_report->buttons & HID_MOUSEBUTTON_RIGHT  ? 'R' : '-');
+       p_report->buttons & MOUSE_BUTTON_LEFT   ? 'L' : '-',
+       p_report->buttons & MOUSE_BUTTON_MIDDLE ? 'M' : '-',
+       p_report->buttons & MOUSE_BUTTON_RIGHT  ? 'R' : '-');
   }
   }
 
 
   //------------- movement (disabled for clearer demo) -------------//
   //------------- movement (disabled for clearer demo) -------------//
+  if ( p_report->wheel != 0 )
+  {
+    printf(" %c ", p_report->wheel > 0 ? 'U' : 'D');
+  }
+
 //  if ( p_report->x != 0 || p_report->y != 0 )
 //  if ( p_report->x != 0 || p_report->y != 0 )
 //  {
 //  {
 //    printf(" (%d, %d) ", p_report->x, p_report->y);
 //    printf(" (%d, %d) ", p_report->x, p_report->y);

+ 3 - 4
demos/host/src/msc_app.c

@@ -66,18 +66,17 @@ void tusbh_msc_mounted_cb(uint8_t dev_addr)
   uint8_t const* p_vendor  = tusbh_msc_get_vendor_name(dev_addr);
   uint8_t const* p_vendor  = tusbh_msc_get_vendor_name(dev_addr);
   uint8_t const* p_product = tusbh_msc_get_product_name(dev_addr);
   uint8_t const* p_product = tusbh_msc_get_product_name(dev_addr);
 
 
-  printf("Vendor  Name: ");
+  printf("Name: ");
   for(uint8_t i=0; i<8; i++) putchar(p_vendor[i]);
   for(uint8_t i=0; i<8; i++) putchar(p_vendor[i]);
-  putchar('\n');
 
 
-  printf("Product Name: ");
+  printf(" ");
   for(uint8_t i=0; i<16; i++) putchar(p_product[i]);
   for(uint8_t i=0; i<16; i++) putchar(p_product[i]);
   putchar('\n');
   putchar('\n');
 
 
   uint32_t last_lba, block_size;
   uint32_t last_lba, block_size;
   tusbh_msc_get_capacity(dev_addr, &last_lba, &block_size);
   tusbh_msc_get_capacity(dev_addr, &last_lba, &block_size);
   printf("Disk Size: %d MB\n", (last_lba+1)/ ((1024*1024)/block_size) );
   printf("Disk Size: %d MB\n", (last_lba+1)/ ((1024*1024)/block_size) );
-  printf("LBA 0-0x%X, Block Size: %d\n", last_lba, block_size);
+  printf("LBA 0-0x%X  Block Size: %d\n", last_lba, block_size);
 }
 }
 
 
 //--------------------------------------------------------------------+
 //--------------------------------------------------------------------+

+ 3 - 3
tinyusb/class/hid.h

@@ -125,9 +125,9 @@ typedef ATTR_PACKED_STRUCT(struct)
  * \brief buttons codes for HID mouse
  * \brief buttons codes for HID mouse
  */
  */
 enum {
 enum {
-	HID_MOUSEBUTTON_LEFT   = BIT_(0),
-	HID_MOUSEBUTTON_RIGHT  = BIT_(1),
-	HID_MOUSEBUTTON_MIDDLE = BIT_(2)
+	MOUSE_BUTTON_LEFT   = BIT_(0),
+	MOUSE_BUTTON_RIGHT  = BIT_(1),
+	MOUSE_BUTTON_MIDDLE = BIT_(2)
 };
 };
 
 
 /**
 /**