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.

simulator hand icon on button region mouse over

add a hand pointing cursor over the buttons

Change-Id: Idb54e084b5b768de845a94c5bb13e4435d9b82e5

authored by

William Wilgus and committed by
William Wilgus
8884284d fc26ba3f

+88 -11
+70 -2
firmware/target/hosted/sdl/button-sdl.c
··· 69 69 70 70 static int btn = 0; /* Hopefully keeps track of currently pressed keys... */ 71 71 72 + #ifdef SIMULATOR 73 + static bool cursor_isfocus = false; 74 + SDL_Cursor *sdl_focus_cursor = NULL; 75 + SDL_Cursor *sdl_arrow_cursor = NULL; 76 + #endif 77 + 72 78 int sdl_app_has_input_focus = 1; 79 + 73 80 #if (CONFIG_PLATFORM & PLATFORM_MAEMO) 74 81 static int n900_updown_key_pressed = 0; 75 82 #endif ··· 254 261 last_tick = current_tick; 255 262 #endif 256 263 } 264 + #ifdef SIMULATOR 265 + if (event->window.event == SDL_WINDOWEVENT_FOCUS_LOST 266 + || event->window.event == SDL_WINDOWEVENT_LEAVE 267 + || event->window.event == SDL_WINDOWEVENT_RESIZED 268 + || event->window.event == SDL_WINDOWEVENT_FOCUS_LOST) 269 + { 270 + if (cursor_isfocus) 271 + { 272 + cursor_isfocus = false; 273 + SDL_SetCursor(sdl_arrow_cursor); 274 + } 275 + } 276 + #endif 257 277 break; 258 278 case SDL_KEYDOWN: 259 279 case SDL_KEYUP: ··· 282 302 #endif 283 303 button_event(ev_key, event->type == SDL_KEYDOWN); 284 304 break; 285 - #ifdef HAVE_TOUCHSCREEN 305 + 306 + 307 + 286 308 case SDL_MOUSEMOTION: 309 + { 310 + #ifdef SIMULATOR 311 + static uint32_t next_check = 0; 312 + if (background && sdl_app_has_input_focus 313 + && (TIME_AFTER(event->motion.timestamp, next_check))) 314 + { 315 + int x = event->motion.x; 316 + int y = event->motion.y; 317 + 318 + extern struct button_map bm[]; 319 + int i; 320 + for (i = 0; bm[i].button; i++) 321 + { 322 + int xd = (x-bm[i].x)*(x-bm[i].x); 323 + int yd = (y-bm[i].y)*(y-bm[i].y); 324 + /* check distance from center of button < radius */ 325 + if ( xd + yd < bm[i].radius*bm[i].radius ) { 326 + break; 327 + } 328 + } 329 + 330 + if (bm[i].button) 331 + { 332 + if (!cursor_isfocus) 333 + { 334 + cursor_isfocus = true; 335 + SDL_SetCursor(sdl_focus_cursor); 336 + } 337 + } 338 + else if (cursor_isfocus) 339 + { 340 + cursor_isfocus = false; 341 + SDL_SetCursor(sdl_arrow_cursor); 342 + } 343 + 344 + next_check = event->motion.timestamp + 10; /* ms */ 345 + } 346 + #endif 347 + #ifdef HAVE_TOUCHSCREEN 287 348 if (event->motion.state & SDL_BUTTON(1)) 288 349 { 289 350 int x = event->motion.x; 290 351 int y = event->motion.y; 291 352 touchscreen_event(x, y); 292 353 } 293 - break; 294 354 #endif 355 + break; 295 356 357 + } 296 358 case SDL_MOUSEBUTTONUP: 297 359 case SDL_MOUSEBUTTONDOWN: 298 360 { ··· 560 622 561 623 void button_init_device(void) 562 624 { 625 + #ifdef SIMULATOR 626 + if (!sdl_focus_cursor) 627 + sdl_focus_cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND); 628 + if (!sdl_arrow_cursor) 629 + sdl_arrow_cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); 630 + #endif 563 631 }
+9
firmware/target/hosted/sdl/system-sdl.c
··· 177 177 178 178 void sim_do_exit() 179 179 { 180 + #ifdef SIMULATOR 181 + extern SDL_Cursor *sdl_focus_cursor; 182 + extern SDL_Cursor *sdl_arrow_cursor; 183 + if (sdl_focus_cursor) 184 + SDL_FreeCursor(sdl_focus_cursor); 185 + if (sdl_arrow_cursor) 186 + SDL_FreeCursor(sdl_arrow_cursor); 187 + #endif 188 + 180 189 sim_kernel_shutdown(); 181 190 SDL_UnlockMutex(window_mutex); 182 191 SDL_DestroyMutex(window_mutex);
+9 -9
firmware/target/hosted/sdl/window-sdl.c
··· 35 35 36 36 SDL_mutex *window_mutex; 37 37 38 - static SDL_Window *window; 38 + SDL_Window *sdlWindow; 39 39 static SDL_Renderer *sdlRenderer; 40 40 static SDL_Surface *picture_surface; 41 41 ··· 74 74 int original_height = h; 75 75 int original_width = w; 76 76 77 - if ((SDL_GetWindowFlags(window) & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN)) 77 + if ((SDL_GetWindowFlags(sdlWindow) & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN)) 78 78 || display_zoom) 79 79 return; 80 80 81 - SDL_GetWindowSize(window, &w, &h); 81 + SDL_GetWindowSize(sdlWindow, &w, &h); 82 82 if (w != original_width || h != original_height) 83 83 { 84 84 if (abs(original_width - w) < SNAP_MARGIN) ··· 89 89 else 90 90 h = w * aspect_ratio; 91 91 92 - SDL_SetWindowSize(window, w, h); 92 + SDL_SetWindowSize(sdlWindow, w, h); 93 93 } 94 94 } 95 95 ··· 104 104 0, 0, 0, 0), SDL_TEXTUREACCESS_STREAMING, w, h)) == NULL) 105 105 panicf("%s", SDL_GetError()); 106 106 107 - if (SDL_GetWindowFlags(window) & SDL_WINDOW_RESIZABLE) 107 + if (SDL_GetWindowFlags(sdlWindow) & SDL_WINDOW_RESIZABLE) 108 108 restore_aspect_ratio(w, h); 109 109 110 110 if (background && picture_surface && ··· 153 153 154 154 get_window_dimensions(&w, &h); 155 155 156 - if (!(SDL_GetWindowFlags(window) & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN)) 156 + if (!(SDL_GetWindowFlags(sdlWindow) & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN)) 157 157 && display_zoom) 158 158 { 159 - SDL_SetWindowSize(window, display_zoom * w, display_zoom * h); 159 + SDL_SetWindowSize(sdlWindow, display_zoom * w, display_zoom * h); 160 160 } 161 161 #if defined(__APPLE__) || defined(__WIN32) 162 162 restore_aspect_ratio(w, h); ··· 200 200 201 201 get_window_dimensions(&width, &height); 202 202 203 - if ((window = SDL_CreateWindow(UI_TITLE, SDL_WINDOWPOS_CENTERED, 203 + if ((sdlWindow = SDL_CreateWindow(UI_TITLE, SDL_WINDOWPOS_CENTERED, 204 204 SDL_WINDOWPOS_CENTERED, width * display_zoom, 205 205 height * display_zoom , flags)) == NULL) 206 206 panicf("%s", SDL_GetError()); 207 - if ((sdlRenderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC)) == NULL) 207 + if ((sdlRenderer = SDL_CreateRenderer(sdlWindow, -1, SDL_RENDERER_PRESENTVSYNC)) == NULL) 208 208 panicf("%s", SDL_GetError()); 209 209 210 210 /* Surface for LCD content only. Needs to fit largest LCD */