this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #1218 from RobLoach/mousedelay

libretro: Add Mouse Hide Delay option

authored by

Vadim Grigoruk and committed by
GitHub
0d86eba7 d70303c0

+117 -9
+78 -1
src/system/libretro/libretro-common/include/libretro.h
··· 1321 1321 * fallback, stderr). 1322 1322 */ 1323 1323 1324 + #define RETRO_ENVIRONMENT_GET_INPUT_MAX_USERS 61 1325 + /* unsigned * -- 1326 + * Unsigned value is the number of active input devices 1327 + * provided by the frontend. This may change between 1328 + * frames, but will remain constant for the duration 1329 + * of each frame. 1330 + * If callback returns true, a core need not poll any 1331 + * input device with an index greater than or equal to 1332 + * the number of active devices. 1333 + * If callback returns false, the number of active input 1334 + * devices is unknown. In this case, all input devices 1335 + * should be considered active. 1336 + */ 1337 + 1338 + #define RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK 62 1339 + /* const struct retro_audio_buffer_status_callback * -- 1340 + * Lets the core know the occupancy level of the frontend 1341 + * audio buffer. Can be used by a core to attempt frame 1342 + * skipping in order to avoid buffer under-runs. 1343 + * A core may pass NULL to disable buffer status reporting 1344 + * in the frontend. 1345 + */ 1346 + 1347 + #define RETRO_ENVIRONMENT_SET_MINIMUM_AUDIO_LATENCY 63 1348 + /* const unsigned * -- 1349 + * Sets minimum frontend audio latency in milliseconds. 1350 + * Resultant audio latency may be larger than set value, 1351 + * or smaller if a hardware limit is encountered. A frontend 1352 + * is expected to honour requests up to 512 ms. 1353 + * 1354 + * - If value is less than current frontend 1355 + * audio latency, callback has no effect 1356 + * - If value is zero, default frontend audio 1357 + * latency is set 1358 + * 1359 + * May be used by a core to increase audio latency and 1360 + * therefore decrease the probability of buffer under-runs 1361 + * (crackling) when performing 'intensive' operations. 1362 + * A core utilising RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK 1363 + * to implement audio-buffer-based frame skipping may achieve 1364 + * optimal results by setting the audio latency to a 'high' 1365 + * (typically 6x or 8x) integer multiple of the expected 1366 + * frame time. 1367 + * 1368 + * WARNING: This can only be called from within retro_run(). 1369 + * Calling this can require a full reinitialization of audio 1370 + * drivers in the frontend, so it is important to call it very 1371 + * sparingly, and usually only with the users explicit consent. 1372 + * An eventual driver reinitialize will happen so that audio 1373 + * callbacks happening after this call within the same retro_run() 1374 + * call will target the newly initialized driver. 1375 + */ 1376 + 1324 1377 /* VFS functionality */ 1325 1378 1326 1379 /* File paths: ··· 2210 2263 retro_usec_t reference; 2211 2264 }; 2212 2265 2266 + /* Notifies a libretro core of the current occupancy 2267 + * level of the frontend audio buffer. 2268 + * 2269 + * - active: 'true' if audio buffer is currently 2270 + * in use. Will be 'false' if audio is 2271 + * disabled in the frontend 2272 + * 2273 + * - occupancy: Given as a value in the range [0,100], 2274 + * corresponding to the occupancy percentage 2275 + * of the audio buffer 2276 + * 2277 + * - underrun_likely: 'true' if the frontend expects an 2278 + * audio buffer underrun during the 2279 + * next frame (indicates that a core 2280 + * should attempt frame skipping) 2281 + * 2282 + * It will be called right before retro_run() every frame. */ 2283 + typedef void (RETRO_CALLCONV *retro_audio_buffer_status_callback_t)( 2284 + bool active, unsigned occupancy, bool underrun_likely); 2285 + struct retro_audio_buffer_status_callback 2286 + { 2287 + retro_audio_buffer_status_callback_t callback; 2288 + }; 2289 + 2213 2290 /* Pass this to retro_video_refresh_t if rendering to hardware. 2214 2291 * Passing NULL to retro_video_refresh_t is still a frame dupe as normal. 2215 2292 * */ ··· 2658 2735 struct retro_system_info 2659 2736 { 2660 2737 /* All pointers are owned by libretro implementation, and pointers must 2661 - * remain valid until retro_deinit() is called. */ 2738 + * remain valid until it is unloaded. */ 2662 2739 2663 2740 const char *library_name; /* Descriptive name of library. Should not 2664 2741 * contain any version numbers, etc. */
+20
src/system/libretro/libretro_core_options.h
··· 73 73 }, 74 74 0 75 75 }, 76 + { 77 + "tic80_mouse_hide_delay", 78 + "Mouse Cursor Hide Delay", 79 + "The number of seconds to wait before the hiding the mouse.", 80 + { 81 + { "disabled", NULL }, 82 + { "1", NULL }, 83 + { "2", NULL }, 84 + { "3", NULL }, 85 + { "4", NULL }, 86 + { "5", NULL }, 87 + { "6", NULL }, 88 + { "7", NULL }, 89 + { "8", NULL }, 90 + { "9", NULL }, 91 + { "10", NULL }, 92 + { NULL, NULL }, 93 + }, 94 + "5" 95 + }, 76 96 { NULL, NULL, NULL, {{0}}, NULL }, 77 97 }; 78 98
+19 -8
src/system/libretro/tic80_libretro.c
··· 21 21 // The maximum amount of inputs (2, 3 or 4) 22 22 #define TIC_MAXPLAYERS 4 23 23 24 - // How long to wait before hiding the mouse. 25 - // TODO: Move the timer start count to a variable. 26 - #define TIC_LIBRETRO_MOUSE_HIDE_TIMER_START 300 27 - 28 24 static struct retro_log_callback logging; 29 25 static retro_log_printf_t log_cb; 30 26 static retro_video_refresh_t video_cb; ··· 42 38 u8 mouseCursor; 43 39 u16 mousePreviousX; 44 40 u16 mousePreviousY; 45 - u16 mouseHideTimer; 41 + int mouseHideTimer; 42 + int mouseHideTimerStart; 46 43 tic80* tic; 47 44 }; 48 45 static struct tic80_state* state; ··· 115 112 state->mouseCursor = 0; 116 113 state->mousePreviousX = 0; 117 114 state->mousePreviousY = 0; 118 - state->mouseHideTimer = TIC_LIBRETRO_MOUSE_HIDE_TIMER_START; 115 + state->mouseHideTimer = state->mouseHideTimerStart; 119 116 120 117 // Initialize the keyboard mappings. 121 118 state->keymap[RETROK_UNKNOWN] = tic_key_unknown; ··· 498 495 499 496 // Have the mouse disappear after a certain time of inactivity. 500 497 if (mouse->x != state->mousePreviousX || mouse->y != state->mousePreviousY) { 501 - state->mouseHideTimer = TIC_LIBRETRO_MOUSE_HIDE_TIMER_START; 498 + state->mouseHideTimer = state->mouseHideTimerStart; 502 499 state->mousePreviousX = mouse->x; 503 500 state->mousePreviousY = mouse->y; 504 501 } ··· 526 523 void tic80_libretro_mousecursor(tic80_local* game, tic80_mouse* mouse, int cursortype) 527 524 { 528 525 // Only draw the mouse cursor if it's active. 529 - if (state->mouseHideTimer <= 0) { 526 + if (state->mouseHideTimer == 0) { 530 527 return; 531 528 } 532 529 ··· 654 651 } 655 652 else if (strcmp(var.value, "arrow") == 0) { 656 653 state->mouseCursor = 3; 654 + } 655 + } 656 + 657 + // Mouse Hide Delay 658 + state->mouseHideTimerStart = -1; 659 + var.key = "tic80_mouse_hide_delay"; 660 + var.value = NULL; 661 + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { 662 + state->mouseHideTimerStart = atoi(var.value); 663 + if (state->mouseHideTimerStart > 0) { 664 + state->mouseHideTimerStart = state->mouseHideTimerStart * TIC80_FRAMERATE; 665 + } 666 + else { 667 + state->mouseHideTimerStart = -1; 657 668 } 658 669 } 659 670 }