Skip to content

Commit

Permalink
Fix some constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
linuscu committed Sep 5, 2024
1 parent deaf63e commit 123ae2d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/hid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ project (hid)
set(deps
logging
testing

math
)

bs_generate_package(hid "tier1" "${deps}" "")
14 changes: 8 additions & 6 deletions packages/hid/source/common/KeyboardPiano.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "hid/KeyboardPiano.h"

#include "math/MathConstants.h"

#include <memory>

namespace l::hid {
Expand Down Expand Up @@ -29,14 +31,14 @@ namespace l::hid {
}
else {
int32_t note = ConvertKeyCodeToNote(keyCode, mOctave);
if (note > -INT_MIN) {
if (note > -l::math::constants::INTMIN) {
noteHandler(note, true);
}
}
}
if (releasedNow) {
int32_t note = ConvertKeyCodeToNote(keyCode, mOctave);
if (note > -INT_MIN) {
if (note > -l::math::constants::INTMIN) {
noteHandler(note, false);
}
}
Expand Down Expand Up @@ -64,14 +66,14 @@ namespace l::hid {
}
else {
int32_t note = ConvertKeyCodeToNote(keyCode, mOctave);
if (note > -INT_MIN) {
if (note > -l::math::constants::INTMIN) {
mNotePlayer->NoteOn(note);
}
}
}
if (releasedNow) {
int32_t note = ConvertKeyCodeToNote(keyCode, mOctave);
if (note > -INT_MIN) {
if (note > -l::math::constants::INTMIN) {
mNotePlayer->NoteOff(note);
}
}
Expand All @@ -84,15 +86,15 @@ namespace l::hid {
if (key > 0) {
return key + octave * 12;
}
return -INT_MIN;
return -l::math::constants::INTMIN;
}

int32_t KeyboardPiano::ConvertCharCodeToNote(int32_t charCode, int32_t octave) {
auto key = mCharCodeToNote[charCode];
if (key > 0) {
return key + octave * 12;
}
return -INT_MIN;
return -l::math::constants::INTMIN;
}

void KeyboardPiano::MapKeyFunctions(KeyFunctionTypes function, int32_t keyCode) {
Expand Down

0 comments on commit 123ae2d

Please sign in to comment.