Esempio n. 1
0
File: Input.cpp Progetto: ljkd/SAGE
bool Input::IsMouseHeld(int button)
{
	if (BUTTON_DOWN(m_mouseState, button) && BUTTON_DOWN(m_lastMouseState, button))
		return true;

	return false;
}
Esempio n. 2
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;
}
Esempio n. 3
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;
  }
}
Esempio n. 4
0
void ButtonsClass::poll(uint8_t but) {
  uint8_t but_tmp = but;

  for (uint8_t i = 0; i < GUI_NUM_BUTTONS; i++) {
    STORE_B_CURRENT(i, IS_BIT_SET8(but_tmp, 0));

    if (BUTTON_PRESSED(i)) {
      B_PRESS_TIME(i) =  slowclock;
      
      if (B_PRESSED_ONCE(i)) {
	uint16_t diff = clock_diff(B_LAST_PRESS_TIME(i), B_PRESS_TIME(i));
	if (diff < DOUBLE_CLICK_TIME) {
	  SET_B_DOUBLE_CLICK(i);
	  CLEAR_B_PRESSED_ONCE(i);
	}
      } else {
	B_LAST_PRESS_TIME(i) = B_PRESS_TIME(i);
	SET_B_PRESSED_ONCE(i);
      }
    }
    
    if (BUTTON_DOWN(i) && B_PRESSED_ONCE(i)) {
      uint16_t diff = clock_diff(B_LAST_PRESS_TIME(i), slowclock);
      if (diff > LONG_CLICK_TIME) {
	SET_B_LONG_CLICK(i);
	CLEAR_B_PRESSED_ONCE(i);
      }
    }

    if (BUTTON_UP(i) && B_PRESSED_ONCE(i)) {
      uint16_t diff = clock_diff(B_LAST_PRESS_TIME(i), slowclock);
      if (diff > LONG_CLICK_TIME) {
	CLEAR_B_PRESSED_ONCE(i);
      } else if (diff > DOUBLE_CLICK_TIME) {
	CLEAR_B_PRESSED_ONCE(i);
	SET_B_CLICK(i);
      }
    }

    but_tmp >>= 1;
  }
}
int MouseButton (int button) {
    return BUTTON_DOWN(mouseState, button);
}
Esempio n. 6
0
void EncodersClass::poll(uint16_t sr) {
  uint16_t sr_tmp = sr;
  
  for (uint8_t i = 0; i < GUI_NUM_ENCODERS; i++) {
    uint8_t sr2 = sr & 3;
    uint8_t sro2 = sr_old & 3;

    if (sr2 != sro2) {
      /*
	LCD.line1();
      LCD.putnumber(sr2);
      LCD.puts(" ");
      LCD.putnumber(sro2);
      LCD.puts(" ");
      LCD.putnumber(sr_old2s[i]);
      */
      
      volatile int8_t *val = &(ENCODER_NORMAL(i));
      
      if (BUTTON_DOWN(i)) {
	  val = &(ENCODER_BUTTON(i));
      }

	
#if 1
      if ((sr2 == 0 && sro2 == 1 && sr_old2s[i] != ENCODER_FIX_MINUS_1) ||
	  (sr2 == 3 && sro2 == 0 && sr_old2s[i] != ENCODER_FIX_MINUS_0)) {
	if (*val > -64)
	  (*val)--;
	if (sro2 == 1)
	  sr_old2s[i] = ENCODER_FIX_MINUS_1;
	if (sro2 == 0)
	  sr_old2s[i] = ENCODER_FIX_MINUS_0;
      } else if ((sr2 == 0 && sro2 == 3 && sr_old2s[i] != ENCODER_FIX_PLUS_3) ||
		 (sr2 == 3 && sro2 == 1 && sr_old2s[i] != ENCODER_FIX_PLUS_1)) {
	if (*val < 64)
	  (*val)++;
	if (sro2 == 1)
	  sr_old2s[i] = ENCODER_FIX_PLUS_1;
	if (sro2 == 3)
	  sr_old2s[i] = ENCODER_FIX_PLUS_3;
      }
#endif
    }
#if 0
      if( i== 0) {
	uint8_t sr0 = IS_BIT_SET(sr, 0);
	uint8_t sr1 = IS_BIT_SET(sr, 1);
	uint8_t sro0 = IS_BIT_SET(sr_old, 0);
	uint8_t sro1 = IS_BIT_SET(sr_old, 1);

	if (sr2 != sro2) {
	  static uint8_t val = 100;
	  
	  LCD.line2();
	  if (sr2 == 3) {
	    if (sro2 == 0) {
	      LCD.puts("LEFT ");
	      val--;
	    } else if (sro2 == 1) {
	      LCD.puts("RIGHT");
	      val++;
	    }
	  } else if ((sr2 == 1)  && (sro2 == 3)) {
	      LCD.puts("LEFT ");
	      val--;
	  } else if (sr2 == 0) {
	    if (sro2 == 3) {
	      LCD.puts("RIGHT");
	      val++;
	    }
	  }

	  LCD.line1();
	  //	  LCD.putnumberx(IS_BIT_SET8(sr, 0));
	  //	  LCD.putnumberx(IS_BIT_SET8(sr, 1));
	  //	  LCD.putnumberx(IS_BIT_SET8(sr_old, 0));
	  //	  LCD.putnumberx(IS_BIT_SET8(sr_old, 1));
	  LCD.putnumberx(sr2);
	  LCD.putnumberx( sro2);

	  LCD.puts(" ");
	  LCD.putnumber(val);
	}
      }
#endif
    sr >>= 2;
    sr_old >>= 2;
  }

  sr_old = sr_tmp;
}