@@ -151,8 +151,27 @@ static void hid_host_mouse_report_callback(const uint8_t* const data, const int
151151 // Calculate absolute position from displacement
152152 x_pos += mouse_report .x_displacement ;
153153 y_pos += mouse_report .y_displacement ;
154- x_scroll += mouse_report .scroll ;
155- y_scroll += mouse_report .tilt ;
154+
155+ x_scroll += mouse_report .tilt ;
156+ y_scroll += mouse_report .scroll ;
157+
158+ if (mouse_report .x_displacement > 10 ) {
159+ send_navigation_event (BSP_INPUT_NAVIGATION_KEY_RIGHT , 1 , 0 );
160+ } else if (mouse_report .x_displacement < -10 ) {
161+ send_navigation_event (BSP_INPUT_NAVIGATION_KEY_LEFT , 1 , 0 );
162+ }
163+
164+ if (mouse_report .y_displacement > 10 ) {
165+ send_navigation_event (BSP_INPUT_NAVIGATION_KEY_DOWN , 1 , 0 );
166+ } else if (mouse_report .y_displacement < -10 ) {
167+ send_navigation_event (BSP_INPUT_NAVIGATION_KEY_UP , 1 , 0 );
168+ }
169+
170+ if (mouse_report .scroll > 10 ) {
171+ send_navigation_event (BSP_INPUT_NAVIGATION_KEY_PGUP , 1 , 0 );
172+ } else if (mouse_report .scroll < -10 ) {
173+ send_navigation_event (BSP_INPUT_NAVIGATION_KEY_PGDN , 1 , 0 );
174+ }
156175
157176 if (mouse_report .buttons .button1 ) {
158177 send_navigation_event (BSP_INPUT_NAVIGATION_KEY_GAMEPAD_A , 1 , 0 );
@@ -267,6 +286,20 @@ static void hid_host_generic_report_callback(const uint8_t* const data, const in
267286 if (length >= 10 ) {
268287 gamepad_report_t rpt = parse_gamepad_report (data , length );
269288
289+ int lx = ((int )rpt .lx - 128 );
290+ int ly = ((int )rpt .ly - 128 );
291+
292+ if (lx > 50 ) {
293+ send_navigation_event (BSP_INPUT_NAVIGATION_KEY_RIGHT , 1 , 0 );
294+ } else if (lx < -50 ) {
295+ send_navigation_event (BSP_INPUT_NAVIGATION_KEY_LEFT , 1 , 0 );
296+ }
297+ if (ly > 50 ) {
298+ send_navigation_event (BSP_INPUT_NAVIGATION_KEY_UP , 1 , 0 );
299+ } else if (ly < -50 ) {
300+ send_navigation_event (BSP_INPUT_NAVIGATION_KEY_DOWN , 1 , 0 );
301+ }
302+
270303 if (rpt .buttons .up ) {
271304 send_navigation_event (BSP_INPUT_NAVIGATION_KEY_UP , 1 , 0 );
272305 }
0 commit comments