shithub: m8c

Download patch

ref: 99f90a25e4d3c5b9f5895c6cc7aa4b326b774d8b
parent: 587e3dbdd9e05591f3e360a08308ed4dc8409e5b
author: Jonne Kokkonen <jonne.kokkonen@gmail.com>
date: Mon Apr 7 10:39:58 EDT 2025

- show an error message dialog if RTMIDI is enabled and device does not respond to sysex messages

--- a/src/backends/m8_rtmidi.c
+++ b/src/backends/m8_rtmidi.c
@@ -212,7 +212,9 @@
   const Uint64 timer_wait_for_response = SDL_GetTicks();
   while (!midi_sysex_received) {
     if (SDL_GetTicks() - timer_wait_for_response > 1000) {
-      SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM,"No response from device. Please make sure you're using M8 firmware 6.0.0 or newer.");
+      SDL_LogCritical(
+          SDL_LOG_CATEGORY_SYSTEM,
+          "No response from device. Please make sure you're using M8 firmware 6.0.0 or newer.");
       close_and_free_midi_ports();
       return 0;
     }
--- a/src/main.c
+++ b/src/main.c
@@ -94,6 +94,10 @@
           SDL_LogCritical(SDL_LOG_CATEGORY_ERROR, "Device not detected.");
           app_state = QUIT;
           screensaver_destroy();
+#ifdef USE_RTMIDI
+          show_error_message("Cannot initialize M8 remote display. Make sure you're running "
+                             "firmware 6.0.0 or newer.");
+#endif
         }
       }
     }
--- a/src/render.c
+++ b/src/render.c
@@ -57,7 +57,7 @@
           "m8c", texture_width * 2, texture_height * 2,
           SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY | init_fullscreen, &win, &rend)) {
     SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window and renderer: %s",
-                 SDL_GetError());
+                    SDL_GetError());
     return false;
   }
 
@@ -355,4 +355,8 @@
 void fix_texture_scaling_after_window_resize(void) {
   SDL_SetRenderTarget(rend, NULL);
   SDL_SetRenderLogicalPresentation(rend, texture_width, texture_height, scaling_mode);
+}
+
+void show_error_message(const char *message) {
+  SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "m8c error", message, win);
 }
\ No newline at end of file
--- a/src/render.h
+++ b/src/render.h
@@ -20,6 +20,8 @@
 void toggle_fullscreen();
 void display_keyjazz_overlay(uint8_t show, uint8_t base_octave, uint8_t velocity);
 
+void show_error_message(const char *message);
+
 void screensaver_init();
 void screensaver_draw();
 void screensaver_destroy();
--