#include "CursorTask.h" #include #include #include #include #include void CursorTask::logic() { if(!show) return; touchpad_report_t touchpad; touchpad_scan(&touchpad); state = touchpad_arrow_pressed(TPAD_ARROW_CLICK); int dx = 0, dy = 0; static bool tp_last_contact = touchpad.contact; if(touchpad.contact && !touchpad.pressed) { static int tp_last_x = touchpad.x; static int tp_last_y = touchpad.y; if(tp_last_contact) { dx = (touchpad.x - tp_last_x) / 10; dy = (tp_last_y - touchpad.y) / 10; } tp_last_x = touchpad.x; tp_last_y = touchpad.y; tp_last_contact = touchpad.contact; } else { tp_last_contact = false; } x = std::max({0, dx + x}); y = std::max({0, dy + y}); x = std::min({x, SCREEN_WIDTH}); y = std::min({y, SCREEN_HEIGHT}); } void CursorTask::render( SDL_Surface *screen ) { if(!show) return; //Draw the simple mouse cursor filledTrigonRGBA( screen, x, y, x+5, y+10, x+10, y+5, 255, 255, 255, 255); trigonRGBA( screen, x, y, x+5, y+10, x+10, y+5, 255, 0, 0, 255); }