Exemplo n.º 1
0
// check if any keys or buttons1 are pressed
bool
any_key_pressed (void)
{
  int i;
  bool ret = FALSE;

  update_input();

  for (i=0; i<KEY_PACK(SDLK_LAST); i++)
    if ( just_pressed(input_state[i]) )
      { 
	clear_fresh(input_state[i]);
	ret = TRUE; 
	break;
      }
  if ( just_pressed(input_state[KEY_PACK(JOY_BUTTON1)]) )
    {
      clear_fresh (input_state[KEY_PACK(JOY_BUTTON1)]);
      ret = TRUE;
    }

  if ( just_pressed(input_state[KEY_PACK(MOUSE_BUTTON1)]) )
    {
      ret = TRUE;
      clear_fresh (input_state[KEY_PACK(MOUSE_BUTTON1)]);
    }

  return (ret);

}  // any_key_pressed()
Exemplo n.º 2
0
void do_keyboard_mode(void) {
  signed int shift = 0;
  uint8_t accent=0, slide=0;
  uint8_t i, last_bank;
  
  // turn tempo off!
  turn_off_tempo();
  
  clear_bank_leds();

  read_switches();
  last_bank = bank;
  has_bank_knob_changed(); // ignore startup change

  while (1) {
    read_switches();

    if (function_changed) {
      midi_notesoff();           // turn all notes off
      return;
    }
  
    // show the current MIDI address
    if (!is_bank_led_set(midi_out_addr)) {
      clear_bank_leds();
      set_bank_led(midi_out_addr);
    }

    if (has_bank_knob_changed()) {
      // bank knob was changed, which means they want a different
      // midi addr... OK then!
      midi_out_addr = bank;

      // set the new midi address (burn to EEPROM)
      internal_eeprom_write8(MIDIOUT_ADDR_EEADDR, midi_out_addr);

      last_bank = bank;
    }

    // show the octave
    display_octave_shift(shift);

    for (i=0; i<13; i++) {
      // check if any notes were just pressed
      if (just_pressed(notekey_tab[i])) {
	note_on((C2+i) + shift*OCTAVE, slide, accent);
	midi_send_note_on( ((C2+i) + shift*OCTAVE) | (accent << 6));
	slide = TRUE;

	// turn on that LED
	set_notekey_led(i);	
      }
      
      // check if any notes were released
      if (just_released(notekey_tab[i])) {
	midi_send_note_off( ((C2+i) + shift*OCTAVE) | (accent << 6));

	// turn off that LED
	clear_notekey_led(i);
      }
    }

    if (just_pressed(KEY_UP)) {
      if (shift < 2)
	shift++;
    } else if (just_pressed(KEY_DOWN)) {
      if (shift > -1)
	shift--;
    } 

    // check if they turned accent on
    if (just_pressed(KEY_ACCENT)) {
      accent = !accent;
      if (accent)
	set_led(LED_ACCENT);
      else
	clear_led(LED_ACCENT);
    }
    
    // if no keys are held down and there was a note just playing
    // turn off the note.
    if ((NOTE_PIN & 0x3F) && no_keys_pressed()) {
      note_off(0);
      slide = FALSE;
      clear_notekey_leds();
    }
  }
}