From 442b9bc3da0fdaabbd0818f51360d0c2252c9f52 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Mon, 23 Dec 2024 05:44:40 +0100 Subject: [PATCH] Syntax style nits --- audio/audio_driver.c | 15 ++- audio/drivers/ctr_dsp_thread_audio.c | 42 +++--- audio/drivers/pipewire.c | 5 +- audio/drivers/psp_audio.c | 11 +- audio/drivers/pulse.c | 13 +- cheevos/cheevos_client.c | 4 +- frontend/drivers/platform_ctr.c | 5 +- frontend/drivers/platform_darwin.m | 10 +- gfx/common/x11_common.c | 13 +- gfx/drivers/d3d10.c | 17 ++- gfx/drivers/d3d11.c | 16 +-- gfx/drivers/gl2.c | 18 +-- gfx/video_driver.c | 6 +- gfx/video_filters/picoscale_256x_320x240.c | 21 ++- gfx/widgets/gfx_widget_leaderboard_display.c | 12 +- input/common/wayland_common.c | 16 +-- input/drivers_joypad/mfi_joypad.m | 21 +-- input/drivers_joypad/sdl_joypad.c | 13 +- input/drivers_joypad/switch_joypad.c | 42 +++--- libretro-common/audio/dsp_filters/reverb.c | 16 ++- libretro-common/file/archive_file_zlib.c | 3 +- .../formats/libchdr/libchdr_huffman.c | 3 +- libretro-common/include/retro_endianness.h | 60 +++++---- menu/cbs/menu_cbs_get_value.c | 6 +- menu/cbs/menu_cbs_left.c | 117 +++++++++-------- menu/menu_displaylist.c | 5 +- menu/menu_setting.c | 37 +++--- ui/drivers/cocoa/cocoa_common.m | 122 +++++++++--------- ui/drivers/ui_cocoa.m | 25 ++-- ui/drivers/ui_cocoatouch.m | 38 +++--- 30 files changed, 378 insertions(+), 354 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index f842d7ae39..01a727eb95 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -501,10 +501,12 @@ static void audio_driver_flush( if (is_slowmotion) src_data.ratio *= slowmotion_ratio; - if (is_fastforward && config_get_ptr()->bools.audio_fastforward_speedup) { + if (is_fastforward && config_get_ptr()->bools.audio_fastforward_speedup) + { const retro_time_t flush_time = cpu_features_get_time_usec(); - if (audio_st->last_flush_time > 0) { + if (audio_st->last_flush_time > 0) + { /* What we should see if the speed was 1.0x, converted to microsecs */ const double expected_flush_delta = (src_data.input_frames / audio_st->input * 1000000); @@ -517,16 +519,17 @@ static void audio_driver_flush( compression and decompression every single frame, which would make sounds irrecognizable. - https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average */ + https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average + */ const retro_time_t n = AUDIO_FF_EXP_AVG_SAMPLES; audio_st->avg_flush_delta = audio_st->avg_flush_delta * (n - 1) / n + - (flush_time - audio_st->last_flush_time) / n; + (flush_time - audio_st->last_flush_time) / n; /* How much does the avg_flush_delta deviate from the delta at 1.0x speed? */ src_data.ratio *= MAX(AUDIO_MIN_RATIO, - MIN(AUDIO_MAX_RATIO, - audio_st->avg_flush_delta / expected_flush_delta)); + MIN(AUDIO_MAX_RATIO, + audio_st->avg_flush_delta / expected_flush_delta)); } audio_st->last_flush_time = flush_time; diff --git a/audio/drivers/ctr_dsp_thread_audio.c b/audio/drivers/ctr_dsp_thread_audio.c index 4fbbf5f6fa..458695113a 100644 --- a/audio/drivers/ctr_dsp_thread_audio.c +++ b/audio/drivers/ctr_dsp_thread_audio.c @@ -55,17 +55,16 @@ static void ctr_dsp_audio_loop(void* data) if (!ctr) return; - while (1) + for (;;) { size_t buf_avail, avail, to_write; slock_lock(ctr->fifo_lock); - do { + do + { avail = FIFO_READ_AVAIL(ctr->fifo); - - if (!avail) { + if (!avail) scond_wait(ctr->fifo_avail, ctr->fifo_lock); - } } while (!avail && ctr->running); slock_unlock(ctr->fifo_lock); @@ -81,7 +80,8 @@ static void ctr_dsp_audio_loop(void* data) slock_lock(ctr->fifo_lock); - if (to_write > 0) { + if (to_write > 0) + { fifo_read(ctr->fifo, ctr->dsp_buf.data_pcm8 + pos, to_write); DSP_FlushDataCache(ctr->dsp_buf.data_pcm8 + pos, to_write); scond_signal(ctr->fifo_done); @@ -89,7 +89,8 @@ static void ctr_dsp_audio_loop(void* data) slock_unlock(ctr->fifo_lock); - if (buf_pos == pos) { + if (buf_pos == pos) + { svcSleepThread(100000); } @@ -142,10 +143,10 @@ static void *ctr_dsp_thread_audio_init(const char *device, unsigned rate, unsign ctr->fifo = fifo_new(ctr->fifo_size); - if (!(ctr->fifo_lock = slock_new()) || - !(ctr->fifo_avail = scond_new()) || - !(ctr->fifo_done = scond_new()) || - !(ctr->thread = sthread_create(ctr_dsp_audio_loop, ctr))) + if ( !(ctr->fifo_lock = slock_new()) + || !(ctr->fifo_avail = scond_new()) + || !(ctr->fifo_done = scond_new()) + || !(ctr->thread = sthread_create(ctr_dsp_audio_loop, ctr))) { RARCH_LOG("[Audio]: thread creation failed.\n"); ctr->running = false; @@ -229,7 +230,8 @@ static ssize_t ctr_dsp_thread_audio_write(void *data, const void *buf, size_t si if (ctr->running) { /* Wait a maximum of one frame, skip the write if the thread is still busy */ - if (!scond_wait_timeout(ctr->fifo_done, ctr->fifo_lock, ctr->frame_time)) { + if (!scond_wait_timeout(ctr->fifo_done, ctr->fifo_lock, ctr->frame_time)) + { slock_unlock(ctr->fifo_lock); break; } @@ -282,11 +284,11 @@ static bool ctr_dsp_thread_audio_start(void *data, bool is_shutdown) /* Prevents restarting audio when the menu * is toggled off on shutdown */ - if (is_shutdown) - return true; - - ndspSetMasterVol(1.0); - ctr->playing = true; + if (!is_shutdown) + { + ndspSetMasterVol(1.0); + ctr->playing = true; + } return true; } @@ -298,11 +300,7 @@ static void ctr_dsp_thread_audio_set_nonblock_state(void *data, bool state) ctr->nonblocking = state; } -static bool ctr_dsp_thread_audio_use_float(void *data) -{ - (void)data; - return false; -} +static bool ctr_dsp_thread_audio_use_float(void *data) { return false; } static size_t ctr_dsp_thread_audio_write_avail(void *data) { diff --git a/audio/drivers/pipewire.c b/audio/drivers/pipewire.c index 55efc791aa..049a6bf481 100644 --- a/audio/drivers/pipewire.c +++ b/audio/drivers/pipewire.c @@ -229,12 +229,13 @@ static const struct pw_stream_events playback_stream_events = { static int wait_resync(pw_t *pw) { + int res; + retro_assert(pw != NULL); - int res; pw->pending_seq = pw_core_sync(pw->core, PW_ID_CORE, pw->pending_seq); - while (true) + for (;;) { pw_thread_loop_wait(pw->thread_loop); diff --git a/audio/drivers/psp_audio.c b/audio/drivers/psp_audio.c index 2bbdd3fee8..e6f8e2c174 100644 --- a/audio/drivers/psp_audio.c +++ b/audio/drivers/psp_audio.c @@ -68,20 +68,19 @@ typedef struct psp_audio #define AUDIO_BUFFER_SIZE_MASK (AUDIO_BUFFER_SIZE-1) /* Return port used */ -static int configureAudio(unsigned rate) { - int port; +static int configureAudio(unsigned rate) +{ #if defined(VITA) - port = sceAudioOutOpenPort( + return sceAudioOutOpenPort( SCE_AUDIO_OUT_PORT_TYPE_MAIN, AUDIO_OUT_COUNT, rate, SCE_AUDIO_OUT_MODE_STEREO); #elif defined(ORBIS) - port = sceAudioOutOpen(0xff, + return sceAudioOutOpen(0xff, SCE_AUDIO_OUT_PORT_TYPE_MAIN, 0, AUDIO_OUT_COUNT, rate, SCE_AUDIO_OUT_MODE_STEREO); #else - port = sceAudioSRCChReserve(AUDIO_OUT_COUNT, rate, 2); + return sceAudioSRCChReserve(AUDIO_OUT_COUNT, rate, 2); #endif - return port; } static void audioMainLoop(void *data) diff --git a/audio/drivers/pulse.c b/audio/drivers/pulse.c index 6c60b35684..4c799cbcc1 100644 --- a/audio/drivers/pulse.c +++ b/audio/drivers/pulse.c @@ -92,21 +92,22 @@ static void context_state_cb(pa_context *c, void *data) } } -static void pa_sinklist_cb(pa_context *c, const pa_sink_info *l, int eol, void *data) +static void pa_sinklist_cb(pa_context *c, const pa_sink_info *l, int eol, void *data) { union string_list_elem_attr attr; attr.i = 0; pa_t *pa = (pa_t*)data; if (!pa->devicelist) - pa->devicelist = string_list_new(); + pa->devicelist = string_list_new(); if (!pa->devicelist) return; - // If eol is set to a positive number, you're at the end of the list - if (eol > 0) { + /* If EOL is set to a positive number, + * you're at the end of the list */ + if (eol > 0) return; - } + RARCH_DBG("[PulseAudio]: Sink detected: %s\n",l->name); string_list_append(pa->devicelist, l->name, attr); } @@ -213,7 +214,7 @@ static void *pulse_init(const char *device, unsigned rate, /* Checking device against sink list would be tricky due to callback, so it is just set. */ if (device) pa_context_set_default_sink(pa->context, device, NULL, NULL); - + spec.format = is_little_endian() ? PA_SAMPLE_FLOAT32LE : PA_SAMPLE_FLOAT32BE; spec.channels = 2; spec.rate = rate; diff --git a/cheevos/cheevos_client.c b/cheevos/cheevos_client.c index 10c0048098..1f8e480d1f 100644 --- a/cheevos/cheevos_client.c +++ b/cheevos/cheevos_client.c @@ -155,7 +155,7 @@ static void rcheevos_filter_url_param(char* url, char* param) else ++start; - do + for (;;) { next = strchr(start, '&'); @@ -175,7 +175,7 @@ static void rcheevos_filter_url_param(char* url, char* param) return; start = next + 1; - } while (1); + } } #endif #endif diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index cb37b99b27..7200007175 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -409,8 +409,6 @@ static void frontend_ctr_init(void* data) #ifndef IS_SALAMANDER extern audio_driver_t audio_null; - (void)data; - verbosity_enable(); gfxInit(GSP_BGR8_OES, GSP_BGR8_OES, false); @@ -465,7 +463,8 @@ static void frontend_ctr_init(void* data) if (csndInit() != 0) audio_ctr_csnd = audio_null; ctr_check_dspfirm(); - if (ndspInit() != 0) { + if (ndspInit() != 0) + { audio_ctr_dsp = audio_null; #ifdef HAVE_THREADS audio_ctr_dsp_thread = audio_null; diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index 12133742ac..524be2992a 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -419,17 +419,15 @@ static void frontend_darwin_get_env(int *argc, char *argv[], fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], application_data, "database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], application_data, "downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS])); NSURL *url = [[NSBundle mainBundle] URLForResource:nil withExtension:@"dsp" subdirectory:@"filters/audio"]; - if (url) { + if (url) strlcpy(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER], [[url baseURL] fileSystemRepresentation], sizeof(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER])); - } else { + else fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER], application_data, "filters/audio", sizeof(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER])); - } url = [[NSBundle mainBundle] URLForResource:nil withExtension:@"filt" subdirectory:@"filters/video"]; - if (url) { + if (url) strlcpy(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], [[url baseURL] fileSystemRepresentation], sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); - } else { + else fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], application_data, "filters/video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); - } fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], application_data, "info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], application_data, "overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OSK_OVERLAY], application_data, "overlays/keyboards", sizeof(g_defaults.dirs[DEFAULT_DIR_OSK_OVERLAY])); diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 69f9bdefa6..8a7cc783d6 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -209,11 +209,11 @@ void x11_set_window_attr(Display *dpy, Window win) static bool xss_screensaver_inhibit(Display *dpy, bool enable) { int dummy, min, maj; - if (!XScreenSaverQueryExtension(dpy, &dummy, &dummy) || - !XScreenSaverQueryVersion(dpy, &maj, &min) || - maj < 1 || (maj == 1 && min < 1)) { + if ( !XScreenSaverQueryExtension(dpy, &dummy, &dummy) + || !XScreenSaverQueryVersion(dpy, &maj, &min) + || (maj < 1) + || (maj == 1 && min < 1)) return false; - } XScreenSaverSuspend(dpy, enable); XResetScreenSaver(dpy); return true; @@ -276,10 +276,13 @@ bool x11_suspend_screensaver(void *data, bool enable) return true; #endif if (!xss_screensaver_inhibit(g_x11_dpy, enable) && enable) - if (xdg_screensaver_available) { + { + if (xdg_screensaver_available) + { xdg_screensaver_inhibit(wnd); return xdg_screensaver_available; } + } return true; } diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c index 207534dcdb..5c62612646 100644 --- a/gfx/drivers/d3d10.c +++ b/gfx/drivers/d3d10.c @@ -257,7 +257,7 @@ static bool d3d10_init_shader( D3DBlob ps_code = NULL; D3DBlob gs_code = NULL; - bool success = true; + bool success = true; if (!src) /* LPCWSTR filename */ { @@ -1366,17 +1366,16 @@ static bool d3d10_gfx_set_shader(void* data, size_t _len = strlcpy(_path, slang_path, sizeof(_path)); strlcpy(_path + _len, ".vs.hlsl", sizeof(_path) - _len); - if (!d3d10_init_shader( - d3d10->device, vs_src, 0, _path, "main", - NULL, NULL, desc, countof(desc), - &d3d10->pass[i].shader)) { } + d3d10_init_shader(d3d10->device, vs_src, 0, + _path, "main", NULL, NULL, desc, + countof(desc), &d3d10->pass[i].shader); strlcpy(_path + _len, ".ps.hlsl", sizeof(_path) - _len); - if (!d3d10_init_shader( - d3d10->device, ps_src, 0, _path, NULL, "main", - NULL, NULL, 0, - &d3d10->pass[i].shader)) { } + d3d10_init_shader(d3d10->device, ps_src, + 0, _path, NULL, "main", + NULL, NULL, 0, + &d3d10->pass[i].shader); free(d3d10->shader_preset->pass[i].source.string.vertex); free(d3d10->shader_preset->pass[i].source.string.fragment); diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index b08a7a2c14..143877e296 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -1568,19 +1568,15 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const size_t _len = strlcpy(_path, slang_path, sizeof(_path)); strlcpy(_path + _len, ".vs.hlsl", sizeof(_path) - _len); - if (!d3d11_init_shader( - d3d11->device, vs_src, 0, _path, "main", NULL, NULL, desc, countof(desc), - &d3d11->pass[i].shader, - feat_level_hint - )) { } + d3d11_init_shader(d3d11->device, vs_src, 0, + _path, "main", NULL, NULL, desc, countof(desc), + &d3d11->pass[i].shader, feat_level_hint); strlcpy(_path + _len, ".ps.hlsl", sizeof(_path) - _len); - if (!d3d11_init_shader( - d3d11->device, ps_src, 0, _path, NULL, "main", NULL, NULL, 0, - &d3d11->pass[i].shader, - feat_level_hint - )) { } + d3d11_init_shader(d3d11->device, ps_src, 0, _path, + NULL, "main", NULL, NULL, 0, + &d3d11->pass[i].shader, feat_level_hint); free(d3d11->shader_preset->pass[i].source.string.vertex); free(d3d11->shader_preset->pass[i].source.string.fragment); diff --git a/gfx/drivers/gl2.c b/gfx/drivers/gl2.c index 228783c461..eac83eef96 100644 --- a/gfx/drivers/gl2.c +++ b/gfx/drivers/gl2.c @@ -1783,13 +1783,11 @@ static void gl2_renderchain_recompute_pass_sizes( case RARCH_SCALE_VIEWPORT: if (gl->rotation % 180 == 90) - { - fbo_rect->img_width = fbo_rect->max_img_width = + fbo_rect->img_width = fbo_rect->max_img_width = fbo_scale->scale_x * vp_height; - } else { - fbo_rect->img_width = fbo_rect->max_img_width = + else + fbo_rect->img_width = fbo_rect->max_img_width = fbo_scale->scale_x * vp_width; - } break; } @@ -1807,13 +1805,11 @@ static void gl2_renderchain_recompute_pass_sizes( case RARCH_SCALE_VIEWPORT: if (gl->rotation % 180 == 90) - { - fbo_rect->img_height = fbo_rect->max_img_height = + fbo_rect->img_height = fbo_rect->max_img_height = fbo_scale->scale_y * vp_width; - } else { - fbo_rect->img_height = fbo_rect->max_img_height = - fbo_scale->scale_y * vp_height; - } + else + fbo_rect->img_height = fbo_rect->max_img_height = + fbo_scale->scale_y * vp_height; break; } diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 54816b92c1..ad1ce4424b 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -308,8 +308,7 @@ static void *video_null_init(const video_info_t *video, } static bool video_null_frame(void *a, const void *b, unsigned c, unsigned d, -uint64_t e, -unsigned f, const char *g, video_frame_info_t *h) { return true; } +uint64_t e, unsigned f, const char *g, video_frame_info_t *h) { return true; } static void video_null_free(void *a) { } static void video_null_set_nonblock_state(void *a, bool b, bool c, unsigned d) { } static bool video_null_alive(void *a) { return frontend_driver_get_signal_handler_state() != 1; } @@ -2090,7 +2089,8 @@ void video_driver_set_aspect_ratio(void) video_st->poke->set_aspect_ratio(video_st->data, aspect_ratio_idx); } -void video_viewport_get_scaled_aspect(struct video_viewport *vp, unsigned viewport_width, unsigned viewport_height, bool ydown) { +void video_viewport_get_scaled_aspect(struct video_viewport *vp, unsigned viewport_width, unsigned viewport_height, bool ydown) +{ float device_aspect = (float)viewport_width / viewport_height; float desired_aspect = video_driver_get_aspect_ratio(); video_viewport_get_scaled_aspect2(vp, viewport_width, viewport_height, ydown, device_aspect, desired_aspect); diff --git a/gfx/video_filters/picoscale_256x_320x240.c b/gfx/video_filters/picoscale_256x_320x240.c index 65c0831738..393073fb3b 100644 --- a/gfx/video_filters/picoscale_256x_320x240.c +++ b/gfx/video_filters/picoscale_256x_320x240.c @@ -107,7 +107,8 @@ scalers h: /* scale 4:5 */ #define PICOSCALE_H_UPSCALE_SNN_4_5(di,ds,si,ss,w,f) do { \ uint16_t i; \ - for (i = w/4; i > 0; i--, si += 4, di += 5) { \ + for (i = w/4; i > 0; i--, si += 4, di += 5) \ + { \ di[0] = f(si[0]); \ di[1] = f(si[1]); \ PICOSCALE_P_05(di[2], f(si[1]),f(si[2])); \ @@ -120,7 +121,8 @@ scalers h: #define PICOSCALE_H_UPSCALE_BL2_4_5(di,ds,si,ss,w,f) do { \ uint16_t i; \ - for (i = w/4; i > 0; i--, si += 4, di += 5) { \ + for (i = w/4; i > 0; i--, si += 4, di += 5) \ + { \ di[0] = f(si[0]); \ PICOSCALE_P_05(di[1], f(si[0]),f(si[1])); \ PICOSCALE_P_05(di[2], f(si[1]),f(si[2])); \ @@ -133,7 +135,8 @@ scalers h: #define PICOSCALE_H_UPSCALE_BL4_4_5(di,ds,si,ss,w,f) do { \ uint16_t i, t; uint16_t p = f(si[0]); \ - for (i = w/4; i > 0; i--, si += 4, di += 5) { \ + for (i = w/4; i > 0; i--, si += 4, di += 5) \ + { \ PICOSCALE_P_025(di[0], p, f(si[0])); \ PICOSCALE_P_05 (di[1], f(si[0]),f(si[1])); \ PICOSCALE_P_05 (di[2], f(si[1]),f(si[2])); \ @@ -150,7 +153,8 @@ scalers v: #define PICOSCALE_V_MIX(di,li,ri,w,p_mix,f) do { \ uint16_t i, t, u; (void)t, (void)u; \ - for (i = 0; i < w; i += 4) { \ + for (i = 0; i < w; i += 4) \ + { \ p_mix((di)[i ], f((li)[i ]),f((ri)[i ])); \ p_mix((di)[i+1], f((li)[i+1]),f((ri)[i+1])); \ p_mix((di)[i+2], f((li)[i+2]),f((ri)[i+2])); \ @@ -240,7 +244,7 @@ void picoscale_upscale_rgb_snn_256_320x192_240(uint16_t *PICOSCALE_restrict di, /* Next two lines */ PICOSCALE_H_UPSCALE_SNN_4_5(di, ds, si, ss, 256, PICOSCALE_F_NOP); PICOSCALE_H_UPSCALE_SNN_4_5(di, ds, si, ss, 256, PICOSCALE_F_NOP); - + /* mix lines 2-4 */ di -= ds*3; @@ -411,8 +415,11 @@ static void picoscale_256x_320x240_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) { - if ((width == 256) && - ((height == 224) || (height == 240) || (height == 192) || (height == 239))) + if ( (width == 256) + && ((height == 224) + || (height == 240) + || (height == 192) + || (height == 239))) { *out_width = 320; *out_height = 240; diff --git a/gfx/widgets/gfx_widget_leaderboard_display.c b/gfx/widgets/gfx_widget_leaderboard_display.c index e65cd6ab1a..756e635f04 100644 --- a/gfx/widgets/gfx_widget_leaderboard_display.c +++ b/gfx/widgets/gfx_widget_leaderboard_display.c @@ -170,7 +170,8 @@ static void gfx_widget_leaderboard_display_frame(void* data, void* userdata) - p_dispwidget->gfx_widget_fonts.regular.line_descender); ptr = state->tracker_info[i].display; - while (*ptr) { + while (*ptr) + { float next_char_x = char_x + state->fixed_char_width; const char c = *ptr++; if (c >= CHEEVO_LBOARD_FIRST_FIXED_CHAR && c <= CHEEVO_LBOARD_LAST_FIXED_CHAR) @@ -182,9 +183,7 @@ static void gfx_widget_leaderboard_display_frame(void* data, void* userdata) char_x += padding; } else - { next_char_x = char_x + char_width; - } } buffer[0] = c; @@ -348,16 +347,17 @@ static void gfx_widget_leaderboard_display_frame(void* data, void* userdata) if (state->disconnected || state->loading) { char loading_buffer[8] = "RA ..."; - const char* disconnected_text = state->disconnected ? "! RA !" : loading_buffer; + const char *disconnected_text = state->disconnected ? "! RA !" : loading_buffer; const unsigned disconnect_widget_width = font_driver_get_message_width( state->dispwidget_ptr->gfx_widget_fonts.msg_queue.font, disconnected_text, 0, 1) + CHEEVO_LBOARD_DISPLAY_PADDING * 2; const unsigned disconnect_widget_height = p_dispwidget->gfx_widget_fonts.msg_queue.line_height + (CHEEVO_LBOARD_DISPLAY_PADDING - 1) * 2; - x = video_width - disconnect_widget_width - spacing; + x = video_width - disconnect_widget_width - spacing; y -= disconnect_widget_height + spacing; - if (state->loading) { + if (state->loading) + { const uint16_t loading_shift = 5; loading_buffer[((state->loading - 1) >> loading_shift) + 3] = '\0'; state->loading &= (1 << (loading_shift + 2)) - 1; diff --git a/input/common/wayland_common.c b/input/common/wayland_common.c index 3009885cc1..7245773b82 100644 --- a/input/common/wayland_common.c +++ b/input/common/wayland_common.c @@ -464,14 +464,10 @@ static void handle_relative_motion(void *data, } static void -locked_pointer_locked(void *data, struct zwp_locked_pointer_v1 *locked_pointer) -{ -} +locked_pointer_locked(void *data, struct zwp_locked_pointer_v1 *lockptr) { } static void -locked_pointer_unlocked(void *data, struct zwp_locked_pointer_v1 *locked_pointer) -{ -} +locked_pointer_unlocked(void *data, struct zwp_locked_pointer_v1 *lockptr) { } static void wl_touch_handle_frame(void *data, struct wl_touch *wl_touch) { } @@ -551,13 +547,15 @@ static bool wl_update_scale(gfx_ctx_wayland_data_t *wl) wl_list_for_each(os, &wl->current_outputs, link) { - if (os->output->scale > largest_scale) { + if (os->output->scale > largest_scale) + { largest_scale = os->output->scale; new_output = os->output; } }; - if (new_output && wl->current_output != new_output) { + if (new_output && wl->current_output != new_output) + { wl->current_output = new_output; wl->pending_buffer_scale = new_output->scale; return true; @@ -1125,7 +1123,7 @@ const struct zwp_relative_pointer_v1_listener relative_pointer_listener = { }; const struct zwp_locked_pointer_v1_listener locked_pointer_listener = { - .locked = locked_pointer_locked, + .locked = locked_pointer_locked, .unlocked = locked_pointer_unlocked, }; diff --git a/input/drivers_joypad/mfi_joypad.m b/input/drivers_joypad/mfi_joypad.m index ec8d0655b1..f68c9455af 100644 --- a/input/drivers_joypad/mfi_joypad.m +++ b/input/drivers_joypad/mfi_joypad.m @@ -81,7 +81,7 @@ static void apple_gamecontroller_joypad_poll_internal(GCController *controller, { uint32_t *buttons = &mfi_buttons[slot]; /* Retain the values from the paused controller handler and pass them through. - * The menu button can be pressed/unpressed + * The menu button can be pressed/unpressed * like any other button in iOS 13, * so no need to passthrough anything */ if (@available(iOS 13, *)) @@ -231,7 +231,7 @@ static void apple_gamecontroller_joypad_register(GCController *controller) { #ifdef __IPHONE_14_0 /* Don't let tvOS or iOS do anything with **our** buttons!! - * iOS will start a screen recording if you hold or doubleclick + * iOS will start a screen recording if you hold or doubleclick * the OPTIONS button, we don't want that. */ if (@available(iOS 14.0, tvOS 14.0, macOS 11, *)) { @@ -241,8 +241,8 @@ static void apple_gamecontroller_joypad_register(GCController *controller) gp.buttonHome.preferredSystemGestureState = GCSystemGestureStateDisabled; } #endif - - /* controllerPausedHandler is deprecated in favor + + /* controllerPausedHandler is deprecated in favor * of being able to deal with the menu * button as any other button */ if (@available(iOS 13, *)) @@ -257,16 +257,16 @@ static void apple_gamecontroller_joypad_register(GCController *controller) { uint32_t slot = (uint32_t)controller.playerIndex; - /* Support buttons that aren't supported by the mFi + /* Support buttons that aren't supported by the mFi * controller via "hotkey" combinations: * * LS + Menu => Select * LT + Menu => L3 * RT + Menu => R3 - * Note that these are just button presses, and it + * Note that these are just button presses, and it * does not simulate holding down the button */ - if ( controller.gamepad.leftShoulder.pressed + if ( controller.gamepad.leftShoulder.pressed || controller.extendedGamepad.leftShoulder.pressed ) { mfi_buttons[slot] &= ~(1 << RETRO_DEVICE_ID_JOYPAD_START); @@ -703,14 +703,14 @@ static int16_t apple_gamecontroller_joypad_state( ? binds[i].joykey : joypad_info->auto_binds[i].joykey; const uint32_t joyaxis = (binds[i].joyaxis != AXIS_NONE) ? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis; - if ( (uint16_t)joykey != NO_BTN + if ( (uint16_t)joykey != NO_BTN && !GET_HAT_DIR(i) && (i < 32) && ((mfi_buttons[port_idx] & (1 << i)) != 0) ) ret |= ( 1 << i); else if (joyaxis != AXIS_NONE && - ((float)abs(apple_gamecontroller_joypad_axis(port_idx, joyaxis)) + ((float)abs(apple_gamecontroller_joypad_axis(port_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold) ret |= (1 << i); } @@ -726,7 +726,8 @@ static bool apple_gamecontroller_joypad_set_rumble(unsigned pad, settings_t *settings = config_get_ptr(); bool enable_device_vibration = settings->bools.enable_device_vibration; - if (@available(iOS 14, *)) { + if (@available(iOS 14, *)) + { if (enable_device_vibration && pad == 0) { NSError *error; diff --git a/input/drivers_joypad/sdl_joypad.c b/input/drivers_joypad/sdl_joypad.c index 5f1a706990..64a96a8ad0 100644 --- a/input/drivers_joypad/sdl_joypad.c +++ b/input/drivers_joypad/sdl_joypad.c @@ -190,7 +190,7 @@ static void sdl_pad_connect(unsigned id) } pad->haptic = NULL; - + if (g_has_haptic) { pad->haptic = SDL_HapticOpenFromJoystick(pad->joypad); @@ -217,7 +217,8 @@ static void sdl_pad_connect(unsigned id) } } #if SDL_VERSION_ATLEAST(2, 0, 9) - if (!pad->haptic || pad->rumble_effect == -2) { + if (!pad->haptic || pad->rumble_effect == -2) + { pad->rumble_effect = -3; RARCH_LOG("[SDL]: Falling back to joystick rumble\n"); } @@ -296,7 +297,7 @@ static void *sdl_joypad_init(void *data) } else g_has_haptic = true; - + #if SDL_VERSION_ATLEAST(2, 0, 9) /* enable extended hid reports to support ps4/ps5 rumble over bluetooth */ SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1"); @@ -389,7 +390,7 @@ static int16_t sdl_joypad_axis_state( if (val < 0) { /* Clamp - -0x8000 can cause trouble if we later abs() it. */ - if (val < -0x7fff) + if (val < -0x7fff) return -0x7fff; return val; } @@ -435,12 +436,12 @@ static int16_t sdl_joypad_state( const uint32_t joyaxis = (binds[i].joyaxis != AXIS_NONE) ? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis; if ( - (uint16_t)joykey != NO_BTN + (uint16_t)joykey != NO_BTN && sdl_joypad_button_state(pad, port_idx, (uint16_t)joykey) ) ret |= ( 1 << i); else if (joyaxis != AXIS_NONE && - ((float)abs(sdl_joypad_axis_state(pad, port_idx, joyaxis)) + ((float)abs(sdl_joypad_axis_state(pad, port_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold) ret |= (1 << i); } diff --git a/input/drivers_joypad/switch_joypad.c b/input/drivers_joypad/switch_joypad.c index 7b543be543..65d4ff0278 100644 --- a/input/drivers_joypad/switch_joypad.c +++ b/input/drivers_joypad/switch_joypad.c @@ -31,7 +31,7 @@ static HidVibrationDeviceHandle vibration_handles[DEFAULT_MAX_PADS][2]; static HidVibrationDeviceHandle vibration_handleheld[2]; static HidVibrationValue vibration_values[DEFAULT_MAX_PADS][2]; static HidVibrationValue vibration_stop; -static int previous_handheld = -1; +static int previous_handheld = -1; /* 1 = handheld, 0 = docked, -1 = first use */ static uint previous_split_joycon_setting[MAX_USERS] = { 0 }; #endif @@ -59,7 +59,7 @@ static void *switch_joypad_init(void *data) hidSetNpadJoyHoldType(HidNpadJoyHoldType_Horizontal); padConfigureInput(DEFAULT_MAX_PADS, HidNpadStyleSet_NpadStandard); - /* Switch like stop behavior with muted band channels + /* Switch like stop behavior with muted band channels * and frequencies set to default. */ vibration_stop.amp_low = 0.0f; vibration_stop.freq_low = 160.0f; @@ -181,12 +181,12 @@ static int16_t switch_joypad_state( const uint32_t joyaxis = (binds[i].joyaxis != AXIS_NONE) ? binds[i].joyaxis : joypad_info->auto_binds[i].joyaxis; if ( - (uint16_t)joykey != NO_BTN + (uint16_t)joykey != NO_BTN && (button_state[port_idx] & (1 << (uint16_t)joykey)) ) ret |= ( 1 << i); else if (joyaxis != AXIS_NONE && - ((float)abs(switch_joypad_axis_state(port_idx, joyaxis)) + ((float)abs(switch_joypad_axis_state(port_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold) ret |= (1 << i); } @@ -237,20 +237,20 @@ static void switch_joypad_poll(void) if (previous_handheld == -1) { - /* First call of this function, apply joycon settings + /* First call of this function, apply joycon settings * according to preferences, init variables */ if (!handheld) { for (i = 0; i < MAX_USERS; i += 2) { - unsigned input_split_joycon = + unsigned input_split_joycon = settings->uints.input_split_joycon[i]; if (input_split_joycon) { hidSetNpadJoyAssignmentModeSingleByDefault(i); hidSetNpadJoyAssignmentModeSingleByDefault(i + 1); - } + } else if (!input_split_joycon) { hidSetNpadJoyAssignmentModeDual(i); @@ -266,7 +266,7 @@ static void switch_joypad_poll(void) if (!handheld && previous_handheld) { - /* switching out of handheld, so make sure + /* switching out of handheld, so make sure * joycons are correctly split. */ for (i = 0; i < MAX_USERS; i += 2) { @@ -297,7 +297,7 @@ static void switch_joypad_poll(void) { hidSetNpadJoyAssignmentModeSingleByDefault(i); hidSetNpadJoyAssignmentModeSingleByDefault(i + 1); - } + } else if (!input_split_joycon && previous_split_joycon_setting[i]) { @@ -310,19 +310,20 @@ static void switch_joypad_poll(void) for (i = 0; i < MAX_USERS; i += 2) previous_split_joycon_setting[i] = settings->uints.input_split_joycon[i]; - + previous_handheld = handheld; for (i = 0; i < DEFAULT_MAX_PADS; i++) { - HidAnalogStickState stick_left_state = padGetStickPos(&pad_states[i], 0); + HidAnalogStickState stick_left_state = padGetStickPos(&pad_states[i], 0); HidAnalogStickState stick_right_state = padGetStickPos(&pad_states[i], 1); unsigned input_split_joycon = settings->uints.input_split_joycon[i]; - int pad_button = padGetButtons(&pad_states[i]); - if (input_split_joycon && !handheld) { + int pad_button = padGetButtons(&pad_states[i]); + if (input_split_joycon && !handheld) + { button_state[i] = 0; - - if (hidGetNpadDeviceType((HidNpadIdType)i) & HidDeviceTypeBits_JoyLeft) { + if (hidGetNpadDeviceType((HidNpadIdType)i) & HidDeviceTypeBits_JoyLeft) + { if (pad_button & HidNpadButton_Left) button_state[i] |= (uint16_t)HidNpadButton_B; if (pad_button & HidNpadButton_Up) @@ -342,7 +343,9 @@ static void switch_joypad_poll(void) analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT][RETRO_DEVICE_ID_ANALOG_X] = -stick_left_state.y; analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT][RETRO_DEVICE_ID_ANALOG_Y] = -stick_left_state.x; - } else if (hidGetNpadDeviceType((HidNpadIdType)i) & HidDeviceTypeBits_JoyRight) { + } + else if (hidGetNpadDeviceType((HidNpadIdType)i) & HidDeviceTypeBits_JoyRight) + { if (pad_button & HidNpadButton_A) button_state[i] |= (uint16_t)HidNpadButton_B; if (pad_button & HidNpadButton_B) @@ -363,10 +366,9 @@ static void switch_joypad_poll(void) /* Throw JoyRight state into retro left analog */ analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT][RETRO_DEVICE_ID_ANALOG_X] = stick_right_state.y; analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT][RETRO_DEVICE_ID_ANALOG_Y] = stick_right_state.x; - } else { - /* Handle other types via Default Input Handling */ - goto lblDefaultInputHandling; } + else /* Handle other types via Default Input Handling */ + goto lblDefaultInputHandling; } else { @@ -375,7 +377,7 @@ lblDefaultInputHandling: button_state[i] = pad_button; analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT][RETRO_DEVICE_ID_ANALOG_X] = stick_left_state.x; analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT][RETRO_DEVICE_ID_ANALOG_Y] = -stick_left_state.y; - + analog_state[i][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_X] = stick_right_state.x; analog_state[i][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_Y] = -stick_right_state.y; } diff --git a/libretro-common/audio/dsp_filters/reverb.c b/libretro-common/audio/dsp_filters/reverb.c index 10559b3a3c..0a60014a1b 100644 --- a/libretro-common/audio/dsp_filters/reverb.c +++ b/libretro-common/audio/dsp_filters/reverb.c @@ -225,17 +225,19 @@ struct reverb_data static void reverb_free(void *data) { - struct reverb_data *rev = (struct reverb_data*)data; unsigned i; + struct reverb_data *rev = (struct reverb_data*)data; - for (i = 0; i < numcombs; i++) { - free(rev->left.bufcomb[i]); - free(rev->right.bufcomb[i]); + for (i = 0; i < numcombs; i++) + { + free(rev->left.bufcomb[i]); + free(rev->right.bufcomb[i]); } - for (i = 0; i < numallpasses; i++) { - free(rev->left.bufallpass[i]); - free(rev->right.bufallpass[i]); + for (i = 0; i < numallpasses; i++) + { + free(rev->left.bufallpass[i]); + free(rev->right.bufallpass[i]); } free(data); } diff --git a/libretro-common/file/archive_file_zlib.c b/libretro-common/file/archive_file_zlib.c index 79d0224401..d82af9aea4 100644 --- a/libretro-common/file/archive_file_zlib.c +++ b/libretro-common/file/archive_file_zlib.c @@ -156,7 +156,8 @@ static bool zlib_stream_decompress_data_to_file_init( zip_context->zstream->zfree = NULL; zip_context->zstream->opaque = NULL; - if (inflateInit2(zip_context->zstream, -MAX_WBITS) != Z_OK) { + if (inflateInit2(zip_context->zstream, -MAX_WBITS) != Z_OK) + { free(zip_context->zstream); zip_context->zstream = NULL; goto error; diff --git a/libretro-common/formats/libchdr/libchdr_huffman.c b/libretro-common/formats/libchdr/libchdr_huffman.c index 1fe38388a3..8f1f095ba0 100644 --- a/libretro-common/formats/libchdr/libchdr_huffman.c +++ b/libretro-common/formats/libchdr/libchdr_huffman.c @@ -427,9 +427,8 @@ int huffman_build_tree(struct huffman_decoder* decoder, uint32_t totaldata, uint #if 0 fprintf(stderr, "Post-sort:\n"); - for (int i = 0; i < listitems; i++) { + for (int i = 0; i < listitems; i++) fprintf(stderr, "weight: %d code: %d\n", list[i]->m_weight, list[i]->m_bits); - } fprintf(stderr, "===================\n"); #endif diff --git a/libretro-common/include/retro_endianness.h b/libretro-common/include/retro_endianness.h index 8638b2c396..d9cd47777a 100644 --- a/libretro-common/include/retro_endianness.h +++ b/libretro-common/include/retro_endianness.h @@ -416,8 +416,9 @@ typedef struct retro_unaligned_uint64_s retro_unaligned_uint64_t; * @return The first two bytes of \c addr as a 16-bit unsigned integer, * byteswapped from big-endian to host-native order if necessary. */ -static INLINE uint16_t retro_get_unaligned_16be(void *addr) { - return retro_be_to_cpu16(retro_unaligned16(addr)); +static INLINE uint16_t retro_get_unaligned_16be(void *addr) +{ + return retro_be_to_cpu16(retro_unaligned16(addr)); } /** @@ -431,8 +432,9 @@ static INLINE uint16_t retro_get_unaligned_16be(void *addr) { * @return The first four bytes of \c addr as a 32-bit unsigned integer, * byteswapped from big-endian to host-native order if necessary. */ -static INLINE uint32_t retro_get_unaligned_32be(void *addr) { - return retro_be_to_cpu32(retro_unaligned32(addr)); +static INLINE uint32_t retro_get_unaligned_32be(void *addr) +{ + return retro_be_to_cpu32(retro_unaligned32(addr)); } /** @@ -446,8 +448,9 @@ static INLINE uint32_t retro_get_unaligned_32be(void *addr) { * @return The first eight bytes of \c addr as a 64-bit unsigned integer, * byteswapped from big-endian to host-native order if necessary. */ -static INLINE uint64_t retro_get_unaligned_64be(void *addr) { - return retro_be_to_cpu64(retro_unaligned64(addr)); +static INLINE uint64_t retro_get_unaligned_64be(void *addr) +{ + return retro_be_to_cpu64(retro_unaligned64(addr)); } /** @@ -461,8 +464,9 @@ static INLINE uint64_t retro_get_unaligned_64be(void *addr) { * @return The first two bytes of \c addr as a 16-bit unsigned integer, * byteswapped from little-endian to host-native order if necessary. */ -static INLINE uint16_t retro_get_unaligned_16le(void *addr) { - return retro_le_to_cpu16(retro_unaligned16(addr)); +static INLINE uint16_t retro_get_unaligned_16le(void *addr) +{ + return retro_le_to_cpu16(retro_unaligned16(addr)); } /** @@ -476,8 +480,9 @@ static INLINE uint16_t retro_get_unaligned_16le(void *addr) { * @return The first four bytes of \c addr as a 32-bit unsigned integer, * byteswapped from little-endian to host-native order if necessary. */ -static INLINE uint32_t retro_get_unaligned_32le(void *addr) { - return retro_le_to_cpu32(retro_unaligned32(addr)); +static INLINE uint32_t retro_get_unaligned_32le(void *addr) +{ + return retro_le_to_cpu32(retro_unaligned32(addr)); } /** @@ -491,8 +496,9 @@ static INLINE uint32_t retro_get_unaligned_32le(void *addr) { * @return The first eight bytes of \c addr as a 64-bit unsigned integer, * byteswapped from little-endian to host-native order if necessary. */ -static INLINE uint64_t retro_get_unaligned_64le(void *addr) { - return retro_le_to_cpu64(retro_unaligned64(addr)); +static INLINE uint64_t retro_get_unaligned_64le(void *addr) +{ + return retro_le_to_cpu64(retro_unaligned64(addr)); } /** @@ -505,8 +511,9 @@ static INLINE uint64_t retro_get_unaligned_64le(void *addr) { * the way a \c uint16_t* usually would be. * @param v The value to write. */ -static INLINE void retro_set_unaligned_16le(void *addr, uint16_t v) { - retro_unaligned16(addr) = retro_cpu_to_le16(v); +static INLINE void retro_set_unaligned_16le(void *addr, uint16_t v) +{ + retro_unaligned16(addr) = retro_cpu_to_le16(v); } /** @@ -519,8 +526,9 @@ static INLINE void retro_set_unaligned_16le(void *addr, uint16_t v) { * the way a \c uint32_t* usually would be. * @param v The value to write. */ -static INLINE void retro_set_unaligned_32le(void *addr, uint32_t v) { - retro_unaligned32(addr) = retro_cpu_to_le32(v); +static INLINE void retro_set_unaligned_32le(void *addr, uint32_t v) +{ + retro_unaligned32(addr) = retro_cpu_to_le32(v); } /** @@ -533,8 +541,9 @@ static INLINE void retro_set_unaligned_32le(void *addr, uint32_t v) { * the way a \c uint64_t* usually would be. * @param v The value to write. */ -static INLINE void retro_set_unaligned_64le(void *addr, uint64_t v) { - retro_unaligned64(addr) = retro_cpu_to_le64(v); +static INLINE void retro_set_unaligned_64le(void *addr, uint64_t v) +{ + retro_unaligned64(addr) = retro_cpu_to_le64(v); } /** @@ -547,8 +556,9 @@ static INLINE void retro_set_unaligned_64le(void *addr, uint64_t v) { * the way a \c uint16_t* usually would be. * @param v The value to write. */ -static INLINE void retro_set_unaligned_16be(void *addr, uint16_t v) { - retro_unaligned16(addr) = retro_cpu_to_be16(v); +static INLINE void retro_set_unaligned_16be(void *addr, uint16_t v) +{ + retro_unaligned16(addr) = retro_cpu_to_be16(v); } /** @@ -561,8 +571,9 @@ static INLINE void retro_set_unaligned_16be(void *addr, uint16_t v) { * the way a \c uint32_t* usually would be. * @param v The value to write. */ -static INLINE void retro_set_unaligned_32be(void *addr, uint32_t v) { - retro_unaligned32(addr) = retro_cpu_to_be32(v); +static INLINE void retro_set_unaligned_32be(void *addr, uint32_t v) +{ + retro_unaligned32(addr) = retro_cpu_to_be32(v); } /** @@ -575,8 +586,9 @@ static INLINE void retro_set_unaligned_32be(void *addr, uint32_t v) { * the way a \c uint64_t* usually would be. * @param v The value to write. */ -static INLINE void retro_set_unaligned_64be(void *addr, uint64_t v) { - retro_unaligned64(addr) = retro_cpu_to_be64(v); +static INLINE void retro_set_unaligned_64be(void *addr, uint64_t v) +{ + retro_unaligned64(addr) = retro_cpu_to_be64(v); } diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index c362c91c93..e5cbfdb9f2 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -688,7 +688,7 @@ static void menu_action_cpu_managed_freq_label( MENU_ENUM_LABEL_VALUE_CPU_MANAGED_MAX_FREQ), len2); freq = opts.max_freq; break; - }; + } if (freq == 1) strlcpy(s, "Min.", len); @@ -727,7 +727,7 @@ static void menu_action_cpu_freq_label( MENU_ENUM_LABEL_VALUE_CPU_POLICY_GOVERNOR), len2); strlcpy(s, d->scaling_governor, len); break; - }; + } } static void menu_action_cpu_governor_label( @@ -1160,7 +1160,7 @@ static void menu_action_setting_disp_set_label_menu_video_resolution( char *s2, size_t len2) { unsigned width = 0, height = 0; - char desc[64] = {0}; + char desc[64] = {0}; *w = 19; *s = '\0'; diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index c8971de5b0..c88dd76c81 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -697,18 +697,19 @@ static int cpu_policy_freq_managed_tweak(unsigned type, const char *label, cpu_scaling_opts_t opts; enum cpu_scaling_mode mode = get_cpu_scaling_mode(&opts); - switch (type) { - case MENU_SETTINGS_CPU_MANAGED_SET_MINFREQ: - opts.min_freq = get_cpu_scaling_next_frequency_limit( - opts.min_freq, -1); - set_cpu_scaling_mode(mode, &opts); - break; - case MENU_SETTINGS_CPU_MANAGED_SET_MAXFREQ: - opts.max_freq = get_cpu_scaling_next_frequency_limit( - opts.max_freq, -1); - set_cpu_scaling_mode(mode, &opts); - break; - }; + switch (type) + { + case MENU_SETTINGS_CPU_MANAGED_SET_MINFREQ: + opts.min_freq = get_cpu_scaling_next_frequency_limit( + opts.min_freq, -1); + set_cpu_scaling_mode(mode, &opts); + break; + case MENU_SETTINGS_CPU_MANAGED_SET_MAXFREQ: + opts.max_freq = get_cpu_scaling_next_frequency_limit( + opts.max_freq, -1); + set_cpu_scaling_mode(mode, &opts); + break; + } return 0; } @@ -726,30 +727,31 @@ static int cpu_policy_freq_managed_gov(unsigned type, const char *label, if (!drivers || !drivers[0]) return -1; - switch (atoi(label)) { - case 0: - pidx = string_list_find_elem(drivers[0]->available_governors, - opts.main_policy); - if (pidx > 1) - { - strlcpy(opts.main_policy, - drivers[0]->available_governors->elems[pidx-2].data, - sizeof(opts.main_policy)); - set_cpu_scaling_mode(mode, &opts); - } - break; - case 1: - pidx = string_list_find_elem(drivers[0]->available_governors, - opts.menu_policy); - if (pidx > 1) - { - strlcpy(opts.menu_policy, - drivers[0]->available_governors->elems[pidx-2].data, - sizeof(opts.menu_policy)); - set_cpu_scaling_mode(mode, &opts); - } - break; - }; + switch (atoi(label)) + { + case 0: + pidx = string_list_find_elem(drivers[0]->available_governors, + opts.main_policy); + if (pidx > 1) + { + strlcpy(opts.main_policy, + drivers[0]->available_governors->elems[pidx-2].data, + sizeof(opts.main_policy)); + set_cpu_scaling_mode(mode, &opts); + } + break; + case 1: + pidx = string_list_find_elem(drivers[0]->available_governors, + opts.menu_policy); + if (pidx > 1) + { + strlcpy(opts.menu_policy, + drivers[0]->available_governors->elems[pidx-2].data, + sizeof(opts.menu_policy)); + set_cpu_scaling_mode(mode, &opts); + } + break; + } return 0; } @@ -764,29 +766,30 @@ static int cpu_policy_freq_tweak(unsigned type, const char *label, if (!drivers) return 0; - switch (type) { - case MENU_SETTINGS_CPU_POLICY_SET_MINFREQ: - next_freq = get_cpu_scaling_next_frequency(drivers[policyid], - drivers[policyid]->min_policy_freq, -1); - set_cpu_scaling_min_frequency(drivers[policyid], next_freq); - break; - case MENU_SETTINGS_CPU_POLICY_SET_MAXFREQ: - next_freq = get_cpu_scaling_next_frequency(drivers[policyid], - drivers[policyid]->max_policy_freq, -1); - set_cpu_scaling_max_frequency(drivers[policyid], next_freq); - break; - case MENU_SETTINGS_CPU_POLICY_SET_GOVERNOR: + switch (type) { - int pidx = string_list_find_elem(drivers[policyid]->available_governors, - drivers[policyid]->scaling_governor); - if (pidx > 1) - { - set_cpu_scaling_governor(drivers[policyid], - drivers[policyid]->available_governors->elems[pidx-2].data); - } - break; + case MENU_SETTINGS_CPU_POLICY_SET_MINFREQ: + next_freq = get_cpu_scaling_next_frequency(drivers[policyid], + drivers[policyid]->min_policy_freq, -1); + set_cpu_scaling_min_frequency(drivers[policyid], next_freq); + break; + case MENU_SETTINGS_CPU_POLICY_SET_MAXFREQ: + next_freq = get_cpu_scaling_next_frequency(drivers[policyid], + drivers[policyid]->max_policy_freq, -1); + set_cpu_scaling_max_frequency(drivers[policyid], next_freq); + break; + case MENU_SETTINGS_CPU_POLICY_SET_GOVERNOR: + { + int pidx = string_list_find_elem(drivers[policyid]->available_governors, + drivers[policyid]->scaling_governor); + if (pidx > 1) + { + set_cpu_scaling_governor(drivers[policyid], + drivers[policyid]->available_governors->elems[pidx-2].data); + } + break; + } } - }; return 0; } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 204a3302af..b9da152036 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -11883,7 +11883,8 @@ static unsigned menu_displaylist_build_shader_parameter( current_value = min; original_value = param->current; - if (half_step <= 0.0) { /* safety check */ + if (half_step <= 0.0) /* safety check */ + { char val_s[16], val_d[16]; snprintf(val_s, sizeof(val_s), "%.2f", current_value); snprintf(val_d, sizeof(val_d), "%d", 0); @@ -12793,7 +12794,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, case CPUSCALING_BALANCED: /* No settings for these modes */ break; - }; + } } info->flags |= MD_FLAG_NEED_REFRESH diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 951df1e856..94350a896a 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -9508,38 +9508,39 @@ static void systemd_service_toggle(const char *path, char *unit, bool enable) static void switch_oc_enable_toggle_change_handler(rarch_setting_t *setting) { FILE* f = fopen(SWITCH_OC_TOGGLE_PATH, "w"); - if (*setting->value.target.boolean == true) { - fprintf(f, "1\n"); - } else { - fprintf(f, "0\n"); - } - fclose(f); + if (*setting->value.target.boolean) + fprintf(f, "1\n"); + else + fprintf(f, "0\n"); + fclose(f); } static void switch_cec_enable_toggle_change_handler(rarch_setting_t *setting) { - if (*setting->value.target.boolean == true) { + if (*setting->value.target.boolean) + { FILE* f = fopen(SWITCH_CEC_TOGGLE_PATH, "w"); - fprintf(f, "\n"); + fprintf(f, "\n"); fclose(f); - } else { - filestream_delete(SWITCH_CEC_TOGGLE_PATH); - } - + } + else + filestream_delete(SWITCH_CEC_TOGGLE_PATH); } static void bluetooth_ertm_disable_toggle_change_handler(rarch_setting_t *setting) { - if (*setting->value.target.boolean == true) { + if (*setting->value.target.boolean) + { FILE* f = fopen(BLUETOOTH_ERTM_TOGGLE_PATH, "w"); - fprintf(f, "1\n"); + fprintf(f, "1\n"); fclose(f); - } else { + } + else + { FILE* f = fopen(BLUETOOTH_ERTM_TOGGLE_PATH, "w"); - fprintf(f, "0\n"); + fprintf(f, "0\n"); fclose(f); - } - + } } #endif diff --git a/ui/drivers/cocoa/cocoa_common.m b/ui/drivers/cocoa/cocoa_common.m index 7313e10919..9d9ae21a8b 100644 --- a/ui/drivers/cocoa/cocoa_common.m +++ b/ui/drivers/cocoa/cocoa_common.m @@ -185,7 +185,7 @@ void cocoa_file_load_with_detect_core(const char *filename); */ self.controllerUserInteractionEnabled = YES; #endif - + #if TARGET_OS_IOS self.shouldLockCurrentInterfaceOrientation = NO; #endif @@ -227,51 +227,52 @@ void cocoa_file_load_with_detect_core(const char *filename); bool foundSiri = false; bool nonSiriPress = false; - for (GCController *controller in controllers) { - if ([self isSiri:controller]) - { - foundSiri = true; - if (type == UIPressTypeSelect) - return controller.microGamepad.buttonA.pressed; - else if (type == UIPressTypePlayPause) - return controller.microGamepad.buttonX.pressed; - } - else if (controller.extendedGamepad) - { - if (type == UIPressTypeUpArrow) - nonSiriPress |= controller.extendedGamepad.dpad.up.pressed - || controller.extendedGamepad.leftThumbstick.up.pressed - || controller.extendedGamepad.rightThumbstick.up.pressed; - else if (type == UIPressTypeDownArrow) - nonSiriPress |= controller.extendedGamepad.dpad.down.pressed - || controller.extendedGamepad.leftThumbstick.down.pressed - || controller.extendedGamepad.rightThumbstick.down.pressed; - else if (type == UIPressTypeLeftArrow) - nonSiriPress |= controller.extendedGamepad.dpad.left.pressed - || controller.extendedGamepad.leftShoulder.pressed - || controller.extendedGamepad.leftTrigger.pressed - || controller.extendedGamepad.leftThumbstick.left.pressed - || controller.extendedGamepad.rightThumbstick.left.pressed; - else if (type == UIPressTypeRightArrow) - nonSiriPress |= controller.extendedGamepad.dpad.right.pressed - || controller.extendedGamepad.rightShoulder.pressed - || controller.extendedGamepad.rightTrigger.pressed - || controller.extendedGamepad.leftThumbstick.right.pressed - || controller.extendedGamepad.rightThumbstick.right.pressed; - else if (type == UIPressTypeSelect) - nonSiriPress |= controller.extendedGamepad.buttonA.pressed; - else if (type == UIPressTypeMenu) - nonSiriPress |= controller.extendedGamepad.buttonB.pressed; - else if (type == UIPressTypePlayPause) - nonSiriPress |= controller.extendedGamepad.buttonX.pressed; - } - else - { - /* we have a remote that is not extended. some of these remotes send - * spurious presses. the only way to get them to work properly is to - * make the siri remote work improperly. */ - nonSiriPress = true; - } + for (GCController *controller in controllers) + { + if ([self isSiri:controller]) + { + foundSiri = true; + if (type == UIPressTypeSelect) + return controller.microGamepad.buttonA.pressed; + else if (type == UIPressTypePlayPause) + return controller.microGamepad.buttonX.pressed; + } + else if (controller.extendedGamepad) + { + if (type == UIPressTypeUpArrow) + nonSiriPress |= controller.extendedGamepad.dpad.up.pressed + || controller.extendedGamepad.leftThumbstick.up.pressed + || controller.extendedGamepad.rightThumbstick.up.pressed; + else if (type == UIPressTypeDownArrow) + nonSiriPress |= controller.extendedGamepad.dpad.down.pressed + || controller.extendedGamepad.leftThumbstick.down.pressed + || controller.extendedGamepad.rightThumbstick.down.pressed; + else if (type == UIPressTypeLeftArrow) + nonSiriPress |= controller.extendedGamepad.dpad.left.pressed + || controller.extendedGamepad.leftShoulder.pressed + || controller.extendedGamepad.leftTrigger.pressed + || controller.extendedGamepad.leftThumbstick.left.pressed + || controller.extendedGamepad.rightThumbstick.left.pressed; + else if (type == UIPressTypeRightArrow) + nonSiriPress |= controller.extendedGamepad.dpad.right.pressed + || controller.extendedGamepad.rightShoulder.pressed + || controller.extendedGamepad.rightTrigger.pressed + || controller.extendedGamepad.leftThumbstick.right.pressed + || controller.extendedGamepad.rightThumbstick.right.pressed; + else if (type == UIPressTypeSelect) + nonSiriPress |= controller.extendedGamepad.buttonA.pressed; + else if (type == UIPressTypeMenu) + nonSiriPress |= controller.extendedGamepad.buttonB.pressed; + else if (type == UIPressTypePlayPause) + nonSiriPress |= controller.extendedGamepad.buttonX.pressed; + } + else + { + /* we have a remote that is not extended. some of these remotes send + * spurious presses. the only way to get them to work properly is to + * make the siri remote work improperly. */ + nonSiriPress = true; + } } if (!foundSiri || [controllers count] == 1) @@ -332,13 +333,14 @@ void cocoa_file_load_with_detect_core(const char *filename); -(void)pressesEnded:(NSSet *)presses withEvent:(UIPressesEvent *)event { - for (UIPress *press in presses) { - if (press.type == UIPressTypeSelect || press.type == UIPressTypePlayPause) - [self sendKeyForPress:press.type down:false]; - else - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_MSEC), dispatch_get_main_queue(), ^{ + for (UIPress *press in presses) + { + if (press.type == UIPressTypeSelect || press.type == UIPressTypePlayPause) + [self sendKeyForPress:press.type down:false]; + else + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_MSEC), dispatch_get_main_queue(), ^{ [[CocoaView get] sendKeyForPress:press.type down:false]; - }); + }); } } @@ -578,22 +580,20 @@ void cocoa_file_load_with_detect_core(const char *filename); /* NOTE: This version runs on iOS6+. */ - (UIInterfaceOrientationMask)supportedInterfaceOrientations { - if (@available(iOS 16, *)) { - if (self.shouldLockCurrentInterfaceOrientation) { + if (@available(iOS 16, *)) + { + if (self.shouldLockCurrentInterfaceOrientation) return 1 << self.lockInterfaceOrientation; - } else { - return (UIInterfaceOrientationMask)apple_frontend_settings.orientation_flags; - } - } else { return (UIInterfaceOrientationMask)apple_frontend_settings.orientation_flags; } + return (UIInterfaceOrientationMask)apple_frontend_settings.orientation_flags; } /* NOTE: This does not run on iOS 16+ */ --(BOOL)shouldAutorotate { - if (self.shouldLockCurrentInterfaceOrientation) { +-(BOOL)shouldAutorotate +{ + if (self.shouldLockCurrentInterfaceOrientation) return NO; - } return YES; } diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index d9abaf3e18..c40c458857 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -458,7 +458,7 @@ static ui_application_t ui_application_cocoa = { CGFloat delta_x = event.deltaX; CGFloat delta_y = event.deltaY; NSPoint pos = CONVERT_POINT(); - cocoa_input_data_t + cocoa_input_data_t *apple = (cocoa_input_data_t*) input_state_get_ptr()->current_data; if (!apple) @@ -471,10 +471,13 @@ static ui_application_t ui_application_cocoa = { apple->touches[0].screen_x = (int16_t)pos.x; apple->touches[0].screen_y = (int16_t)pos.y; - if (apple->mouse_grabbed) { + if (apple->mouse_grabbed) + { apple->window_pos_x += (int16_t)delta_x; apple->window_pos_y += (int16_t)delta_y; - } else { + } + else + { apple->window_pos_x = (int16_t)pos.x; apple->window_pos_y = (int16_t)pos.y; } @@ -493,7 +496,7 @@ static ui_application_t ui_application_cocoa = { { NSInteger number = event.buttonNumber; NSPoint pos = CONVERT_POINT(); - cocoa_input_data_t + cocoa_input_data_t *apple = (cocoa_input_data_t*) input_state_get_ptr()->current_data; if (!apple || pos.y < 0) @@ -508,7 +511,7 @@ static ui_application_t ui_application_cocoa = { { NSInteger number = event.buttonNumber; NSPoint pos = CONVERT_POINT(); - cocoa_input_data_t + cocoa_input_data_t *apple = (cocoa_input_data_t*) input_state_get_ptr()->current_data; if (!apple || pos.y < 0) @@ -709,7 +712,7 @@ static ui_application_t ui_application_cocoa = { - (void)setVideoMode:(gfx_ctx_mode_t)mode { - BOOL is_fullscreen = (self.window.styleMask + BOOL is_fullscreen = (self.window.styleMask & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen; if (mode.fullscreen) { @@ -806,7 +809,7 @@ static ui_application_t ui_application_cocoa = { steam_poll(); #endif - while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.002, FALSE) + while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.002, FALSE) == kCFRunLoopRunHandledSource); if (ret == -1) { @@ -860,7 +863,7 @@ static ui_application_t ui_application_cocoa = { } else { - const ui_msg_window_t *msg_window = + const ui_msg_window_t *msg_window = ui_companion_driver_get_msg_window_ptr(); if (msg_window) { @@ -880,7 +883,7 @@ static void open_core_handler(ui_browser_window_state_t *state, bool result) { rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system; settings_t *settings = config_get_ptr(); - bool set_supports_no_game_enable = + bool set_supports_no_game_enable = settings->bools.set_supports_no_game_enable; if (!state || string_is_empty(state->result)) return; @@ -930,7 +933,7 @@ static void open_document_handler( - (IBAction)openCore:(id)sender { - const ui_browser_window_t *browser = + const ui_browser_window_t *browser = ui_companion_driver_get_browser_window_ptr(); if (browser) @@ -957,7 +960,7 @@ static void open_document_handler( - (void)openDocument:(id)sender { - const ui_browser_window_t *browser = + const ui_browser_window_t *browser = ui_companion_driver_get_browser_window_ptr(); if (browser) diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index c4df0f7661..0c893690a4 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -462,10 +462,11 @@ enum - (void)sendEvent:(UIEvent *)event { [super sendEvent:event]; - if (@available(iOS 13.4, tvOS 13.4, *)) { - if (event.type == UIEventTypeHover) - return; - } + if (@available(iOS 13.4, tvOS 13.4, *)) + { + if (event.type == UIEventTypeHover) + return; + } if (event.allTouches.count) handle_touch_event(event.allTouches.allObjects); @@ -479,16 +480,16 @@ enum /* Keyboard event hack for iOS versions prior to iOS 7. * * Derived from: - * http://nacho4d-nacho4d.blogspot.com/2012/01/ - * catching-keyboard-events-in-ios.html - */ + * http://nacho4d-nacho4d.blogspot.com/2012/01/ + * catching-keyboard-events-in-ios.html + */ const uint8_t *eventMem = objc_unretainedPointer([event performSelector:@selector(_gsEvent)]); int eventType = eventMem ? *(int*)&eventMem[8] : 0; switch (eventType) { case GSEVENT_TYPE_KEYDOWN: - case GSEVENT_TYPE_KEYUP: + case GSEVENT_TYPE_KEYUP: apple_input_keyboard_event(eventType == GSEVENT_TYPE_KEYDOWN, *(uint16_t*)&eventMem[0x3C], 0, 0, RETRO_DEVICE_KEYBOARD); break; @@ -509,17 +510,15 @@ enum - (instancetype)init { self = [super init]; - if (self) { + if (self) [self setupMetalLayer]; - } return self; } - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; - if (self) { + if (self) [self setupMetalLayer]; - } return self; } @@ -694,16 +693,16 @@ enum NSFileManager *fileManager = [NSFileManager defaultManager]; // Check if the file exists and rename it - if ([fileManager fileExistsAtPath:originalPath]) { + if ([fileManager fileExistsAtPath:originalPath]) + { NSError *error = nil; - if ([fileManager moveItemAtPath:originalPath toPath:newPath error:&error]) { + if ([fileManager moveItemAtPath:originalPath toPath:newPath error:&error]) NSLog(@"File renamed to %@", newPath); - } else { + else NSLog(@"Error renaming file: %@", error.localizedDescription); - } - } else { - NSLog(@"File does not exist at path %@", originalPath); } + else + NSLog(@"File does not exist at path %@", originalPath); } [self setDelegate:self]; @@ -874,7 +873,8 @@ enum NSString *destination = [NSString stringWithUTF8String:fullpath]; /* Copy file to documents directory if it's not already * inside Documents directory */ - if ([url startAccessingSecurityScopedResource]) { + if ([url startAccessingSecurityScopedResource]) + { if (![[url path] containsString: self.documentsDirectory]) if (![manager fileExistsAtPath:destination]) [manager copyItemAtPath:[url path] toPath:destination error:&error];