| 125 | } |
| 126 | |
| 127 | static void |
| 128 | DrawScreen(SDL_Window *window) |
| 129 | { |
| 130 | SDL_Surface *screen = SDL_GetWindowSurface(window); |
| 131 | int i; |
| 132 | |
| 133 | if (!screen) { |
| 134 | return; |
| 135 | } |
| 136 | |
| 137 | SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 75, 75, 75)); |
| 138 | |
| 139 | /* draw Touch History */ |
| 140 | for (i = eventWrite; i < eventWrite + EVENT_BUF_SIZE; ++i) { |
| 141 | const SDL_Event *event = &events[i & (EVENT_BUF_SIZE - 1)]; |
| 142 | const float age = (float)(i - eventWrite) / EVENT_BUF_SIZE; |
| 143 | float x, y; |
| 144 | unsigned int c, col; |
| 145 | |
| 146 | if ( (event->type == SDL_FINGERMOTION) || |
| 147 | (event->type == SDL_FINGERDOWN) || |
| 148 | (event->type == SDL_FINGERUP) ) { |
| 149 | x = event->tfinger.x; |
| 150 | y = event->tfinger.y; |
| 151 | |
| 152 | /* draw the touch: */ |
| 153 | c = colors[event->tfinger.fingerId % 7]; |
| 154 | col = ((unsigned int) (c * (0.1f + 0.85f))) | (unsigned int) (0xFF * age) << 24; |
| 155 | |
| 156 | if (event->type == SDL_FINGERMOTION) { |
| 157 | drawCircle(screen, x * screen->w, y * screen->h, 5, col); |
| 158 | } else if (event->type == SDL_FINGERDOWN) { |
| 159 | drawCircle(screen, x * screen->w, y * screen->h, -10, col); |
| 160 | } |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | if (knob.p.x > 0) { |
| 165 | drawKnob(screen, &knob); |
| 166 | } |
| 167 | |
| 168 | SDL_UpdateWindowSurface(window); |
| 169 | } |
| 170 | |
| 171 | static void |
| 172 | loop(void) |
no test coverage detected