diff --git a/AircraftList.cpp b/AircraftList.cpp index e94cf0b..547dba0 100644 --- a/AircraftList.cpp +++ b/AircraftList.cpp @@ -4,7 +4,7 @@ static uint64_t mstime(void) { struct timeval tv; uint64_t mst; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); mst = ((uint64_t)tv.tv_sec)*1000; mst += tv.tv_usec/1000; return mst; @@ -17,7 +17,7 @@ Aircraft *AircraftList::find(uint32_t addr) { if (p->addr == addr) return (p); p = p->next; } - return (NULL); + return (nullptr); } //instead of this, net_io should call this class directly to update info @@ -90,7 +90,7 @@ void AircraftList::update(Modes *modes) { } p = head; - Aircraft *prev = NULL; + Aircraft *prev = nullptr; while(p) { if(!p->live) { @@ -111,11 +111,11 @@ void AircraftList::update(Modes *modes) { } AircraftList::AircraftList() { - head = NULL; + head = nullptr; } AircraftList::~AircraftList() { - while(head != NULL) { + while(head != nullptr) { Aircraft *temp = head; head = head->next; delete(temp); diff --git a/Input.cpp b/Input.cpp index b743154..f5496d6 100644 --- a/Input.cpp +++ b/Input.cpp @@ -59,20 +59,26 @@ void Input::getInput() } break; - case SDL_FINGERMOTION:; - touchDownTime = 0; + case SDL_FINGERMOTION:; + if(mstime() - touchDownTime > 150) { + tapCount = 0; + touchDownTime = 0; + } view->moveCenterRelative( view->screen_width * event.tfinger.dx, view->screen_height * event.tfinger.dy); break; case SDL_FINGERDOWN: if(mstime() - touchDownTime > 500) { tapCount = 0; + } + + if(SDL_GetNumTouchFingers(event.tfinger.touchId) == 0) { + touchDownTime = mstime(); } - touchDownTime = mstime(); break; case SDL_FINGERUP: - if(mstime() - touchDownTime < 120) { + if(mstime() - touchDownTime < 150 && SDL_GetNumTouchFingers(event.tfinger.touchId) == 0) { touchx = view->screen_width * event.tfinger.x; touchy = view->screen_height * event.tfinger.y; tapCount++; diff --git a/Makefile b/Makefile index 9cd3687..37ad1f8 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # sure that the variable PREFIX is defined, e.g. make PREFIX=/usr/local # -CFLAGS=-O2 -g -Wall -W +CFLAGS=-O2 -g -Wno-write-strings LIBS=-lm -lSDL2 -lSDL2_ttf -lSDL2_gfx CC=g++ diff --git a/View.cpp b/View.cpp index b34ddf2..8701742 100644 --- a/View.cpp +++ b/View.cpp @@ -1094,33 +1094,13 @@ void View::drawPlanes() { usex = x + (mstime() - p->msSeenLatLon) * velx; usey = y + (mstime() - p->msSeenLatLon) * vely; } - - if(p == selectedAircraft) { - // this logic should be in input, register a callback for click? - float elapsed = mstime() - clickTime; - - int boxSize; - if(elapsed < 300) { - boxSize = (int)(20.0 * (1.0 - (1.0 - elapsed / 300.0) * cos(sqrt(elapsed)))); - } else { - boxSize = 20; - } - //rectangleRGBA(renderer, usex - boxSize, usey - boxSize, usex + boxSize, usey + boxSize, pink.r, pink.g, pink.b, 255); - lineRGBA(renderer, usex - boxSize, usey - boxSize, usex - boxSize/2, usey - boxSize, pink.r, pink.g, pink.b, 255); - lineRGBA(renderer, usex - boxSize, usey - boxSize, usex - boxSize, usey - boxSize/2, pink.r, pink.g, pink.b, 255); - - lineRGBA(renderer, usex + boxSize, usey - boxSize, usex + boxSize/2, usey - boxSize, pink.r, pink.g, pink.b, 255); - lineRGBA(renderer, usex + boxSize, usey - boxSize, usex + boxSize, usey - boxSize/2, pink.r, pink.g, pink.b, 255); - - lineRGBA(renderer, usex + boxSize, usey + boxSize, usex + boxSize/2, usey + boxSize, pink.r, pink.g, pink.b, 255); - lineRGBA(renderer, usex + boxSize, usey + boxSize, usex + boxSize, usey + boxSize/2, pink.r, pink.g, pink.b, 255); - - lineRGBA(renderer, usex - boxSize, usey + boxSize, usex - boxSize/2, usey + boxSize, pink.r, pink.g, pink.b, 255); - lineRGBA(renderer, usex - boxSize, usey + boxSize, usex - boxSize, usey + boxSize/2, pink.r, pink.g, pink.b, 255); - } planeColor = lerpColor(style.planeColor, style.planeGoneColor, (now - p->seen) / (float) DISPLAY_ACTIVE); + if(p == selectedAircraft) { + planeColor = style.selectedColor; + } + if(outOfBounds(x,y)) { drawPlaneOffMap(x, y, &(p->cx), &(p->cy), planeColor); } else { @@ -1261,6 +1241,31 @@ void View::drawClick() { filledCircleRGBA(renderer, clickx, clicky, radius, white.r, white.g, white.b, alpha); } + + + if(selectedAircraft) { + // this logic should be in input, register a callback for click? + float elapsed = mstime() - clickTime; + + int boxSize; + if(elapsed < 300) { + boxSize = (int)(20.0 * (1.0 - (1.0 - elapsed / 300.0) * cos(sqrt(elapsed)))); + } else { + boxSize = 20; + } + //rectangleRGBA(renderer, selectedAircraft->cx - boxSize, selectedAircraft->cy - boxSize, selectedAircraft->cx + boxSize, selectedAircraft->cy + boxSize, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255); + lineRGBA(renderer, selectedAircraft->cx - boxSize, selectedAircraft->cy - boxSize, selectedAircraft->cx - boxSize/2, selectedAircraft->cy - boxSize, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255); + lineRGBA(renderer, selectedAircraft->cx - boxSize, selectedAircraft->cy - boxSize, selectedAircraft->cx - boxSize, selectedAircraft->cy - boxSize/2, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255); + + lineRGBA(renderer, selectedAircraft->cx + boxSize, selectedAircraft->cy - boxSize, selectedAircraft->cx + boxSize/2, selectedAircraft->cy - boxSize, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255); + lineRGBA(renderer, selectedAircraft->cx + boxSize, selectedAircraft->cy - boxSize, selectedAircraft->cx + boxSize, selectedAircraft->cy - boxSize/2, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255); + + lineRGBA(renderer, selectedAircraft->cx + boxSize, selectedAircraft->cy + boxSize, selectedAircraft->cx + boxSize/2, selectedAircraft->cy + boxSize, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255); + lineRGBA(renderer, selectedAircraft->cx + boxSize, selectedAircraft->cy + boxSize, selectedAircraft->cx + boxSize, selectedAircraft->cy + boxSize/2, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255); + + lineRGBA(renderer, selectedAircraft->cx - boxSize, selectedAircraft->cy + boxSize, selectedAircraft->cx - boxSize/2, selectedAircraft->cy + boxSize, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255); + lineRGBA(renderer, selectedAircraft->cx - boxSize, selectedAircraft->cy + boxSize, selectedAircraft->cx - boxSize, selectedAircraft->cy + boxSize/2, style.selectedColor.r, style.selectedColor.g, pink.b, 255); + } } void View::registerClick(int tapcount, int x, int y) { @@ -1297,8 +1302,7 @@ void View::registerClick(int tapcount, int x, int y) { } void View::registerMouseMove(int x, int y) { - lastFrameTime = mstime(); - + mouseMovedTime = mstime(); this->mousex = x; this->mousey = y; } @@ -1345,6 +1349,7 @@ void View::draw() { drawPlanes(); drawStatus(); drawMouse(); + drawClick(); char fps[13] = " "; snprintf(fps,13," %.1ffps", 1000.0 / (mstime() - lastFrameTime)); diff --git a/map1090.REMOVED.git-id b/map1090.REMOVED.git-id index b383a41..fe74180 100644 --- a/map1090.REMOVED.git-id +++ b/map1090.REMOVED.git-id @@ -1 +1 @@ -884676a0069dc93832d407eea2d3e612de57d44a \ No newline at end of file +85bf9e07a831ad5a30abf7ae4737f9c8a543f9e2 \ No newline at end of file