|
21 | 21 | #include <string/stdstring.h> |
22 | 22 | #include <retro_math.h> |
23 | 23 | #include <retro_timers.h> |
| 24 | +#include <time/rtime.h> |
24 | 25 |
|
25 | 26 | #ifdef HAVE_CONFIG_H |
26 | 27 | #include "../config.h" |
@@ -3299,6 +3300,7 @@ void video_driver_build_info(video_frame_info_t *video_info) |
3299 | 3300 | video_info->memory_show = settings->bools.video_memory_show; |
3300 | 3301 | video_info->statistics_show = settings->bools.video_statistics_show; |
3301 | 3302 | video_info->framecount_show = settings->bools.video_framecount_show; |
| 3303 | + video_info->time_show = settings->uints.video_time_show; |
3302 | 3304 | video_info->core_status_msg_show = runloop_st->core_status_msg.set; |
3303 | 3305 | video_info->aspect_ratio_idx = settings->uints.video_aspect_ratio_idx; |
3304 | 3306 | video_info->post_filter_record = settings->bools.video_post_filter_record; |
@@ -4130,7 +4132,7 @@ bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled) |
4130 | 4132 | void video_driver_frame(const void *data, unsigned width, |
4131 | 4133 | unsigned height, size_t pitch) |
4132 | 4134 | { |
4133 | | - char status_text[128]; |
| 4135 | + char status_text[256]; |
4134 | 4136 | static char video_driver_msg[256]; |
4135 | 4137 | static retro_time_t last_time; |
4136 | 4138 | static retro_time_t curr_time; |
@@ -4465,6 +4467,62 @@ void video_driver_frame(const void *data, unsigned width, |
4465 | 4467 | RUNLOOP_MSG_QUEUE_UNLOCK(runloop_st); |
4466 | 4468 | } |
4467 | 4469 |
|
| 4470 | + if (video_info.time_show) |
| 4471 | + { |
| 4472 | + static char time_text[64]; |
| 4473 | + static retro_time_t next_time_update; |
| 4474 | + static unsigned time_show_last_format; |
| 4475 | + time_t time_; |
| 4476 | + |
| 4477 | + _len = strlen(status_text); |
| 4478 | + |
| 4479 | + if (_len > 0) |
| 4480 | + { |
| 4481 | + status_text[ _len] = ' '; |
| 4482 | + status_text[++_len] = '|'; |
| 4483 | + status_text[++_len] = '|'; |
| 4484 | + status_text[++_len] = ' '; |
| 4485 | + status_text[++_len] = '\0'; |
| 4486 | + } |
| 4487 | + |
| 4488 | + if ( !next_time_update |
| 4489 | + || (new_time >= next_time_update) |
| 4490 | + || video_info.time_show != time_show_last_format) |
| 4491 | + { |
| 4492 | + struct tm tm_; |
| 4493 | + retro_time_t time_update_interval = 0; |
| 4494 | + |
| 4495 | + time(&time_); |
| 4496 | + |
| 4497 | + time_show_last_format = video_info.time_show; |
| 4498 | + rtime_localtime(&time_, &tm_); |
| 4499 | + |
| 4500 | + switch (video_info.time_show) |
| 4501 | + { |
| 4502 | + case TIME_SHOW_HM: |
| 4503 | + strftime(time_text, sizeof(time_text), "%H:%M", &tm_); |
| 4504 | + time_update_interval = (60 - tm_.tm_sec) * 1000000; |
| 4505 | + break; |
| 4506 | + case TIME_SHOW_HMS: |
| 4507 | + strftime(time_text, sizeof(time_text), "%H:%M:%S", &tm_); |
| 4508 | + time_update_interval = 500000; |
| 4509 | + break; |
| 4510 | + case TIME_SHOW_HM_AMPM: |
| 4511 | + strftime_am_pm(time_text, sizeof(time_text), "%I:%M %p", &tm_); |
| 4512 | + time_update_interval = (60 - tm_.tm_sec) * 1000000; |
| 4513 | + break; |
| 4514 | + case TIME_SHOW_HMS_AMPM: |
| 4515 | + strftime_am_pm(time_text, sizeof(time_text), "%I:%M:%S %p", &tm_); |
| 4516 | + time_update_interval = 500000; |
| 4517 | + break; |
| 4518 | + } |
| 4519 | + |
| 4520 | + next_time_update = new_time + time_update_interval; |
| 4521 | + } |
| 4522 | + |
| 4523 | + strlcpy(status_text + _len, time_text, sizeof(status_text) - _len); |
| 4524 | + } |
| 4525 | + |
4468 | 4526 | /* Slightly messy code, |
4469 | 4527 | * but we really need to do processing before blocking on VSync |
4470 | 4528 | * for best possible scheduling. |
@@ -4751,6 +4809,7 @@ void video_driver_frame(const void *data, unsigned width, |
4751 | 4809 | || video_info.framecount_show |
4752 | 4810 | || video_info.memory_show |
4753 | 4811 | || video_info.core_status_msg_show |
| 4812 | + || video_info.time_show |
4754 | 4813 | ) |
4755 | 4814 | #if HAVE_MENU |
4756 | 4815 | && !((video_info.menu_st_flags & MENU_ST_FLAG_SCREENSAVER_ACTIVE)) |
|
0 commit comments