MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / OnGridButton

Method OnGridButton

Source/StepSequencer.cpp:299–364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297}
298
299void StepSequencer::OnGridButton(int x, int y, float velocity, IGridController* grid)
300{
301 if (mPush2Connected || grid == mGridControlTarget->GetGridController())
302 {
303 bool press = velocity > 0;
304 if (x >= 0 && y >= 0)
305 {
306 Vec2i gridPos = ControllerToGrid(Vec2i(x, y));
307
308 if (grid != nullptr && grid->IsMultisliderGrid())
309 {
310 mGrid->SetVal(gridPos.x, gridPos.y, velocity);
311 }
312 else
313 {
314 if (press)
315 {
316 mHeldButtons.push_back(HeldButton(gridPos.x, gridPos.y));
317 float val = mGrid->GetVal(gridPos.x, gridPos.y);
318 if (val != mStrength)
319 mGrid->SetVal(gridPos.x, gridPos.y, mStrength);
320 else
321 mGrid->SetVal(gridPos.x, gridPos.y, 0);
322 }
323 else
324 {
325 for (auto iter = mHeldButtons.begin(); iter != mHeldButtons.end(); ++iter)
326 {
327 if (iter->mCol == gridPos.x && iter->mRow == gridPos.y)
328 {
329 mHeldButtons.erase(iter);
330 break;
331 }
332 }
333 }
334 }
335
336 UpdateLights();
337 UpdateVelocityLights();
338 UpdateMetaLights();
339 }
340 }
341 else if (grid == mVelocityGridController->GetGridController())
342 {
343 if (velocity > 0)
344 {
345 for (auto iter : mHeldButtons)
346 {
347 float strength = (8 - y) / 8.0f;
348 mGrid->SetVal(iter.mCol, iter.mRow, strength);
349 }
350 UpdateVelocityLights();
351 }
352 }
353 else if (grid == mMetaStepGridController->GetGridController())
354 {
355 if (velocity > 0)
356 {

Callers

nothing calls this directly

Calls 6

Vec2iClass · 0.85
HeldButtonClass · 0.85
GetGridControllerMethod · 0.80
IsMultisliderGridMethod · 0.80
SetValMethod · 0.80
GetValMethod · 0.80

Tested by

no test coverage detected