Browse Source

test mouse clicks with BOOTSEL button

Thomas Buck 1 year ago
parent
commit
cc5f528358
1 changed files with 25 additions and 22 deletions
  1. 25
    22
      firmware/src/usb_hid.c

+ 25
- 22
firmware/src/usb_hid.c View File

58
         case REPORT_ID_MOUSE:
58
         case REPORT_ID_MOUSE:
59
         {
59
         {
60
             struct pmw_motion mouse = pmw_get();
60
             struct pmw_motion mouse = pmw_get();
61
+            uint8_t buttons = 0x00;
62
+            if (btn) {
63
+                buttons |= MOUSE_BUTTON_LEFT;
64
+            }
61
             if (mouse.motion) {
65
             if (mouse.motion) {
62
-                tud_hid_mouse_report(REPORT_ID_MOUSE, 0x00,
66
+                tud_hid_mouse_report(REPORT_ID_MOUSE, buttons,
63
                         mouse.delta_x * (INVERT_MOUSE_X_AXIS ? -1 : 1),
67
                         mouse.delta_x * (INVERT_MOUSE_X_AXIS ? -1 : 1),
64
                         mouse.delta_y * (INVERT_MOUSE_Y_AXIS ? -1 : 1),
68
                         mouse.delta_y * (INVERT_MOUSE_Y_AXIS ? -1 : 1),
65
                         0, 0);
69
                         0, 0);
70
         case REPORT_ID_CONSUMER_CONTROL:
74
         case REPORT_ID_CONSUMER_CONTROL:
71
         {
75
         {
72
             // use to avoid send multiple consecutive zero report
76
             // use to avoid send multiple consecutive zero report
73
-            static bool has_consumer_key = false;
77
+            //static bool has_consumer_key = false;
74
 
78
 
75
             if (btn) {
79
             if (btn) {
76
                 // volume down
80
                 // volume down
77
-                uint16_t volume_down = HID_USAGE_CONSUMER_VOLUME_DECREMENT;
78
-                tud_hid_report(REPORT_ID_CONSUMER_CONTROL, &volume_down, 2);
79
-                has_consumer_key = true;
81
+                //uint16_t volume_down = HID_USAGE_CONSUMER_VOLUME_DECREMENT;
82
+                //tud_hid_report(REPORT_ID_CONSUMER_CONTROL, &volume_down, 2);
83
+                //has_consumer_key = true;
80
             } else {
84
             } else {
81
                 // send empty key report (release key) if previously has key pressed
85
                 // send empty key report (release key) if previously has key pressed
82
-                uint16_t empty_key = 0;
83
-                if (has_consumer_key) tud_hid_report(REPORT_ID_CONSUMER_CONTROL, &empty_key, 2);
84
-                has_consumer_key = false;
86
+                //uint16_t empty_key = 0;
87
+                //if (has_consumer_key) tud_hid_report(REPORT_ID_CONSUMER_CONTROL, &empty_key, 2);
88
+                //has_consumer_key = false;
85
             }
89
             }
86
         }
90
         }
87
         break;
91
         break;
89
         case REPORT_ID_GAMEPAD:
93
         case REPORT_ID_GAMEPAD:
90
         {
94
         {
91
             // use to avoid send multiple consecutive zero report for keyboard
95
             // use to avoid send multiple consecutive zero report for keyboard
92
-            static bool has_gamepad_key = false;
96
+            //static bool has_gamepad_key = false;
93
 
97
 
94
-            hid_gamepad_report_t report = {
95
-                .x   = 0, .y = 0, .z = 0, .rz = 0, .rx = 0, .ry = 0,
96
-                .hat = 0, .buttons = 0
97
-            };
98
+            //hid_gamepad_report_t report = {
99
+            //    .x   = 0, .y = 0, .z = 0, .rz = 0, .rx = 0, .ry = 0,
100
+            //    .hat = 0, .buttons = 0
101
+            //};
98
 
102
 
99
             if (btn) {
103
             if (btn) {
100
-                report.hat = GAMEPAD_HAT_UP;
101
-                report.buttons = GAMEPAD_BUTTON_A;
102
-                tud_hid_report(REPORT_ID_GAMEPAD, &report, sizeof(report));
103
-
104
-                has_gamepad_key = true;
104
+                //report.hat = GAMEPAD_HAT_UP;
105
+                //report.buttons = GAMEPAD_BUTTON_A;
106
+                //tud_hid_report(REPORT_ID_GAMEPAD, &report, sizeof(report));
107
+                //has_gamepad_key = true;
105
             } else {
108
             } else {
106
-                report.hat = GAMEPAD_HAT_CENTERED;
107
-                report.buttons = 0;
108
-                if (has_gamepad_key) tud_hid_report(REPORT_ID_GAMEPAD, &report, sizeof(report));
109
-                has_gamepad_key = false;
109
+                //report.hat = GAMEPAD_HAT_CENTERED;
110
+                //report.buttons = 0;
111
+                //if (has_gamepad_key) tud_hid_report(REPORT_ID_GAMEPAD, &report, sizeof(report));
112
+                //has_gamepad_key = false;
110
             }
113
             }
111
         }
114
         }
112
         break;
115
         break;

Loading…
Cancel
Save