Beispiel #1
0
bool MagicMNMPage::handleEvent(gui_event_t *event)  {
  if (BUTTON_DOWN(Buttons.BUTTON4)) {
    for (int i = Buttons.ENCODER1; i <= Buttons.ENCODER4; i++) {
      if (EVENT_PRESSED(event, i)) {
        GUI.setLine(GUI.LINE1);
        GUI.flash_string_fill("CLEAR");
        GUI.setLine(GUI.LINE2);
        GUI.flash_put_value(0, i);
        clearRecording(i);
        return true;
      }
    }
  }

  if (EVENT_PRESSED(event, Buttons.BUTTON2)) {
    setToCurrentTrack();
    return true;
  }
  if (EVENT_PRESSED(event, Buttons.BUTTON3)) {
    startRecording();
    return true;
  }
  if (EVENT_RELEASED(event, Buttons.BUTTON3)) {
    stopRecording();
    return true;
  }
  if (EVENT_PRESSED(event, Buttons.BUTTON4) || EVENT_RELEASED(event, Buttons.BUTTON4)) {
    return true;
  }

  return false;
}
Beispiel #2
0
 virtual bool handleEvent(gui_event_t *event) {
   // check buttons and encoders, small hack really, because all in one byte
   for (int i = 0; i < 8; i++) {
     if (EVENT_PRESSED(event, i) && buttonMask & _BV(i)) {
       pressedKey = i;
       hasPressedKey = true;
     }
     if (EVENT_RELEASED(event, i) && releaseMask & _BV(i)) {
       pressedKey = -1;
       hasPressedKey = true;
     }
   }
   return true;
 }
Beispiel #3
0
int poll_char(char *c)
{
	uint32_t event;
	while(poll_event(&event))
		if(!EVENT_RELEASED(event))
		{
			if(EVENT_CODE2(event) == 0 && scancodes[EVENT_CODE1(event)])
			{
				if(key_state[LSHIFT] & (1 << DOWN) || key_state[RSHIFT] & (1 << DOWN))
					*c = shift_scancodes[EVENT_CODE1(event)];
				else
					*c = scancodes[EVENT_CODE1(event)];
				return 1;
			}
		}
	return 0;
}
Beispiel #4
0
bool MagicSwitchPage::handleEvent(gui_event_t *event) {
  if (BUTTON_DOWN(Buttons.BUTTON4)) {
    if (EVENT_PRESSED(event, Buttons.BUTTON1)) {
      GUI.flash_strings_fill("CLEAR ALL", "");
      for (int i = 0; i < 4; i++) {
        magicPages[i].clearRecording();
      }
      return true;
    }
  }
  if (EVENT_PRESSED(event, Buttons.BUTTON2)) {
    MidiUart.printfString("SELECT PAGE");
    selectPage = true;
    redisplayPage();
    return true;
  }
  if (EVENT_RELEASED(event, Buttons.BUTTON2)) {
    selectPage = false;
    if (currentPage != NULL) {
      redisplayPage();
    }
    return true;
  }
  if (selectPage) {
    for (int i = Buttons.ENCODER1; i <= Buttons.ENCODER4; i++) {
      if (pages[i] != NULL && EVENT_PRESSED(event, i)) {
        setPage(pages[i]);
        return true;
      }
    }
    if (EVENT_PRESSED(event, Buttons.BUTTON1)) {
      setToCurrentTrack();
      return true;
    }
  }

  if (currentPage != NULL) {
    return currentPage->handleEvent(event);
  } 
  else {
    return false;
  }
}