global mouse moved to state and removed some GetMousePosition()s.

This commit is contained in:
Sebastian
2024-11-14 01:37:16 +01:00
parent 5d3b72d4ef
commit 2e103dc561
10 changed files with 58 additions and 60 deletions
+30 -25
View File
@@ -1,6 +1,7 @@
#pragma once
#include "datatypes.h"
#include "graph-item.h"
#include "node.h"
#include "raymath.h"
#include <map>
@@ -12,7 +13,8 @@ namespace VISEQ::GRAPH::NODES {
class MidiNode : public Node{
public:
using GraphItem::state;
struct NodeMidiOut{
int i;
std::string name;
@@ -65,8 +67,8 @@ namespace VISEQ::GRAPH::NODES {
virtual NodeType getNodeType() const override {return nodeType;}
void setMidiPort(int midi_port, bool state){
midi_outs[midi_port].enabled = state;
void setMidiPort(int midi_port, bool _state){
midi_outs[midi_port].enabled = _state;
}
void trigger() override {
@@ -83,49 +85,50 @@ namespace VISEQ::GRAPH::NODES {
return midi_gate;
}
void interact(){
float wheel = GetMouseWheelMove();
if(IsKeyDown(KEY_LEFT_CONTROL) && !IsKeyDown(KEY_LEFT_ALT)){
switch(state->settings.mode){
switch(GraphItem::state->node_mode){
case 0:{
midiNode->midi_note += wheel;
midi_note += wheel;
break;}
case 1:{
midiNode->midi_cc += wheel;
midi_cc += wheel;
break;}
case 2:{
midiNode->midi_pitch_bend += wheel;
midi_pitch_bend += wheel;
break;}
};
if(midiNode->midi_note < 0 ) midiNode->midi_note = VISEQ::MIDI::Notes.size()-1;
if(midiNode->midi_note >= VISEQ::MIDI::Notes.size() ) midiNode->midi_note = 0;
if(midi_note < 0 ) midi_note = VISEQ::MIDI::Notes.size()-1;
if(midi_note >= VISEQ::MIDI::Notes.size() ) midi_note = 0;
if(midiNode->midi_cc < 0 ) midiNode->midi_cc = 127;
if(midiNode->midi_cc > 127 ) midiNode->midi_cc = 0;
if(midi_cc < 0 ) midi_cc = 127;
if(midi_cc > 127 ) midi_cc = 0;
if(midiNode->midi_pitch_bend < 0 ) midiNode->midi_pitch_bend = 0;
if(midiNode->midi_pitch_bend > 16383 ) midiNode->midi_pitch_bend = 16383;
if(midi_pitch_bend < 0 ) midi_pitch_bend = 0;
if(midi_pitch_bend > 16383 ) midi_pitch_bend = 16383;
} else if(IsKeyDown(KEY_LEFT_SHIFT) && !IsKeyDown(KEY_LEFT_ALT)) {
midiNode->midi_velocity += wheel;
if(midiNode->midi_velocity < 0 ) midiNode->midi_velocity = 127;
if(midiNode->midi_velocity > 127 ) midiNode->midi_velocity = 0;
midi_velocity += wheel;
if(midi_velocity < 0 ) midi_velocity = 127;
if(midi_velocity > 127 ) midi_velocity = 0;
} else if(IsKeyDown(KEY_LEFT_ALT)) {
switch(state->settings.mode){
switch(GraphItem::state->node_mode){
case 0:{
float incr = (float)wheel * (IsKeyDown(KEY_LEFT_SHIFT) ? 100.0f : IsKeyDown(KEY_LEFT_CONTROL) ? 1000.0f : 10.0f);
midiNode->midi_gate += incr;
if(midiNode->midi_gate < 0 ) midiNode->midi_gate = 0;
midi_gate += incr;
if(midi_gate < 0 ) midi_gate = 0;
break;}
case 1:{
midiNode->midi_cc_value += wheel;
if(midiNode->midi_cc_value < 0 ) midiNode->midi_cc_value = 0;
if(midiNode->midi_cc_value > 127 ) midiNode->midi_cc_value = 127;
midi_cc_value += wheel;
if(midi_cc_value < 0 ) midi_cc_value = 0;
if(midi_cc_value > 127 ) midi_cc_value = 127;
break;}
case 2:{
float incr = (float)wheel * (IsKeyDown(KEY_LEFT_SHIFT) ? 100.0f : IsKeyDown(KEY_LEFT_CONTROL) ? 1000.0f : 10.0f);
midiNode->midi_pitch_bend += incr;
if(midiNode->midi_pitch_bend < 0 ) midiNode->midi_pitch_bend = 0;
if(midiNode->midi_pitch_bend > 16383 ) midiNode->midi_pitch_bend = 16383;
midi_pitch_bend += incr;
if(midi_pitch_bend < 0 ) midi_pitch_bend = 0;
if(midi_pitch_bend > 16383 ) midi_pitch_bend = 16383;
break;}
};
}
@@ -133,6 +136,8 @@ namespace VISEQ::GRAPH::NODES {
void draw(Vec2Df mouse, Camera2D cam) override {
Node::draw();
interact();
last = time;
time = GetTime();
if(time - start >= (float)midi_gate / 1000.0f){