MCPcopy Create free account
hub / github.com/VCVRack/Rack / onMouseMove

Method onMouseMove

src/keyboard.cpp:183–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181 }
182
183 void onMouseMove(math::Vec pos) {
184 int16_t values[2];
185 values[0] = math::clamp((int) std::round(pos.x * 0x3f80), 0, 0x3f80);
186 // Flip Y values
187 values[1] = math::clamp((int) std::round((1.f - pos.y) * 0x3f80), 0, 0x3f80);
188
189 for (int id = 0; id < 2; id++) {
190 if (values[id] != lastValues[id]) {
191 // Continuous controller MSB
192 midi::Message m;
193 m.setStatus(0xb);
194 m.setNote(id);
195 m.setValue(values[id] >> 7);
196 onMessage(m);
197 // Continuous controller LSB
198 midi::Message m2;
199 m2.setStatus(0xb);
200 m2.setNote(id + 32);
201 m2.setValue(values[id] & 0x7f);
202 onMessage(m2);
203 lastValues[id] = values[id];
204 }
205 }
206 }
207};
208
209

Callers

nothing calls this directly

Calls 5

roundFunction · 0.85
setStatusMethod · 0.80
setNoteMethod · 0.80
clampFunction · 0.70
setValueMethod · 0.45

Tested by

no test coverage detected