| 771 | } |
| 772 | |
| 773 | void onMouseMove(U32 x, U32 y, bool relative) { |
| 774 | U32 send = 0; |
| 775 | U64 time = KSystem::getSystemTimeAsMicroSeconds(); |
| 776 | |
| 777 | if (relative) { |
| 778 | if (mouseEvents) { |
| 779 | BOXEDWINE_CRITICAL_SECTION_WITH_CONDITION(mouseEvents->bufferCond); |
| 780 | if (x) { |
| 781 | queueEvent(mouseEvents, K_EV_REL, K_REL_X, x, time); |
| 782 | send = 1; |
| 783 | } |
| 784 | if (y) { |
| 785 | queueEvent(mouseEvents, K_EV_REL, K_REL_Y, y, time); |
| 786 | send = 1; |
| 787 | } |
| 788 | if (send) { |
| 789 | postSendEvent(mouseEvents, time); |
| 790 | BOXEDWINE_CONDITION_SIGNAL_ALL(mouseEvents->bufferCond); |
| 791 | } |
| 792 | } |
| 793 | } |
| 794 | else { |
| 795 | if (touchEvents) { |
| 796 | BOXEDWINE_CRITICAL_SECTION_WITH_CONDITION(touchEvents->bufferCond); |
| 797 | // :TODO this is a huge hack, for some reason xorg only picks up the first event so |
| 798 | // to make the mouse mostly smooth, just alternate which axis is first in the queue |
| 799 | static int count = 0; |
| 800 | count++; |
| 801 | if (count % 2 == 0) { |
| 802 | if (x != touchEvents->lastX) { |
| 803 | queueEvent(touchEvents, K_EV_ABS, K_ABS_X, x, time); |
| 804 | touchEvents->lastX = x; |
| 805 | send = 1; |
| 806 | } |
| 807 | if (y != touchEvents->lastY) { |
| 808 | queueEvent(touchEvents, K_EV_ABS, K_ABS_Y, y, time); |
| 809 | touchEvents->lastY = y; |
| 810 | send = 1; |
| 811 | } |
| 812 | } else { |
| 813 | if (y != touchEvents->lastY) { |
| 814 | queueEvent(touchEvents, K_EV_ABS, K_ABS_Y, y, time); |
| 815 | touchEvents->lastY = y; |
| 816 | send = 1; |
| 817 | } |
| 818 | if (x != touchEvents->lastX) { |
| 819 | queueEvent(touchEvents, K_EV_ABS, K_ABS_X, x, time); |
| 820 | touchEvents->lastX = x; |
| 821 | send = 1; |
| 822 | } |
| 823 | } |
| 824 | if (send) { |
| 825 | postSendEvent(touchEvents, time); |
| 826 | BOXEDWINE_CONDITION_SIGNAL_ALL(touchEvents->bufferCond); |
| 827 | } |
| 828 | } |
| 829 | } |
| 830 | } |
no test coverage detected