From 86a914ed7bf5316cad6dcac5f69cc3b300b40a23 Mon Sep 17 00:00:00 2001
From: David Robillard <d@drobilla.net>
Date: Thu, 18 Aug 2022 01:16:43 -0400
Subject: Fix control binding value computation

---
 src/gui/.clang-tidy            |  1 -
 src/server/.clang-tidy         |  1 -
 src/server/ControlBindings.cpp | 13 ++++++++-----
 3 files changed, 8 insertions(+), 7 deletions(-)

(limited to 'src')

diff --git a/src/gui/.clang-tidy b/src/gui/.clang-tidy
index e258f145..775b8cd7 100644
--- a/src/gui/.clang-tidy
+++ b/src/gui/.clang-tidy
@@ -18,7 +18,6 @@ Checks: >
   -bugprone-macro-parentheses,
   -bugprone-parent-virtual-call,
   -bugprone-reserved-identifier,
-  -bugprone-signed-char-misuse,
   -bugprone-suspicious-string-compare,
   -cert-dcl21-cpp,
   -cert-dcl37-c,
diff --git a/src/server/.clang-tidy b/src/server/.clang-tidy
index deab7090..b309c823 100644
--- a/src/server/.clang-tidy
+++ b/src/server/.clang-tidy
@@ -16,7 +16,6 @@ Checks: >
   -bugprone-easily-swappable-parameters,
   -bugprone-parent-virtual-call,
   -bugprone-reserved-identifier,
-  -bugprone-signed-char-misuse,
   -bugprone-suspicious-string-compare,
   -cert-dcl37-c,
   -cert-dcl51-cpp,
diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp
index 8ae4f7c2..60684440 100644
--- a/src/server/ControlBindings.cpp
+++ b/src/server/ControlBindings.cpp
@@ -124,17 +124,20 @@ ControlBindings::midi_event_key(uint16_t, const uint8_t* buf, uint16_t& value)
 {
 	switch (lv2_midi_message_type(buf)) {
 	case LV2_MIDI_MSG_CONTROLLER:
-		value = static_cast<int8_t>(buf[2]);
+		value = buf[2];
 		return {Type::MIDI_CC, static_cast<int8_t>(buf[1])};
 	case LV2_MIDI_MSG_BENDER:
-		value = (static_cast<int8_t>(buf[2]) << 7) + static_cast<int8_t>(buf[1]);
+		value = (buf[2] << 7U) + buf[1];
 		return {Type::MIDI_BENDER};
 	case LV2_MIDI_MSG_CHANNEL_PRESSURE:
-		value = static_cast<int8_t>(buf[1]);
+		value = buf[1];
 		return {Type::MIDI_CHANNEL_PRESSURE};
 	case LV2_MIDI_MSG_NOTE_ON:
-		value = 1.0f;
-		return {Type::MIDI_NOTE, static_cast<int8_t>(buf[1])};
+		value = 1;
+		return {Type::MIDI_NOTE, buf[1]};
+	case LV2_MIDI_MSG_NOTE_OFF:
+		value = 0;
+		return {Type::MIDI_NOTE, buf[1]};
 	default:
 		return {};
 	}
-- 
cgit v1.2.1