shithub: m8c

Download patch

ref: cdc9ef11d2f4c1fee5fb757ead0e8ab8f965b6c0
parent: 6d50e07ce6724df51bf1d628acd40e1f9648403e
author: hayabusa <s.hashimoto@hs-sh.net>
date: Fri May 27 17:05:24 EDT 2022

add NoteOff to keyjazz

--- a/input.c
+++ b/input.c
@@ -91,7 +91,7 @@
 }
 
 static input_msg_s handle_keyjazz(SDL_Event *event, uint8_t keyvalue) {
-  input_msg_s key = {keyjazz, keyvalue};
+  input_msg_s key = {keyjazz, keyvalue, event->type};
   switch (event->key.keysym.scancode) {
   case SDL_SCANCODE_Z:
     key.value = keyjazz_base_octave * 12;
--- a/input.h
+++ b/input.h
@@ -32,6 +32,7 @@
 typedef struct input_msg_s {
   input_type_t type;
   uint8_t value;
+  uint32_t eventType;
 } input_msg_s;
 
 void close_game_controllers();
--- a/main.c
+++ b/main.c
@@ -72,6 +72,7 @@
   #endif
 
   uint8_t prev_input = 0;
+  uint8_t prev_note = 0;
 
   // main loop
   while (run) {
@@ -87,14 +88,15 @@
       }
       break;
     case keyjazz:
-      if (input.value != prev_input) {
-        prev_input = input.value;
-        if (input.value != 0) {
+      if (input.value != 0) {
+        if (input.eventType == SDL_KEYDOWN && input.value != prev_input) {
           send_msg_keyjazz(port, input.value, 0xFF);
-        } else {
-          send_msg_keyjazz(port, 0, 0);
+          prev_note = input.value;
+        } else if (input.eventType == SDL_KEYUP && input.value == prev_note) {
+          send_msg_keyjazz(port, 0xFF, 0);
         }
       }
+      prev_input = input.value;
       break;
     case special:
       if (input.value != prev_input) {
--