Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

puzzles: polish mouse mode

Reduces lag when dragging. Also throws some comments in.

Change-Id: Ibd0d95e94200ae6de8258ce8d2e001c931161385

+28 -25
+28 -25
apps/plugins/puzzles/rockbox.c
··· 1585 1585 * following code is needed for mouse mode. */ 1586 1586 if(mouse_mode) 1587 1587 { 1588 + static int last_mousedir = 0, held_count = 0, v = 1; 1589 + 1588 1590 if(button & BTN_UP) 1589 1591 state = CURSOR_UP; 1590 1592 else if(button & BTN_DOWN) ··· 1599 1601 1600 1602 last_keystate = button; 1601 1603 1604 + /* move */ 1605 + /* get the direction vector the cursor is moving in. */ 1606 + int new_x = mouse_x, new_y = mouse_y; 1607 + 1608 + /* in src/misc.c */ 1609 + move_cursor(state, &new_x, &new_y, LCD_WIDTH, LCD_HEIGHT, FALSE); 1610 + 1611 + int dx = new_x - mouse_x, dy = new_y - mouse_y; 1612 + 1613 + mouse_x += dx * v; 1614 + mouse_y += dy * v; 1615 + 1616 + /* clamp */ 1617 + /* The % operator with negative operands is messy; this is much 1618 + * simpler. */ 1619 + if(mouse_x < 0) 1620 + mouse_x = 0; 1621 + if(mouse_y < 0) 1622 + mouse_y = 0; 1623 + 1624 + if(mouse_x >= LCD_WIDTH) 1625 + mouse_x = LCD_WIDTH - 1; 1626 + if(mouse_y >= LCD_HEIGHT) 1627 + mouse_y = LCD_HEIGHT - 1; 1628 + 1629 + /* clicking/dragging */ 1602 1630 /* rclick on hold requires that we fire left-click on a 1603 1631 * release, otherwise it's impossible to distinguish the 1604 1632 * two. */ ··· 1620 1648 send_click(LEFT_DRAG, false); 1621 1649 } 1622 1650 1623 - static int last_mousedir = 0, held_count = 0, v = 0; 1624 - 1625 1651 /* acceleration */ 1626 1652 if(state && state == last_mousedir) 1627 1653 { ··· 1639 1665 v = 1; 1640 1666 held_count = 0; 1641 1667 } 1642 - 1643 - /* get the direction vector the cursor is moving in. */ 1644 - int new_x = mouse_x, new_y = mouse_y; 1645 - 1646 - /* in src/misc.c */ 1647 - move_cursor(state, &new_x, &new_y, LCD_WIDTH, LCD_HEIGHT, FALSE); 1648 - 1649 - int dx = new_x - mouse_x, dy = new_y - mouse_y; 1650 - 1651 - mouse_x += dx * v; 1652 - mouse_y += dy * v; 1653 - 1654 - /* The % operator with negative operands is messy; this is much 1655 - * simpler. */ 1656 - if(mouse_x < 0) 1657 - mouse_x = 0; 1658 - if(mouse_y < 0) 1659 - mouse_y = 0; 1660 - 1661 - if(mouse_x >= LCD_WIDTH) 1662 - mouse_x = LCD_WIDTH - 1; 1663 - if(mouse_y >= LCD_HEIGHT) 1664 - mouse_y = LCD_HEIGHT - 1; 1665 1668 1666 1669 /* no buttons are sent to the midend in mouse mode */ 1667 1670 return 0;