gint scorearea_enter_event (GtkWidget * widget, GdkEventCrossing * event) { dragging_outside = DRAG_DIRECTION_NONE; if(Denemo.keyboard_state_locked) return FALSE; //g_debug("start the enter with ks = %x and state %x\n", Denemo.keyboard_state, event->state); if (event->state & GDK_CONTROL_MASK) Denemo.keyboard_state |= GDK_CONTROL_MASK; else Denemo.keyboard_state &= ~GDK_CONTROL_MASK; if (event->state & GDK_SHIFT_MASK) Denemo.keyboard_state |= GDK_SHIFT_MASK; else Denemo.keyboard_state &= ~GDK_SHIFT_MASK; #if 0 //perhaps it would be better to clear Denemo.keyboard_state on focus out event??? if (event->state & GDK_MOD1_MASK) Denemo.keyboard_state |= GDK_MOD1_MASK; else Denemo.keyboard_state &= ~(CHORD_MASK | GDK_MOD1_MASK); #endif // g_debug("end the enter with ks %x (values %x %x)\n", event->state, ~GDK_CONTROL_MASK, Denemo.keyboard_state & (~GDK_CONTROL_MASK) ); set_midi_in_status (); return FALSE; //allow other handlers }
gint scorearea_keypress_event (GtkWidget * widget, GdkEventKey * event) { if(!Denemo.keyboard_state_locked) { Denemo.keyboard_state |= (0xf & klock_mask (event->keyval)); Denemo.keyboard_state ^= llock_mask (event->keyval); // if((event->keyval==GDK_Alt_L)||(event->keyval==GDK_Alt_R)) // Denemo.keyboard_state |= CHORD_MASK; set_midi_in_status (); } //g_print("press Denemo %x state %x klock %x\n", Denemo.keyboard_state, event->state, klock_mask(event->keyval)); //g_debug("State eored %x\n", (lock_mask(event->keyval)^event->state)); if (divert_key_event && !isModifier (event) && divert_key_id == Denemo.project->id) { dnm_clean_event (event); *divert_key_event = event; //g_object_ref(event); FIXME do we need to keep it around? gtk_main_quit (); return TRUE; //*is* reached main loop exits to the caller of the loop when it next gains control } (void) process_key_event (event, perform_command); return TRUE; //I think this means do not run any other handlers after this. }
static void do_one_note (gint mid_c_offset, gint enshift, gint notenum) {//g_print("do one note Adding mask %x, Chord mask %x\n", (Denemo.keyboard_state & ADDING_MASK) , (Denemo.keyboard_state & CHORD_MASK)); if ((Denemo.keyboard_state & ADDING_MASK) && (Denemo.keyboard_state & CHORD_MASK)) { add_or_delete_note_to_chord (mid_c_offset, enshift, notenum); } else { DenemoObject *curobj = NULL; //check for non-printing notes - back up to the first non-printing note. gboolean non_printing_note = FALSE; PushPosition (NULL, NULL); while (cursor_to_prev_note ()) { curobj = Denemo.project->movement->currentobject->data; if (!curobj->isinvisible) break; else non_printing_note = TRUE; } if (Denemo.project->movement->currentobject) { curobj = Denemo.project->movement->currentobject->data; if (non_printing_note) { if (!curobj->isinvisible) cursor_to_next_note (); (void)pop_position ();//Discard the pushed position } else PopPosition (NULL, NULL);// go to where we started, as there are no non-printing notes } else PopPosition (NULL, NULL);// go to where we started, as there are no non-printing notes action_note_into_score (mid_c_offset, enshift, notenum); if (Denemo.keyboard_state & ADDING_MASK) Denemo.keyboard_state |= CHORD_MASK; set_midi_in_status (); } }
gint scorearea_keyrelease_event (GtkWidget * widget, GdkEventKey * event) { if(!Denemo.keyboard_state_locked) { Denemo.keyboard_state ^= (0xf & klock_mask (event->keyval)); if ((event->keyval == GDK_Alt_L) || (event->keyval == GDK_Alt_R)) { if ((Denemo.keyboard_state & CHORD_MASK)) //At least one note has been entered in a chord next_insert_or_editable_note (); Denemo.keyboard_state &= ~CHORD_MASK; } set_midi_in_status (); } //g_print("release %x state %x\n", Denemo.keyboard_state, event->state); // set_cursor_for(keyrelease_modify(event->state), event->keyval); gint state; if ((event->keyval == GDK_Caps_Lock) || (event->keyval == GDK_Num_Lock)) return TRUE; state = (lock_mask (event->keyval) ^ event->state); set_cursor_for (state); return TRUE; }
void process_midi_event (gchar * buf) { if (command == MIDI_CONTROL_CHANGE && (notenumber == 0x40)) { if (velocity == 0x7F) {//PEDAL DOWN if (Denemo.project->movement->cursor_appending || at_nonprinting ()) Denemo.keyboard_state |= ADDING_MASK; else Denemo.keyboard_state |= CHORD_MASK | ADDING_MASK; } else { Denemo.keyboard_state &= ~(CHORD_MASK | ADDING_MASK); next_insert_or_editable_note();//next_insert_or_editable_note (); } set_midi_in_status (); displayhelper (Denemo.project); } if ((0xFFFFFF & *(gint *) buf) == 0) { set_midi_capture (FALSE); g_queue_clear (&midi_queue); if (divert_midi_event) { *divert_midi_event = 0; divert_midi_event = NULL; gtk_main_quit (); } //g_debug("queue emptied %d\n", g_queue_get_length(&midi_queue)); } else { if (command == MIDI_NOTE_ON) midiaction (notenumber); else if (command == MIDI_CONTROL_CHANGE) { gchar *command_name = get_midi_control_command (notenumber, velocity); if (command_name) { execute_callback_from_name (command_name); g_free (command_name); } else { if (notenumber == 0x40) { //Foot Pedal if (velocity == 0x7F) { if ((Denemo.project->movement->cursor_appending) || at_nonprinting ()) Denemo.keyboard_state |= ADDING_MASK; else Denemo.keyboard_state |= CHORD_MASK | ADDING_MASK; } else { Denemo.keyboard_state &= ~(CHORD_MASK | ADDING_MASK); //next_editable_note (); this causes a double advance... } set_midi_in_status (); displayhelper (Denemo.project); } } } else if (command == MIDI_PITCH_BEND) { gchar *command_name = get_midi_pitch_bend_command ((notenumber << 8) + velocity); if (command_name) { execute_callback_from_name (command_name); g_free (command_name); } } } }