Skip to content

Commit

Permalink
add fallback color for scenes
Browse files Browse the repository at this point in the history
  • Loading branch information
YeonV committed Oct 5, 2024
1 parent 84e42d0 commit a2cafac
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/Midi/MidiListener.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const MIDIListener = () => {
const toggleScenePLplay = useStore((state) => state.toggleScenePLplay)
const [bright, setBright] = useState(1)
const scenes = useStore((state) => state.scenes)
const midiSceneInactiveColor = useStore((state) => state.midiColors.sceneInactiveColor)
const midiSceneActiveColor = useStore((state) => state.midiColors.sceneActiveColor)
const activateScene = useStore((state) => state.activateScene)
const captivateScene = useStore((state) => state.captivateScene)
const setSmartBarOpen = useStore(
Expand Down Expand Up @@ -235,7 +237,7 @@ const MIDIListener = () => {
} else if (value.command === 'scene') {
if (output && buttonNumber !== -1) {
try {
output.send([parseInt(`0x${value.typeSceneInactive}`) || 0x90, buttonNumber, parseInt(value.colorSceneInactive, 16) || 60])
output.send([parseInt(`0x${value.typeSceneInactive}`) || 0x90, buttonNumber, parseInt(value.colorSceneInactive || midiSceneInactiveColor, 16) || 60])
} catch (error) {
console.error('Error sending MIDI message:', error)
}
Expand All @@ -252,15 +254,15 @@ const MIDIListener = () => {
if (key === scene_id) {
if (output && buttonNumber !== -1) {
if (!Number.isNaN(buttonNumber)) {
output.send([parseInt(`0x${midiMapping[0][buttonNumber]?.typeSceneActive}`) || 0x90, buttonNumber, parseInt(midiMapping[0][buttonNumber]?.colorSceneActive || '1E', 16)])
output.send([parseInt(`0x${midiMapping[0][buttonNumber]?.typeSceneActive}`) || 0x90, buttonNumber, parseInt(midiMapping[0][buttonNumber]?.colorSceneActive || midiSceneActiveColor || '1E', 16)])
}
} else {
console.error('No MIDI output devices found')
}
} else {
if (output && buttonNumber !== -1) {
if (!Number.isNaN(buttonNumber)) {
output.send([parseInt(`0x${midiMapping[0][buttonNumber]?.typeSceneInactive}`) || 0x90, buttonNumber, parseInt(midiMapping[0][buttonNumber]?.colorSceneInactive || '3C', 16)])
output.send([parseInt(`0x${midiMapping[0][buttonNumber]?.typeSceneInactive}`) || 0x90, buttonNumber, parseInt(midiMapping[0][buttonNumber]?.colorSceneInactive || midiSceneInactiveColor || '3C', 16)])
}
} else {
console.error('No MIDI output devices found')
Expand Down

0 comments on commit a2cafac

Please sign in to comment.