int key_unselect_ch()
{
reset_numeric_entry();

//if ((key_shifts & KB_SHIFT_FLAG  || index_false_shift==1))
if(key[KEY_LSHIFT]|| index_false_shift==1)
{
             if( index_patch_window==1 && index_ask_confirm==0)
             {
             patch_unselect_all_dimmers();
             strcpy(string_monitor_patch,"");
             index_patch_affect_is_done=0;
             }
}


else
{

             for (int ci=1;ci<514;ci++)
             {Selected_Channel[ci]=0;}
             last_ch_selected=0;
             index_type=0;index_level_attribue=0;
             substract_channel_selection_to_layers_plot();


             if(index_ask_confirm==1)
             {
             reset_indexs_confirmation();
             reset_index_actions();
             substract_a_window(W_ASKCONFIRM);
             window_focus_id=previous_window_focus_id;
             add_a_window(window_focus_id);
             }
}

return(0);
}
int affect_dmx_in(int callb_x, int callb_y)
{
Rect MonCallButton(Vec2D(callb_x,callb_y),Vec2D(100,30));
MonCallButton.SetRoundness(7.5);
MonCallButton.SetLineWidth(demi_epaisseur_ligne_fader);

MonCallButton.DrawOutline(CouleurLigne);
//affichage boutons

if (index_affect_dmxin==1)
{
MonCallButton.Draw(CouleurFader);
MonCallButton.DrawOutline(CouleurFader);
}
petitchiffre.Print("DmxIn>Dock",callb_x+5, callb_y+20);
if(window_focus_id==W_CFGMENU && mouse_x>callb_x && mouse_x<callb_x+100 && mouse_y>callb_y && mouse_y<callb_y+30 && window_focus_id==920)
{
if(mouse_button==1 && mouse_released==0)
{
 if(index_affect_dmxin==0)
{
reset_index_actions();
reset_indexs_confirmation();
index_affect_dmxin=1;
}
else
{
reset_index_actions();
}
index_do_dock=index_affect_dmxin;
mouse_released=1;
}
}

return(0);
}
int do_logical_Interface_Trichromie(int xchroma, int ychroma, int rayon, int largeurchroma)
{

/////////////////TRICHRO / QUADRI CHOOSE//////////////////////////////////////

if(mouse_x>xchroma-60 && mouse_x<xchroma+80 && mouse_y>ychroma-190 && mouse_y<ychroma-160)
{

if(index_quadri==0){index_quadri=1;dock_color_type[dock_color_selected]=1;}
else if(index_quadri==1){index_quadri=0;dock_color_type[dock_color_selected]=0;}
mouse_released=1;
}


//GEL LIST BUTTON
if(mouse_x>xchroma+90 && mouse_x<xchroma+150 && mouse_y>ychroma-185 && mouse_y<ychroma-165)
{
show_gel_list=toggle(show_gel_list);
mouse_released=1;
}

/////////////////////AFFECTATION ON / OFF AUX DOCKS FADERS///////////////////////////

if(mouse_x>xchroma+20 && mouse_x<xchroma+150 && mouse_y>ychroma+300 && mouse_y< ychroma+330)
{
if(index_affect_color_to_dock==0)
{
reset_index_actions();
reset_indexs_confirmation();
index_affect_color_to_dock=1;
}
else
{
reset_index_actions();
}
index_do_dock=index_affect_color_to_dock;
mouse_released=1;
}
/////////////////////////////////////////////////////////////////////////////////

//////////////////////ROUE DE COULEUR//////////////////////////////////////////////////////

//AFFECTATION MIDI
if( Midi_Faders_Affectation_Type!=0)//config midi
  {
  //midi report
  switch(miditable[0][497])
  {
  case 0: sprintf(thetypinfo,"Note");break;
  case 1: sprintf(thetypinfo,"Key On");break;
  case 2: sprintf(thetypinfo,"Key Off");break;
  case 4: sprintf(thetypinfo,"Ctrl Change");break;
  }
  sprintf(string_last_midi_id,"COLOR WHEEL FADER is Ch: %d Pitch: %d Typ: %s" , miditable[1][497],miditable[2][497],thetypinfo);

  if(mouse_x>xchroma-140 && mouse_x<xchroma+140 && mouse_y>ychroma-140 && mouse_y<ychroma+140)
  {
    attribute_midi_solo_affectation(497,Midi_Faders_Affectation_Mode);
    mouse_released=1;
   }
}


/////////////////////DOCKING DES COULEURS////////////////////////////////////////
//emplacement des box pour actions de storage RVB sur 6 presets

//affectation des circuits aux RVB Y

if(mouse_y>ychroma+165 && mouse_y<ychroma+185)
{
if(mouse_x> xchroma-130 && mouse_x< xchroma-80 )//RED
{
if (index_inspekt==1){show_who_is_in_dock_color(dock_color_selected,0);}
couleur_to_affect=0;
bool there_is_asel_chan=0;

switch(index_paste_on_the_fly)
{
case 0:
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1)
{there_is_asel_chan=1;break;}
}

if(there_is_asel_chan==1 && (index_do_dock==1|| index_do_modify==1 || index_do_report==1))
{index_do_affect_color_trichro=1;index_ask_confirm=1;}

else {index_do_affect_color_trichro=0;index_ask_confirm=0;sprintf(string_Last_Order,"No channel selected to store as color");}
break;
case 1:
if(index_blind==0)
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferSaisie[p]=my_red;}
}
}
else
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferBlind[p]=my_red;}
}
}
sprintf(string_Last_Order,"Pasted On the Fly RED result");
break;
}
mouse_released=1;
}

else if (mouse_x> xchroma-65 && mouse_x< xchroma-15 )//GREEN
{
if (index_inspekt==1){show_who_is_in_dock_color(dock_color_selected,1);}
couleur_to_affect=1;
bool there_is_asel_chan=0;
switch(index_paste_on_the_fly)
{
case 0:
for(int p=1;p<513;p++)
{if(Selected_Channel[p]==1){there_is_asel_chan=1;break;}}
if(there_is_asel_chan==1 && (index_do_dock==1|| index_do_modify==1 || index_do_report==1))
{index_do_affect_color_trichro=1;index_ask_confirm=1;}
else {sprintf(string_Last_Order,"No channel selected to store as color");}
break;
case 1:
if(index_blind==0)
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferSaisie[p]=my_green;}
}
}
else
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferBlind[p]=my_green;}
}
}
sprintf(string_Last_Order,"Pasted On the Fly GREEN result");
break;
}
mouse_released=1;
}

else if (mouse_x> xchroma && mouse_x< xchroma+50 )//BLUE
{
if (index_inspekt==1){show_who_is_in_dock_color(dock_color_selected,2);}

couleur_to_affect=2;
bool there_is_asel_chan=0;
switch(index_paste_on_the_fly)
{
case 0:
for(int p=1;p<513;p++)
{if(Selected_Channel[p]==1){there_is_asel_chan=1;break;}}
if(there_is_asel_chan==1 && (index_do_dock==1|| index_do_modify==1 || index_do_report==1)){index_do_affect_color_trichro=1;index_ask_confirm=1;}
else {sprintf(string_Last_Order,"No channel selected to store as color");}
break;
case 1:
if(index_blind==0)
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferSaisie[p]=my_blue;}
}
}
else
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferBlind[p]=my_blue;}
}
}
sprintf(string_Last_Order,"Pasted On the Fly BLUE result");
break;
}
mouse_released=1;
}

else if (mouse_x> xchroma+65 && mouse_x< xchroma+115 )//YELLOW
{
if (index_inspekt==1){show_who_is_in_dock_color(dock_color_selected,3);}
couleur_to_affect=3;
bool there_is_asel_chan=0;
switch(index_paste_on_the_fly)
{
case 0:
for(int p=1;p<513;p++)
{if(Selected_Channel[p]==1){there_is_asel_chan=1;break;}}
if(there_is_asel_chan==1&& (index_do_dock==1|| index_do_modify==1 || index_do_report==1)){index_do_affect_color_trichro=1;index_ask_confirm=1;}
else {sprintf(string_Last_Order,"No channel selected to store as color");}
break;
case 1:
if(index_blind==0)
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferSaisie[p]=my_yellow;}
}
}
else
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferBlind[p]=my_yellow;}
}
}
sprintf(string_Last_Order,"Pasted On the Fly YELLOW result");
break;
}
mouse_released=1;
}
}


//midi out de la roue

if(mouse_x> xchroma+140-10 && mouse_x< xchroma+140+10 && mouse_y>ychroma+110-10 && mouse_y<ychroma+110+10)
{

  if(midi_send_out[497]==0){midi_send_out[497]=1; }
  else if(midi_send_out[497]==1){midi_send_out[497]=0; }
  mouse_released=1;
  }

raccrochage_midi_logical_circulaire (xchroma-6, ychroma, 497, 125, 125);



//premiere rangee de dock colors

for (int dock_color=0;dock_color<4;dock_color++)
{
if(mouse_x>xchroma-130+(65*dock_color) && mouse_x<xchroma-80+(65*dock_color) && mouse_y>ychroma+215 && mouse_y<ychroma+235)
{
if( Midi_Faders_Affectation_Type!=0)
{
if(dock_color==0 && Midi_Faders_Affectation_Type==2)
{attribute_midi_to_control(949,Midi_Faders_Affectation_Type,Midi_Faders_Affectation_Mode);}
else{attribute_midi_solo_affectation(949+dock_color, Midi_Faders_Affectation_Mode);}
}
else
{
dock_color_selected=dock_color;
load_etat_picker_dans_dockcolor(dock_color_selected);
sprintf(string_Last_Order,">>Dock Color Selected %d",(dock_color_selected+1));
mouse_released=1;
}
}
}
//deuxième rangee de dockcolors
for (int dock_colortwo=0;dock_colortwo<4;dock_colortwo++)
{
if(mouse_x>xchroma-130+(65*dock_colortwo) && mouse_x<xchroma-80+(65*dock_colortwo) && mouse_y>ychroma+255 && mouse_y<ychroma+275)
{
if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(949+(dock_colortwo+4), Midi_Faders_Affectation_Mode);
}
else
{
dock_color_selected=dock_colortwo+4;
load_etat_picker_dans_dockcolor(dock_color_selected);
sprintf(string_Last_Order,">>Dock Color Selected %d",dock_color_selected+1);
mouse_released=1;
}
}
}

//PASTE ON THE FLY
if(mouse_x>xchroma-150 && mouse_x<xchroma-20 && mouse_y>ychroma+300 && mouse_y< ychroma+330)
{
if(mouse_b&1 &&  mouse_released==0 && window_focus_id==902)
{
index_paste_on_the_fly=toggle(index_paste_on_the_fly);
mouse_released=1;
}
}


//GEL LIST
if(show_gel_list==1)
{

if(mouse_x>xchroma+180 && mouse_x<xchroma+250 && mouse_y>ychroma-185 && mouse_y<ychroma-165)
{
index_gel_type_selected++;
if(index_gel_type_selected>3)index_gel_type_selected=0;
mouse_released=1;
}
//numeric or designer list
if(mouse_x>xchroma+260 && mouse_x<xchroma+330 && mouse_y>ychroma-185 && mouse_y<ychroma-165)
{
show_designer_list=toggle(show_designer_list);
switch(show_designer_list)
{
case 0://numerical order
break;
case 1://designer order
break;
}
mouse_released=1;
}

//saisie d une ref de gelat
if(mouse_x>xchroma+340 && mouse_x<xchroma+390 && mouse_y>ychroma-185 && mouse_y<ychroma-165)
{
call_ref_number=atoi(numeric);
mouse_released=1;
if(call_ref_number<10000 && call_ref_number!=0)
{

//repositionnemennt de la liste
for (int i=0;i<10000;i++)
{
if(refs_of_gels[index_gel_type_selected][i]==call_ref_number )
{
gel_position[index_gel_type_selected]=i;
report_gels_to_rvb_trichro(index_gel_type_selected,gel_position[index_gel_type_selected]);
break;
}
}
reset_numeric_entry();
}

}
//+ - Index gelatine
if(mouse_y>ychroma-187 && mouse_y<ychroma-163)
{
//- index
if(mouse_x>xchroma+398 && mouse_x<xchroma+422)
{
if(gel_position[index_gel_type_selected]>10)gel_position[index_gel_type_selected]-=10;
mouse_released=1;
}
//+ index
if(mouse_x>xchroma+428 && mouse_x<xchroma+452)
{
if(gel_position[index_gel_type_selected]<10000-10)gel_position[index_gel_type_selected]+=10;
mouse_released=1;
}
}

//Transmission calculation
if(mouse_x>xchroma+510 && mouse_x<xchroma+550 && mouse_y>ychroma-185 && mouse_y<ychroma-165)
{
index_use_transmission=toggle(index_use_transmission);
mouse_released=1;
}

//sélection gel
for(int i=0;i<30;i++)
{
if( mouse_x>xchroma+175 && mouse_x<xchroma+485 && mouse_y>ychroma-150+(i*16) && mouse_y<ychroma-134+(i*16) )
{
call_ref_number=refs_of_gels[index_gel_type_selected][gel_position[index_gel_type_selected]+i];
report_gels_to_rvb_trichro(index_gel_type_selected,gel_position[index_gel_type_selected]+i);
mouse_released=1;
}
}
//fin gel list
}


return(0);
}
int mini_faders_panel_core(int xmf, int ymf, int larg)
{

if(mouse_y>ymf && mouse_y<ymf+20 )
{

if(mouse_x>xmf+(24*larg)+10 && mouse_x<xmf+(24*larg)+30)
{
if( Midi_Faders_Affectation_Type!=0)
{
 attribute_midi_solo_affectation(774,1);
}
else
{
position_minifader_selected--;
if(position_minifader_selected<0){position_minifader_selected=core_user_define_nb_faders;}
refresh_minifader_state_view_core(position_minifader_selected);
mouse_released=1;
}
}

else if(mouse_x>xmf+(24*larg)+35 && mouse_x<xmf+(24*larg)+55)
{
if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(775,1);
}
else
{
position_minifader_selected++;
if(position_minifader_selected>core_user_define_nb_faders){position_minifader_selected=0;}
refresh_minifader_state_view_core(position_minifader_selected);
mouse_released=1;
}
}
}


//SELECT ALL
if(mouse_y>ymf-25 && mouse_y<ymf-5 )
{
if(mouse_x>xmf+(24*larg)+10 && mouse_x<xmf+(24*larg)+55)
{
if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(145,1);
}
else
{
for(int i=0;i<core_user_define_nb_faders;i++)
{minifaders_selected[i]=1;}
}
}
}





 //select
if(mouse_x>xmf+(24*larg)+10 && mouse_x<xmf+(24*larg)+55 )
{

if(mouse_y>ymf+25 && mouse_y<ymf+45 && mouse_released==0 )
{
if( Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(776,1);
mouse_released=1;
}
else
{
minifaders_selected[position_minifader_selected]=toggle(minifaders_selected[position_minifader_selected]);
mouse_released=1;
}
}

else if(mouse_y>ymf+50 && mouse_y<ymf+70 && mouse_released==0 )
{
if( Midi_Faders_Affectation_Type!=0)
{
 attribute_midi_solo_affectation(777,1);
 }
else
{
for(int l=0;l<core_user_define_nb_faders;l++)
{
minifaders_selected[l]=0;
}
}
mouse_released=1;
}
}

///////////////LES ACTIONS////////////////////////////////////////////////////
for(int lu=0;lu<5;lu++)
{
for(int llu=0;llu<3;llu++)
{
int numcom=(lu*3)+llu;
//mouse action:
if(mouse_x>xmf+(24*larg)+70+(lu*25) && mouse_x<xmf+(24*larg)+70+(lu*25)+20 && mouse_y>ymf+(llu*25) && mouse_y<ymf+(llu*25)+20)
{
char tmp_c[36];
switch(numcom)
{
case 0:
sprintf(tmp_c,"Flash");
break;
case 1:
sprintf(tmp_c,"Lock");
break;
case 2:
sprintf(tmp_c,"Loop");
break;
case 3:
sprintf(tmp_c,"Lfo UP");
break;
case 4:
sprintf(tmp_c,"Lfo DOWN");
break;
case 5:
sprintf(tmp_c,"Lfo SAW");
break;
case 6:
sprintf(tmp_c,"All Dock Looped");
break;
case 7:
sprintf(tmp_c,"All at 0");
break;
case 8:
sprintf(tmp_c,"Set Pos");
break;
case 9:
sprintf(tmp_c,"To Prev Dock");
break;
case 10:
sprintf(tmp_c,"To Next Dock");
break;
case 11:
sprintf(tmp_c,"Up and Down");
break;
case 12:
sprintf(tmp_c,"Sel Prev Dock");
break;
case 13:
sprintf(tmp_c,"Sel Next Dock");
break;
case 14:
sprintf(tmp_c,"Play Embedded");
break;
default:
                    strcpy(tmp_c,"");
break;
}

sprintf(string_last_midi_id,"%s is Ch: %d Pitch: %d Type: %s",tmp_c, miditable[1][778+numcom],miditable[2][778+numcom],thetypinfo);

if(numcom!=0 )// hors flash
{
if( Midi_Faders_Affectation_Type!=0)
{
 attribute_midi_solo_affectation(778+numcom,1);
 }

else
{
do_action_on_selected_minifaders(numcom);
mouse_released=1;
}
}


}



}
}

//les presets de sélections de faders//////////////////////////////////////////////////////////

for(int lg=0;lg<8;lg++)
{

if(mouse_x>xmf+(24*larg)+10 && mouse_x<xmf+(24*larg)+10+20 && mouse_y>ymf+90+(lg*25) && mouse_y<ymf+90+(lg*25)+20)
{

if(Midi_Faders_Affectation_Type!=0)
{
 //midi report
 switch(miditable[0][794+lg])
 {
  case 0:
  sprintf(thetypinfo,"Note");
  break;
  case 1:
  sprintf(thetypinfo,"Key On");
  break;
  case 2:
  sprintf(thetypinfo,"Key Off");
  break;
  case 4:
  sprintf(thetypinfo,"Ctrl Change");
  break;
 }
  sprintf(string_last_midi_id,"FaderPreset %d is Ch: %d Pitch: %d Type: %s",lg+1, miditable[1][794+lg],miditable[2][794+lg],thetypinfo);

 if(Midi_Faders_Affectation_Type==1)
 {attribute_midi_solo_affectation(794+lg,1);}
 else if(Midi_Faders_Affectation_Type==2)
 {
 attribute_midi_to_control(794, Midi_Faders_Affectation_Type,Midi_Faders_Affectation_Mode);
 }
}
else
{
if(index_do_dock==1)
{
minifader_preset_is=lg;
index_record_minifader_preset=1;
index_ask_confirm=1;
}
else if(index_main_clear==1)
{
minifader_preset_is=lg;
index_clear_minifader_preset=1;
index_ask_confirm=1;
}
else //selection souris normale
{
for(int olp=0;olp<core_user_define_nb_faders;olp++)
{minifaders_selected[olp]=minifaders_preset_selection[lg][olp];}
sprintf(string_Last_Order,"Called Fader Selection from Preset %d", lg+1);
}

}
}
}
////////////Les locks presets///////////////////////////////////////////////////

for(int lck=0;lck<8;lck++)
{

if(mouse_x>xmf+(24*larg)+35 && mouse_x<xmf+(24*larg)+35+20 && mouse_y>ymf+90+(lck*25) && mouse_y<ymf+90+(lck*25)+20)
{

if( Midi_Faders_Affectation_Type!=0)
{

     //midi report
 switch(miditable[0][605+lck])
 {
  case 0:
  sprintf(thetypinfo,"Note");
  break;
  case 1:
  sprintf(thetypinfo,"Key On");
  break;
  case 2:
  sprintf(thetypinfo,"Key Off");
  break;
  case 4:
  sprintf(thetypinfo,"Ctrl Change");
  break;
 }
  sprintf(string_last_midi_id,"Lock Preset %d is Ch: %d Pitch: %d Type: %s",lck+1, miditable[1][605+lck],miditable[2][605+lck],thetypinfo);

  if(Midi_Faders_Affectation_Type==1)
 {attribute_midi_solo_affectation(605+lck,1);}
 else if(Midi_Faders_Affectation_Type==2)
 {
 attribute_midi_to_control(605, Midi_Faders_Affectation_Type,Midi_Faders_Affectation_Mode);
 }
}

else
 {

 if(index_do_dock==1)
 {

 minifader_lockpreset_is=lck;
 index_record_minifader_lockpreset=1;
 index_ask_confirm=1;
 }

 else  if(index_main_clear==1)
 {

 reset_indexs_confirmation();
 lock_preset_selected_for_record=lck;
 index_do_clear_lock_preset=1;
 index_ask_confirm=1;
 sprintf(string_Last_Order,">> Lock State %d cleared",lck+1);
 }
 else
 {
 do_lock_preset(lck);
 sprintf(string_Last_Order,">> Lock State %d called ",lck+1);
 }
mouse_released=1;
}
}
}


/////////////////ALL AT 0///////////////////////////////////////////////////////
all_at_zero_panel_core((xmf+24*larg)+60,ymf+80);

midi_send_faders_button_logical((xmf+24*larg)+140,ymf-40,W_MINIFADERS);


////////////////////////////////////////////////////////////////////////////////
/////////////////////////LES 48 POTARDS/////////////////////////////////////////
int hmfd=200;//hauteur d une ligne de 24 faders
for(int cmptfader=0; cmptfader<max_faders/2; cmptfader++)
{
for(int lfad=0;lfad<2;lfad++)
{

if(cmptfader+(lfad*24)<=core_user_define_nb_faders-1)//limitation nbre faders
{

////FX MODE

if(  window_focus_id==922 && mouse_released==0 && mouse_x>xmf+(cmptfader*larg) && mouse_x<xmf+(cmptfader*larg)+larg && mouse_y>(ymf+(lfad*hmfd))-12  && mouse_y<(ymf+(lfad*hmfd))-12+5 )
{
if( Midi_Faders_Affectation_Type!=0)
{
attribute_midi_to_control(1543+cmptfader+(lfad*24), Midi_Faders_Affectation_Type,  Midi_Faders_Affectation_Mode);
}
else
{
  fader_mode_with_buffers[cmptfader+(lfad*24)]++;
 if(fader_mode_with_buffers[cmptfader+(lfad*24)]>5){fader_mode_with_buffers[cmptfader+(lfad*24)]=0;}
}
mouse_released=1;
}

///////////SELECTION SOURIS SUR  NUMEROS AU DESSUS FADERS/////////////////////////////////////////////////////////
if( mouse_x>xmf+(cmptfader*larg) && mouse_x<xmf+(cmptfader*larg)+larg && mouse_y>(ymf+(lfad*hmfd))  && mouse_y<(ymf+15+(lfad*hmfd)) )
{
position_minifader_selected=cmptfader+(lfad*24);

int dock_selected_is=detect_dock_used(position_minifader_selected);


//SELECTION
if(index_do_dock==0 && index_do_modify==0 && index_do_dock==0   && index_type==0    && index_main_clear==0 )
{
 minifaders_selected[position_minifader_selected]=toggle(minifaders_selected[position_minifader_selected]);
 if(index_inspekt==1)//affichage qui dans dock si VIEW activé
 {
 show_who_is_in_dock( position_minifader_selected,   detect_dock_used(position_minifader_selected));
 }
 mouse_released=1;
}


 //store normal
 else if(index_do_dock==1 && index_direct_chan==0   && index_affect_chaser_to_dock==0  && index_affect_time==0 && index_affect_color_to_dock==0 && index_do_affect_net_to_dock==0
 && index_affect_dmxin==0 && index_affect_video_tracking_to_dock==0 && index_affect_audio_to_dock==0 && gridplayer_to_affect_is==-1
 && index_do_fgroup==0 && index_affect_to_dock_mover==0 && index_affect_draw_to_dock==0 &&  index_affect_echo_to_dock==0)
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_record_on_faders=1;
 index_ask_confirm=1;
 }

  //affect time
 else if (index_do_dock==1 && index_affect_time==1 )
 {
 show_im_recording_a_time=1;
 DoTimeToDock(position_minifader_selected,dock_selected_is);
 sprintf(string_Last_Order,">>Time affected to Master %d Dock %d", position_minifader_selected+1,dock_selected_is);
 index_affect_time=0;
 }
 //color dock
 else if(index_do_dock==1 && index_affect_color_to_dock==1 )
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_affect_color_on_faders=1;
 index_ask_confirm=1;
 }
 //dmx to dock
 else if(index_do_dock==1 && index_affect_dmxin==1 ) // affect couleurs dans dock
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_dmx_to_dock=1;
 index_ask_confirm=1;
 }
 //artnet to dock
 else if(index_do_dock==1 && index_do_affect_net_to_dock==1 ) // affect Network IN dans dock
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_artnet_to_dock=1;
 index_ask_confirm=1;
 }
 //video to dock
 else if(index_do_dock==1 && index_affect_video_tracking_to_dock==1) // affect Network IN dans dock
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_video_to_dock=1;
 index_ask_confirm=1;
 }
 //audio to dock
 else if(index_do_dock==1 &&  index_affect_audio_to_dock==1) // affect audio controls dans dock
 {
 if(player_to_affect_to_dock>=0 && player_to_affect_to_dock<4 )
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_audio_to_dock=1;
 index_ask_confirm=1;
 }
 }

 //store direct CH
 else if(index_do_dock==1 && index_direct_chan==1 )
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_record_direct_ch=1;
 index_ask_confirm=1;
 }
 //store FX
 else if(index_do_dock==1 && index_affect_chaser_to_dock==1)
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_affect_fx=1;
 index_ask_confirm=1;
 }
 //store Grid
 else if(index_do_dock==1 &&  gridplayer_to_affect_is>=0 )
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_affect_grid_to_fader=1;
 index_ask_confirm=1;
 }
 //store group fader
 else if(index_do_dock==1 && index_do_fgroup==1 )
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 bool index_there_is_fader_selected=0;
 for(int io=0;io<48;io++)
 {
 if(minifaders_selected[io]==1){index_there_is_fader_selected=1;break;}
 }
 if(index_there_is_fader_selected==1)
 {
 index_do_affect_fgroup=1;
 index_ask_confirm=1;
 }
 else{sprintf(string_Last_Order,"No minifaders selected");}
 }

  //Store Mover dans dock
 else if (  index_do_dock==1 && index_affect_to_dock_mover==1)
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_affect_mover=1;
 index_ask_confirm=1;
 }


 //draw
 else if(index_do_dock==1 && index_affect_draw_to_dock==1)
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 draw_preset_selected_for_order=draw_preset_selected;
 index_do_draw_affect_to_dock=1;
 index_ask_confirm=1;
 mouse_released=1;
 }
  //echo
 else if(index_do_dock==1 && index_affect_echo_to_dock==1)
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_affect_echo_to_dock=1;
 index_ask_confirm=1;
 mouse_released=1;
 }

 //modify
 else if( index_do_modify==1 )
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_modify_on_faders=1;
 index_ask_confirm=1;
 }


  //report
 if( index_do_report==1 && index_type==0 && index_do_dock==0 && index_do_modify==0 )
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_report_on_faders=1;
 index_ask_confirm=1;
 sprintf(string_Last_Order,"Report");
 }

 //nommage de dock
 else if( index_type==1 && index_do_dock==0 && index_do_report==0 && index_do_modify==0   && numeric_postext!=0 )
 {
 for(int tt=0;tt<24;tt++)
 {
 DockName[position_minifader_selected][dock_selected_is][tt]=numeric[tt];
 }
 DockName[position_minifader_selected][dock_selected_is][24]='\0';
 reset_numeric_entry();numeric_postext=0;
 if(index_text_auto_close==1){index_type=0;}
 sprintf(string_Last_Order,">>On Master %d GIVED A NAME FOR DOCK %d ", position_minifader_selected+1,dock_selected_is+1);
 }

  //clear
 else if(index_main_clear==1 )
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_clear_dock=1;
 index_ask_confirm=1;
 }


refresh_minifader_state_view_core(position_minifader_selected);
}

//MANIP DU MINI FADER/////////////////////////////////////////////////////////////
if( mouse_x>xmf+(cmptfader*larg) && mouse_x<xmf+(cmptfader*larg)+larg && mouse_y>(ymf+15+(lfad*hmfd))  && mouse_y<(ymf+20+127+(lfad*hmfd)) )
{

position_minifader_selected=cmptfader+(lfad*24);
refresh_minifader_state_view_core(cmptfader+(lfad*24));
if(index_inspekt==1){ //affichage qui dans dock si VIEW activé
show_who_is_in_dock( cmptfader+(lfad*24),   detect_dock_used(cmptfader+(lfad*24)));
}
set_mouse_range(xmf+(cmptfader*larg), ymf+20+(lfad*hmfd), xmf+(cmptfader*larg)+larg, ymf+20+127+(lfad*hmfd));//pour pas deborder
//click niveau fader
if( index_main_clear==0)
{
//NIVEAU
Fader[cmptfader+(lfad*24)]=((ymf+127+20+(lfad*hmfd))-mouse_y)*2;
midi_levels[cmptfader+(lfad*24)]=((ymf+127+20+(lfad*hmfd))-mouse_y);//desafffceté pour trouver pb

if(Fader[cmptfader+(lfad*24)]>=254){Fader[cmptfader+(lfad*24)]=255;midi_levels[cmptfader+(lfad*24)]=127;}

index_fader_is_manipulated[cmptfader+(lfad*24)]=1;
if(midi_send_out[cmptfader+(lfad*24)]==1){ index_send_midi_out[cmptfader+(lfad*24)]=1;}
if(lfo_mode_is[cmptfader+(lfad*24)]==1 || lfo_mode_is[cmptfader+(lfad*24)]==2 || lfo_cycle_is_on[cmptfader+(lfad*24)]==1)
{
lfo_mode_is[cmptfader+(lfad*24)]=0; lfo_mode_is[cmptfader+(lfad*24)]=0; lfo_cycle_is_on[cmptfader+(lfad*24)]=0;
}
//CONFIG MIDI

if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_to_control(cmptfader+(lfad*24), Midi_Faders_Affectation_Type,Midi_Faders_Affectation_Mode);
}
}
//NETTOYAGE DE FADER ET DOCK
if(index_main_clear==1)//clear de tous les dock du fader
{
 fader_selected_for_record=cmptfader+(lfad*24);
 index_do_clear_on_faders=1;
 index_ask_confirm=1;
 mouse_released=1  ;
}
}
}//fin limitation nb faders user define
}//fin doublage des faders
}
////////FIN DES 48 POTARDS//////////////////////////////////////////////////////

return(0);
}
Example #5
0
int do_logical_echo_window(int xe, int ye)
{
if(window_focus_id==W_ECHO && dragging_channel_in_echo==0 && mouse_button==1)
{

//edit
if( mouse_released==0 && mouse_x>xe+610 && mouse_x<xe+610+50 && mouse_y>ye+10 && mouse_y<ye+10+20 )
{
index_enable_edit_echo=toggle(index_enable_edit_echo);
mouse_released=1;
}


int index_ec=0;
//SElection presets
for(int le=0;le<3;le++)
{
for(int cel=0;cel<8;cel++)
{
index_ec=cel+(le*8);
if( mouse_x> xe+180+(40*cel) && mouse_x<xe+180+(40*cel)+30 && mouse_y>ye+10+(le*25) && mouse_y<ye+10+(le*25)+20)
{
if( mouse_released==0 )
{
if( Midi_Faders_Affectation_Type!=0)//config midi
{
 attribute_midi_to_control(1663+index_ec,Midi_Faders_Affectation_Type,Midi_Faders_Affectation_Mode);
}
else
{
if(index_main_clear==1)
{
if(index_enable_edit_echo==1)
{
index_selected_echo_for_manipulation=index_ec;
index_ask_clear_echo_preset=1;
index_ask_confirm=1;             //clear_echo_preset(index_selected_echo_for_manipulation);
}
}

else
{
echo_selected=index_ec;

}
}
mouse_released=1;
}
}
}
}


//Set ChanPos
if( mouse_x>xe+615 && mouse_x<xe+615+40 && mouse_y>ye+65 && mouse_y<ye+65+20 && mouse_released==0 && dragging_channel_in_echo==0 && numeric_postext>0)
 {
 echo_grid_channel_position[echo_selected]=atoi(numeric)-1;
 echo_grid_channel_position[echo_selected]= constrain_int_data_to_this_range(echo_grid_channel_position[echo_selected],0,511-14);
 reset_numeric_entry();
 numeric_postext=0;
 mouse_released=1;
 }


//ECHO ACTION PANNEL

for (int n=0;n<5;n++)
{
//actions
if(mouse_x>xe+30 && mouse_x<xe+30+115 && mouse_y>ye+50+(n*30) && mouse_y<ye+50+30+(n*30))
{
if( mouse_released==0 )
{
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1686+n,Midi_Faders_Affectation_Mode);
}
else
{
switch(n)
{
case 0:
     echo_is_echo_mode[echo_selected]=toggle(echo_is_echo_mode[echo_selected]);
     do_bounce[echo_selected]=echo_is_echo_mode[echo_selected];
break;
case 1:
     snap_fader_state(echo_selected,echo_pointing_fader_num[echo_selected]-1);
break;
case 2:
     bounce(echo_selected);
break;
case 3:
     snap_kill_and_bounce(echo_selected,echo_pointing_fader_num[echo_selected]-1);
break;
case 4:
     recall_fader_state_echo(echo_pointing_fader_num[echo_selected]-1);
break;
default:
break;
}
}
mouse_released=1;
}

}
}

//Fader point to
if( mouse_x>xe+70 && mouse_x<xe+70+45 && mouse_y>ye+200 && mouse_y<ye+200+35 && mouse_released==0 && numeric_postext>0)
{
echo_pointing_fader_num[echo_selected]=constrain_int_data_to_this_range(atoi(numeric),1,48);
reset_numeric_entry();
numeric_postext=0;
mouse_released=1;
}


////AFFECT TO DOCK
if( mouse_released==0 && mouse_x>xe+10 && mouse_x<xe+10+110 && mouse_y>ye+245 && mouse_y<ye+245+20  )
{
if(index_affect_echo_to_dock==0)
{
reset_index_actions();
reset_indexs_confirmation();
index_affect_echo_to_dock=1;
}
else
{
reset_index_actions();
}
index_do_dock=index_affect_echo_to_dock;
mouse_released=1;
}


//manipulate channel params Level mode / ground mode
if( mouse_released==0 && mouse_x>xe+500 && mouse_x<xe+500+70 && mouse_y>ye+10 && mouse_y<ye+10+20)
{
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1696,Midi_Faders_Affectation_Mode);
}
else
{
if(index_main_clear==1 && index_enable_edit_echo==1)
{
switch(echo_channel_manipulate_mode[echo_selected])
{
 case 0://levels
 clear_echo_levels(echo_selected);
 break;
 case 1:
 clear_ground_levels(echo_selected);
 break;
}
index_main_clear=0;
}
else
{
echo_channel_manipulate_mode[echo_selected]=toggle(echo_channel_manipulate_mode[echo_selected]);
}
}
mouse_released=1;
}






//les Trois parametres globaux: gravite masse energy
for (int cl=0;cl<3;cl++)
{

if(mouse_x>=xe+155+(cl*180) && mouse_x<=xe+155+(cl*180)+130 && mouse_y>=ye+255 && mouse_y<=ye+255+10)
{
if(  mouse_released==0)
{
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1693+cl,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
echo_global_params[echo_selected][cl]= (float)(constrain_data_to_midi_range(mouse_x-( xe+155+(cl*180))))/127;
midi_levels[1693+cl]=(int)(echo_global_params[echo_selected][cl]*127);
}
}
}
//midi out
if( mouse_released==0 && mouse_x>=xe+290+(cl*180) && mouse_x<=xe+290+(cl*180)+10 && mouse_y>=ye+260 && mouse_y<=ye+265+10)
{
 midi_send_out[1693+cl]=toggle(midi_send_out[1693+cl]);
 mouse_released=1;
}

}//fin des 3 sliders



}
//hors du dragging 0
do_logical_Echo_Aera(xe+155,ye+95);
return(0);
}
int do_logical_Time_Window(int xtime, int ytime, int timerayon)
{

//////////////////////ROUE DE TEMPS//////////////////////////////////////////////////////
//affectation midi

if( Midi_Faders_Affectation_Type!=0)
{
if(mouse_x>xtime+150  && mouse_x< xtime+150+100 && mouse_y>ytime+150 && mouse_y<ytime+150+100 )
 {
 //midi report
  switch(miditable[0][758])
  {
  case 0: sprintf(thetypinfo,"Note");break;
  case 1: sprintf(thetypinfo,"Key On");break;
  case 2: sprintf(thetypinfo,"Key Off");break;
  case 4: sprintf(thetypinfo,"Ctrl Change");break;
  }
  sprintf(string_last_midi_id,"TIMEWHEEL FADER is Ch: %d Pitch: %d Typ: %s" , miditable[1][758],miditable[2][758],thetypinfo);

  attribute_midi_solo_affectation(758,Midi_Faders_Affectation_Mode);
  mouse_released=1;
 }
}
/////////////////////////////////////////////////////////////////////////////////////////
if(index_play_chrono==0 )
{
for(time_angle = 0 ; time_angle <5.980005; time_angle+=0.01)//radians
{
   vtimex = cos(time_angle)*timerayon;
   vtimey = sin(time_angle)*timerayon;

   if(mouse_x>xtime+vtimex+150-15  && mouse_x< xtime+vtimex+150+15 && mouse_y>ytime+vtimey+150-15 && mouse_y<ytime+vtimey+150+15 )
   {

   actual_tickers_chrono=0;//reset du chrono
   angle_timesnap=time_angle;//angle rotation roue time
   position_curseur_time_x= xtime+150+vtimex;
   position_curseur_time_y=ytime+150+vtimey ;
   midi_levels[758]=(int)((angle_timesnap/5.980005)* 128);

   if(midi_send_out[758]==1){index_send_midi_out[758]=1;}

   if(time_wheel_datatype_is==0)//minutes
   {
   angle_timesnap_min=angle_timesnap;
   time_minutes=(int)((angle_timesnap_min/5.980005)*60);
   }
   if(time_wheel_datatype_is==1)//secondes
   {
   angle_timesnap_sec=angle_timesnap;
   time_secondes=(int)((angle_timesnap_sec/5.980005)*60);
   }
   if(time_wheel_datatype_is==2)//dixiemes
   {
   angle_timesnap_dix=angle_timesnap;
   time_centiemes=(int)((angle_timesnap_dix/5.980005)*100);
   }

   }
}
}




//////////////////////////CHRONO//////////////////////////////////////////////////

if(mouse_x>xtime+140-15 && mouse_x<xtime+140+15 && mouse_y>ytime+190-15 && mouse_y<ytime+190+15)
{

switch(miditable[0][765])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"ChronoPlay is Ch: %d Pitch: %d Typ: %s",miditable[1][765],miditable[2][765],thetypinfo);

if( Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(765,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
Chrono_PlayPause();
mouse_released=1;
}
}

if(mouse_x>xtime+180-8 && mouse_x<xtime+180+8 && mouse_y>ytime+200-8 && mouse_y<ytime+200+8)
{

switch(miditable[0][766])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"ChronoReset is Ch: %d Pitch: %d Typ: %s",miditable[1][766],miditable[2][766],thetypinfo);

if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(766,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
Chrono_Reset();
mouse_released=1;
}
}

///////////////////////CHOIX DE SELECTION ROUE= SECONDES ou MINUTES ou HEURES


if(mouse_x>xtime+120 && mouse_x<xtime+180 && mouse_y>ytime+80 && mouse_y<ytime+100)
{

switch(miditable[0][759])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"TimeType is Ch: %d Pitch: %d Typ: %s",miditable[1][759],miditable[2][759],thetypinfo);

if( Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(759,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
time_wheel_datatype_is++;
if(time_wheel_datatype_is>2){time_wheel_datatype_is=0;}
set_time_cursor_to_time_type(time_wheel_datatype_is);
mouse_released=1;
}
}



/////////////////////////CASES D' AFFECTATION AUX DOCK ET MEMOIRES

//la selection des modes de temps in out din dout
if(mouse_x>xtime+300 && mouse_x<xtime+350)
{
//DIN
if(mouse_y>ytime+120 && mouse_y<ytime+150)
{

switch(miditable[0][760])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"DelayIn Button is Ch: %d Pitch: %d Typ: %s",miditable[1][760],miditable[2][760],thetypinfo);

if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(760,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
if(index_type_of_time_to_affect[0]==0){index_type_of_time_to_affect[0]=1;}
else if(index_type_of_time_to_affect[0]==1){index_type_of_time_to_affect[0]=0;}
mouse_released=1;
}
}
//IN
if(mouse_y>ytime+20 && mouse_y<ytime+50)
{

switch(miditable[0][761])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"In Button is Ch: %d Pitch: %d Typ: %s",miditable[1][761],miditable[2][761],thetypinfo);

if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(761,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
if(index_type_of_time_to_affect[1]==0){index_type_of_time_to_affect[1]=1;}
else if(index_type_of_time_to_affect[1]==1){index_type_of_time_to_affect[1]=0;}
mouse_released=1;
}
}
//DOUT
if(mouse_y>ytime+170 && mouse_y<ytime+200)
{

switch(miditable[0][762])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"DelayOut Button is Ch: %d Pitch: %d Typ: %s",miditable[1][762],miditable[2][762],thetypinfo);

if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(762,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
if(index_type_of_time_to_affect[2]==0){index_type_of_time_to_affect[2]=1;}
else if(index_type_of_time_to_affect[2]==1){index_type_of_time_to_affect[2]=0;}
mouse_released=1;
}
}
//OUT
if(mouse_y>ytime+70 && mouse_y<ytime+100)
{

switch(miditable[0][763])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"Out Button is Ch: %d Pitch: %d Typ: %s",miditable[1][763],miditable[2][763],thetypinfo);

if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(763,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
if(index_type_of_time_to_affect[3]==0){index_type_of_time_to_affect[3]=1;}
else if(index_type_of_time_to_affect[3]==1){index_type_of_time_to_affect[3]=0;}
mouse_released=1;
}
}
}

///TAP TEMPO sending
if(mouse_x>xtime+265 && mouse_x<xtime+265+15 && mouse_y>ytime+210 && mouse_y<ytime+210+15)
{

switch(miditable[0][1328])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"Send Tap is Ch: %d Pitch: %d Typ: %s",miditable[1][1328],miditable[2][1328],thetypinfo);

if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(1328,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
if(numeric_postext==0 && index_window_chasers==1)
            {
            set_chaser_tempo_unit(chaser_selected);
            }
            else//si chiffre de chaser tapé
            {
            int chazr=atoi(numeric);
            if(chazr>0 && chazr<128)
            {
            set_chaser_tempo_unit(chazr-1);
            numeric_postext=0;
            reset_numeric_entry();
            }
            }
            mouse_released=1;
do_light_send_tap=1;
}

}



///TAP TEMPO reoording
if(mouse_x>xtime+285 && mouse_x<xtime+285+15 && mouse_y>ytime+210 && mouse_y<ytime+210+15)
{

switch(miditable[0][1327])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"Record Tap is Ch: %d Pitch: %d Typ: %s",miditable[1][1327],miditable[2][1327],thetypinfo);

if( Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(1327,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
index_recording_tap_tempo=toggle(index_recording_tap_tempo);
if(index_recording_tap_tempo==1)
{
start_tempo_ticks=actual_time;nbr_steps_tempo=0;tempo_interm=0;
sprintf(string_tap_tempo_average,"Step:   -    Global: -");
sprintf(string_actual_tap_tempo,"Last: ");
sprintf(string_Last_Order,"Tap Tempo Rec ON");
}
else{sprintf(string_Last_Order,"Tap Tempo Rec Off");}
mouse_released=1;
}


}


//tap button tempo
if(mouse_x>xtime+310 && mouse_x<xtime+310+40 && mouse_y>ytime+210 && mouse_y<ytime+210+30)
{

switch(miditable[0][1326])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"Tap Tempo is Ch: %d Pitch: %d Typ: %s",miditable[1][1326],miditable[2][1326],thetypinfo);

if( Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(1326,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
set_new_time_in_tap_tempo();
mouse_released=1;
}
}


//AFFECT TIME
if(mouse_x>xtime+280 && mouse_x<xtime+350 && mouse_y>ytime+260 && mouse_y<ytime+290)
{

switch(miditable[0][764])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"Affect Time Button is Ch: %d Pitch: %d Typ: %s",miditable[1][764],miditable[2][764],thetypinfo);

if( Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(764,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
if(index_affect_time==0)
{
reset_index_actions();
reset_indexs_confirmation();
index_affect_time=1;
}
else
{
reset_index_actions();
}
index_do_dock=index_affect_time;
mouse_released=1;
}
}


button_midi_out_core( xtime+250, ytime+250,758);

return(0);
}
int commandes_clavier()//la fonction sprintf tue l acces clavier
{
if ( keypressed())
{

int chi = readkey(); 
scan_ascii_is=(chi & 0xff);//prend pas en compte touches fonctions
scan_allegro_key_is=(chi >> 8);//prend en compte tout le monde mais à redistribuer fr et anglais


switch (chi >> 8)  
{	
    

case KEY_ESC://nettoyage chaine de caractere et deselection totale

reset_indexs_confirmation();
reset_index_actions();
key_unselect_ch();
if(window_focus_id==W_PLOT )
{
if(index_menus_lighting_plot==1) unselect_all_shapes();
else if( index_menus_lighting_plot==2 || index_menus_lighting_plot==4)
{reset_symbols_selected(view_plot_calc_number_is);}
}
else if(window_focus_id==W_ASKCONFIRM)
{
 substract_a_window(W_ASKCONFIRM);
 substract_a_window(previous_window_focus_id);
 mouse_released=1;
 window_focus_id=previous_window_focus_id;
 add_a_window(window_focus_id);      
}
sprintf(string_key_id,list_keyname[9]);
break;

///////////////////////PAGE UP DOWN POUR FENETRES /////////////////////////////
case KEY_PGUP: 
sprintf(string_key_id,list_keyname[0]);
key_switch_window_up();
break; 
case KEY_PGDN: 
sprintf(string_key_id,list_keyname[0]);
key_switch_window_down();
break; 
//////////////////SPECIAL KEYS ////////////////////////////////////////////////
case  KEY_TILDE://carré
if(window_focus_id==W_PLOT) {index_move_plot_view_port=toggle(index_move_plot_view_port);}
break;

case KEY_F1://dock mode
if (key_shifts & KB_CTRL_FLAG  || index_false_control==1) 
{
reset_indexs_confirmation();
index_ask_confirm=1; 
index_do_overrecord_mem=1;
clear_keybuf();

}
else if (key_shifts & KB_SHIFT_FLAG || index_false_shift==1) 
{
int mem_to_rec=(int)(atof(numeric)*10);

reset_indexs_confirmation();
index_ask_confirm=1; 
index_do_create_mem=1;
}
else
{
index_do_report=0;
index_do_modify=0; 
index_main_clear=0;
index_do_dock=toggle(index_do_dock);

switch (window_focus_id)
{
case W_CHASERS:
index_affect_chaser_to_dock=index_do_dock;
break;   
case W_GRID:
for(int i=0;i<4;i++)
{
if(index_show_grid_player[i]==1)
{
gridplayer_to_affect_is=i; break;
}
}
break;
case W_MOVER:
index_affect_to_dock_mover=index_do_dock;     
break;    
case W_DRAW:
index_affect_draw_to_dock=index_do_dock;
break;
case W_ECHO:
index_affect_echo_to_dock=index_do_dock;
break;
case W_TIME:
index_affect_time=index_do_dock;   
break;
case W_TRACKINGVIDEO:
index_affect_video_tracking_to_dock=index_do_dock; 
break;
case W_TRICHROMY:
index_affect_color_to_dock=index_do_dock; 
break;
case W_AUDIO:
index_affect_audio_to_dock=index_do_dock;
player_to_affect_to_dock=0;
audio_type_for_dock_affectation_is=0;
break;
case W_CFGMENU:
if(config_page_is==1) { index_affect_dmxin=index_do_dock; }
else if(config_page_is==3) {index_do_affect_net_to_dock=index_do_dock; } 
break;
default:
break;      
}

}
break;
      
case KEY_F2:
index_do_dock=0;
index_do_report=0;
index_main_clear=0;
index_do_modify=toggle(index_do_modify);;      
break;      

case KEY_F3:
if (key_shifts & KB_CTRL_FLAG  || index_false_control==1) 
{
index_do_dock=0;
index_do_modify=0; 
index_main_clear=0;
index_do_report=1;
reset_indexs_confirmation();
index_ask_confirm=1; 
index_do_overecord_mem_plus_faders=1;               
}     
else if (key_shifts & KB_SHIFT_FLAG || index_false_shift==1) //creation mémoires en mode merge Faders / seq
{
index_do_dock=0;
index_do_modify=0; 
index_main_clear=0;
index_do_report=1;
int mem_to_rec=(int)(atof(numeric)*10);
reset_indexs_confirmation();
index_ask_confirm=1; 
index_do_create_mem_plus_faders=1;
}
else
{
index_do_dock=0;
index_do_modify=0; 
index_main_clear=0;
index_do_report=toggle(index_do_report); 
}
break;  

case KEY_F4:
index_do_dock=0;
index_do_modify=0; 
index_do_report=0;     
index_main_clear=toggle(index_main_clear);
break;  

case KEY_F5:
              index_type=toggle(index_type);
              sprintf(numeric,"");numeric_postext=0;
break; 

case KEY_F6:
         if(index_time==0){add_a_window(W_TIME);  } 
           else {   substract_a_window(W_TIME); }
break;  

case KEY_F7:
if(index_trichro_window==0){add_a_window(W_TRICHROMY);} 
else  { substract_a_window(W_TRICHROMY);  }
break;  

case KEY_F8:
  if(index_video_window==0){ add_a_window(W_TRACKINGVIDEO); } 
 else{ substract_a_window(W_TRACKINGVIDEO);}
break;  

case KEY_F9:
          if(index_window_sequentiel==0){;add_a_window(W_SEQUENCIEL);}
          else {substract_a_window(W_SEQUENCIEL);}
break;
case KEY_F10:
if (key_shifts & KB_SHIFT_FLAG  || index_false_shift==1) //CONFIG
{
if(index_show_minifaders==0){add_a_window(W_MINIFADERS);}
else {substract_a_window(W_MINIFADERS);}
}
else
{
if(index_show_faders==0){add_a_window(W_FADERS);}
else {substract_a_window(W_FADERS);}
}

break;  

case KEY_F11:
if (key_shifts & KB_SHIFT_FLAG  || index_false_shift==1) //CONFIG
{
if(index_show_config_window==0){add_a_window(W_CFGMENU);}
else {substract_a_window(W_CFGMENU);}     
}
else if (key_shifts & KB_CTRL_FLAG  || index_false_control==1 ) 
{index_blind=toggle(index_blind);   }
else
{
if(index_show_banger_window==0)
          {add_a_window(W_BANGER);mouse_level_for_event=mouse_z;mouse_level_for_banger=mouse_z;}
          else {substract_a_window(W_BANGER);}       
}
break;  
              
case KEY_F12://black out

if (key_shifts & KB_CTRL_FLAG  || index_false_control==1) 
{
index_ask_confirm=1;index_do_quit_with_save=1;
}

else if (key_shifts & KB_SHIFT_FLAG   || index_false_shift==1) 
{
for (int i=0;i<12;i++)
{
specify_who_to_save_load[i]=0;}
reset_save_load_report_string();     
index_ask_confirm=1;index_do_quit_without_save=1;
}

else
{
if(index_blind==0)
{
for (int rs=0;rs<513;rs++)
{bufferSaisie[rs]=0;Selected_Channel[rs]=0;   }   
sprintf(string_Last_Order,">> Black Out done for On Stage channels");      
}     
else if(index_blind==1)
{
for (int rs=0;rs<513;rs++)
{bufferBlind[rs]=0; Selected_Channel[rs]=0;   }    
sprintf(string_Last_Order,">> Black Out done for On Blind channels");                       
}
             
substract_channel_selection_to_layers_plot();
}  
break;    


case KEY_UP:
key_up();
sprintf(string_key_id,list_keyname[1]);
break;

case KEY_DOWN:
key_down();
sprintf(string_key_id,list_keyname[2]);
break;

case KEY_ENTER :
key_affectation();
sprintf(string_key_id,list_keyname[3]);
break; 

case KEY_ENTER_PAD:
key_affectation();
sprintf(string_key_id,list_keyname[4]);
break; 

case KEY_EQUALS://+
key_add_ch();
sprintf(string_key_id,list_keyname[5]);
break;

case KEY_PLUS_PAD://+ num
key_add_ch();
sprintf(string_key_id,list_keyname[6]);
break;

case KEY_MINUS://-
key_minus_ch();
sprintf(string_key_id,list_keyname[7]);
break;

case KEY_MINUS_PAD://- num
key_minus_ch();
sprintf(string_key_id,list_keyname[8]);
break;


case KEY_TAB:
if(numeric_postext>0)
{
key_thruth();
sprintf(string_key_id,list_keyname[10]);
}
else 
{
if(window_focus_id==W_PLOT) {index_tab_on=toggle(index_tab_on); }  
}
break;
////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////TEXT TYPING OR FUNCTIONS CALLING//////////////////////////////////////////

case KEY_SPACE: 
              if (index_type==0)
             {
             key_go();
             }
              else if(index_type==1)
             {
             numeric[numeric_postext]=' ';
             numeric_postext++;
             }
       sprintf(string_key_id,list_keyname[11]);
       break;
             
         

        case KEY_Q: //lettre a
        if (key_shifts & KB_CTRL_FLAG  || index_false_control==1)
        {
        if(index_show_audio_window==0){add_a_window(W_AUDIO);}
        else {substract_a_window(W_AUDIO);}
        reset_audio_indexs_to_dock();       
        }
        else 
        {

             if(index_type==0)
             {
             key_presetvideo(0);
             }
             else  if (index_type==1)
             {
             numeric[numeric_postext]='A';
             numeric_postext++;
             }
         }
         sprintf(string_key_id,list_keyname[12]);
         break;  
       case KEY_B:
           if (index_type==0)
           {
           key_roi(10);
           }
           else if (index_type==1)
           {
           numeric[numeric_postext]='B';
           numeric_postext++;
           }
           sprintf(string_key_id,list_keyname[13]);
           break;
           
        case KEY_C:
            if (index_type==0)
           { 
            if (key_shifts & KB_CTRL_FLAG  || index_false_control==1) 
            {
            if(numeric_postext==0)
            {
            channel_copy();
            }
            else
            {
            snap_mem_to_copy();  
            }
            } 
            else  if (key_shifts & KB_SHIFT_FLAG || index_false_shift==1) 
            {
            if(index_window_chasers==0){add_a_window(W_CHASERS);} 
            else {substract_a_window(W_CHASERS);}
            } 
           else
           {
           key_roi(8);         }
           } 
           else if (index_type==1)
           {
           numeric[numeric_postext]='C';
           numeric_postext++;
           }
           sprintf(string_key_id,list_keyname[14]);
           break;
           
        case KEY_D://dock mode on
           if(index_type==0)
           {
            key_roi(2);
           }
           else if(index_type==1)
           {
           numeric[numeric_postext]='D';
           numeric_postext++;
           }
           sprintf(string_key_id,list_keyname[15]);
           break;
           
        case KEY_E:
            if (index_type==0)
           {
           key_presetvideo(2);
           }
           else if (index_type==1)
           {
           numeric[numeric_postext]='E';
           numeric_postext++;
           }
           sprintf(string_key_id,list_keyname[16]);
           break;
           
        case KEY_F:
           if(index_type==0)
           {
           key_roi(3);
           }
           
           else if (index_type==1)
           {
           numeric[numeric_postext]='F';
           numeric_postext++;
           }
           sprintf(string_key_id,list_keyname[17]);
           break;
           
        case KEY_G:
            if (index_type==0)
           {
           if ((key_shifts & KB_CTRL_FLAG || index_false_control==1 ) && numeric_postext>0)
           {
           //GET CHANNELS FROM A MEMORY     
           int mem_to_take=(int)(atof(numeric)*10);
           if(MemoiresExistantes[mem_to_take]==1)
           {
           Get_channels_from_memory(mem_to_take);  
           }
           else {sprintf(string_Last_Order,"Get Sel. channel from %d.%d: mem doesn't exist",mem_to_take/10,mem_to_take%10);}   
           } 
           else {key_roi(4);}
           }
           else if (index_type==1)
           {
           numeric[numeric_postext]='G';
           numeric_postext++;
           }
           sprintf(string_key_id,list_keyname[18]);
           break;
           
           case KEY_H:

            if (index_type==0)
           {
           key_roi(5);   
           }
           else if (index_type==1)
           {
           numeric[numeric_postext]='H';
           numeric_postext++;
           }
           
           sprintf(string_key_id,list_keyname[19]);
           break;
        
        case KEY_I:    
           if(index_type==0) //full
           {
           key_full();
           }
           else if(index_type==1)
           {
           numeric[numeric_postext]='I';
           numeric_postext++;
           }
         sprintf(string_key_id,list_keyname[20]);
           break;
           
        case KEY_J:
           if (index_type==0)
           {
           key_time_out();
           }        
           if (index_type==1)
           {
           numeric[numeric_postext]='J';
           numeric_postext++;
           }
           sprintf(string_key_id,list_keyname[21]);
           break;
           
        case KEY_K:
            if (index_type==0)
           {
           key_time_in();
           }
           else if (index_type==1)
           {
           numeric[numeric_postext]='K';
           numeric_postext++;
           }
           sprintf(string_key_id,list_keyname[22]);
           break;
           
        case KEY_L://in + out
           if(index_type==0)
           {
           key_time_in_out();
           }
           else if(index_type==1)
           {
           numeric[numeric_postext]='L';
           numeric_postext++;
           }
           sprintf(string_key_id,list_keyname[23]);
           break;
        
        case KEY_SEMICOLON:
           if(index_type==0)//le M qui est point en clavier americain
           {
           if (key_shifts & KB_SHIFT_FLAG || index_false_shift==1) 
           { if(index_show_mover_window=0){add_a_window(W_MOVER);}
           else {substract_a_window(W_MOVER);}}
           }
           else if(index_type==1)
           {
           numeric[numeric_postext]='M';
           numeric_postext++;     
           }
           sprintf(string_key_id,list_keyname[38]);
           break;  
                
        case KEY_N:
           if (index_type==0)
           {
           key_roi(11);          
           } 
           else if (index_type==1)
           {
           numeric[numeric_postext]='N';
           numeric_postext++;
           }
           sprintf(string_key_id,list_keyname[24]);
           break;
           
        case KEY_O:
       
         
           if(index_type==0)
           { 
           key_at_zero();
           }
           else if (index_type==1)
           {
           numeric[numeric_postext]='O';
           numeric_postext++;
           }
           sprintf(string_key_id,list_keyname[25]);
           break;
           
        case KEY_P:

          if (key_shifts & KB_SHIFT_FLAG || index_false_shift==1) 
           {
           if(index_patch_window==0){add_a_window(W_PATCH);}
           else {substract_a_window(W_PATCH);} 
           } 
           else{
           if (index_type==0)
           {
             if(index_visual_pad==0){add_a_window(W_NUMPAD);}
             else {substract_a_window(W_NUMPAD);}  
           }
           else if (index_type==1)
           {
           numeric[numeric_postext]='P';
           numeric_postext++;
           }
           }
           sprintf(string_key_id,list_keyname[39]);
           break;

        case KEY_A: // lettre Q
            if (index_type==0)
           {
           key_roi(1);
            }
           else if (index_type==1)
           {
           numeric[numeric_postext]='Q';
           numeric_postext++;
           }
           sprintf(string_key_id,list_keyname[26]);
           break;        
  
        case KEY_R://report mode on
        if(index_type==0 )
        {
        key_presetvideo(3);;//les banques de tracking cam
        }
        else if(index_type==1)
        {
           numeric[numeric_postext]='R';
           numeric_postext++;
        }
        sprintf(string_key_id,list_keyname[27]);
           break;
           
        case KEY_S:
            if (index_type==0)
           {
           if (key_shifts & KB_CTRL_FLAG  || index_false_control==1) 
           {
           if(index_is_saving==0){index_save_global_is=1;index_do_quick_save=1;}
           }
           else
           {
           key_roi(1);
           }
           }
           else if (index_type==1)
           {
           numeric[numeric_postext]='S';
           numeric_postext++;
           }
           sprintf(string_key_id,list_keyname[28]);
           break;
           
       case KEY_T:
           if(index_type==0)
           {
           key_presetvideo(4);//les banques de tracking cam
           }
           else if (index_type==1)
           {
           numeric[numeric_postext]='T';
           numeric_postext++;
           }         
           sprintf(string_key_id,list_keyname[29]);
           break;
           
        case KEY_U://inverse selection
           if (index_type==0)
           {
           key_select_inv();
           }
           else if (index_type==1)
           {
           numeric[numeric_postext]='U';
           numeric_postext++;
           }
           sprintf(string_key_id,list_keyname[30]);
           break;
           
        case KEY_V:
           if (index_type==0)
           {
           if (key_shifts & KB_CTRL_FLAG  || index_false_control==1) 
           {
           if(numeric_postext==0)
            {
            channel_paste();
            }
            else//si chiffre de mem tapée
            {
            index_copy_mem_in=1; 
            index_ask_confirm=1;
            
            }              
           } 
           else
           {
           //les aires de tracking cam
           key_roi(9);
           }
           }
           else if (index_type==1)
           {
           numeric[numeric_postext]='V';
           numeric_postext++;
           }
           sprintf(string_key_id,list_keyname[31]);
           break;
           
        case KEY_Z://w
           if (index_type==0)
           {
           if(key_shifts )
           {
           key_backward();
           }
           else{//les aires de tracking cam
           key_roi(6);
           }        
           }
           else if (index_type==1)
           {
           numeric[numeric_postext]='W';
           numeric_postext++;
           }
           sprintf(string_key_id,list_keyname[32]);
           break;
           
        case KEY_X:
           if (index_type==0)
           {
           if(key_shifts)
           {
           key_forward();
           }
          
           else{//les aires de tracking cam
           key_roi(7);
           }
           }
           else  if (index_type==1)
           {
           numeric[numeric_postext]='X';
           numeric_postext++;
           }
           sprintf(string_key_id,list_keyname[33]);
           break;
           
        case KEY_Y://select all 
          
          if (index_type==0)
           {
          key_select_all();
           }
           else if (index_type==1)
           {
           numeric[numeric_postext]='Y';
           numeric_postext++;
           }
           sprintf(string_key_id,list_keyname[34]);
           break;
           
        case KEY_W://z
           if (key_shifts & KB_CTRL_FLAG  || index_false_control==1)
             {
             //ctrl Z reload mem as recorded
             index_do_reload_mem=1;
             index_ask_confirm=1;                   
             }
             else if (key_shifts & KB_SHIFT_FLAG || index_false_shift==1)
             {
             //ctrl Z resurrect mem as recorded
             mem_to_resurrect=(int)(atof(numeric)*10);   
             index_do_resurrect_mem=1;  
             index_ask_confirm=1;                            
             }
           else
           {
            if (index_type==0 )
           {
           key_presetvideo(1);//les banques de tracking cam
           }
           else if (index_type==1)
           {
           numeric[numeric_postext]='Z';
           numeric_postext++;
           }
           }
           sprintf(string_key_id,list_keyname[35]);
           break;
           
    case KEY_LEFT:
    key_left(); 
    sprintf(string_key_id,list_keyname[36]);
    break;
       
       case KEY_RIGHT:
       key_right();
       sprintf(string_key_id,list_keyname[37]);
       break;
      
      case KEY_DEL:
      if (key_shifts & KB_SHIFT_FLAG || index_false_shift==1) 
      {
      reset_indexs_confirmation(); 
      index_do_delete_mem=1;  
      index_ask_confirm=1;       
      }
      break;
//////////////////////ENTREES NUMERIQUES COMMUNES//////////////////////////////////////////

case KEY_0:
numeric[numeric_postext]='0';
numeric_postext++;
break;
case KEY_0_PAD:
numeric[numeric_postext]='0';
numeric_postext++;
break;
case KEY_1:
numeric[numeric_postext]='1';
numeric_postext++;
break;
case KEY_1_PAD:
numeric[numeric_postext]='1';
numeric_postext++;
break;

case KEY_2:
numeric[numeric_postext]='2';
numeric_postext++;
break;
case KEY_2_PAD:
numeric[numeric_postext]='2';
numeric_postext++;
break;
case KEY_3:
numeric[numeric_postext]='3';
numeric_postext++;
break;
case KEY_3_PAD:
numeric[numeric_postext]='3';
numeric_postext++;
break;
case KEY_4:
numeric[numeric_postext]='4';
numeric_postext++;
break;
case KEY_4_PAD:
numeric[numeric_postext]='4';
numeric_postext++;
break;
case KEY_5:
numeric[numeric_postext]='5';
numeric_postext++;
break;
case KEY_5_PAD:
numeric[numeric_postext]='5';
numeric_postext++;
break;
case KEY_6:
numeric[numeric_postext]='6';
numeric_postext++;
break;
case KEY_6_PAD:
numeric[numeric_postext]='6';
numeric_postext++;
break;
case KEY_7:
numeric[numeric_postext]='7';
numeric_postext++;
break;
case KEY_7_PAD:
numeric[numeric_postext]='7';
numeric_postext++;
break;
case KEY_8:
numeric[numeric_postext]='8';
numeric_postext++;
break;
case KEY_8_PAD:
numeric[numeric_postext]='8';
numeric_postext++;
break;
case KEY_9:
numeric[numeric_postext]='9';
numeric_postext++;
break;
case KEY_9_PAD:
numeric[numeric_postext]='9';
numeric_postext++;
break;   

case KEY_COMMA:
numeric[numeric_postext]='.';
numeric_postext++;
break;

case  KEY_DEL_PAD:
numeric[numeric_postext]='.';
numeric_postext++;
break;

case  KEY_M:
numeric[numeric_postext]='.';
numeric_postext++;
break;


case KEY_BACKSPACE:
numeric[numeric_postext]=' ';
numeric_postext--;
numeric[numeric_postext]=' ';
if (numeric_postext<0) {numeric_postext=0;}
break;   

////////////////////MISE EN MEMOIRES DES FENETRES ET TOGGLE/////////////////////
case KEY_PRTSCR:
key_printscreen();              
break; 

default:
      
break;
}  
for(int u=0;u<nbre_key_persos;u++)
{
//keys persos
if( (int)(chi & 0xff)==mapping_temporaire[u])
{
switch(u)
{
case 0://AT level
key_affectation();
sprintf(string_key_id,"At Level");//max 16 char
break;
case 1://CH+
key_add_ch();
sprintf(string_key_id,"Ch +");//max 16 char
break;
case 2://CH-
key_minus_ch();
sprintf(string_key_id,"Ch -");//max 16 char     
break;
case 3://CH THRUTH
key_thruth();
sprintf(string_key_id,"To Ch");//max 16 char     
break;
case 4://CLEAR
key_unselect_ch();
sprintf(string_key_id,"Clear");//max 16 char        
break;
default:
break;
}
}
}



   
//protections

if (numeric_postext>maxchar_numeric){numeric[numeric_postext]=' ';numeric_postext=maxchar_numeric-1;}

if (numeric_postext<0) {numeric_postext=0;} 


       
}
sprintf(string_numeric_entry,"<< %s",numeric);


//CTRL-S
if(index_do_quick_save==1 )
      {
      Save_Show();
      sprintf(string_Last_Order,">> Show Saved at %s", tmp_time);
      index_do_quick_save=0;
      }
      
poll_keyboard();
      
return(0);  
}
int do_logical_TheGrid_divers( int xb, int yb, int num_grid_player)
{
//affect to dock
 if(mouse_x>xb+60 && mouse_x<xb+60+50 && mouse_y>yb && mouse_y<yb+30 &&  mouse_released==0)
 {

index_do_dock=index_affect_color_to_dock;
  if(num_grid_player==gridplayer_to_affect_is)
  {
  reset_index_actions();
  index_do_dock=0;
  }
  else  {
        reset_index_actions();
        reset_indexs_confirmation();
        gridplayer_to_affect_is=num_grid_player;
        index_do_dock=1;
        }


  mouse_released=1;
 }

 if(  index_enable_edit_Grider==1 && mouse_x>xb && mouse_x<xb+10 && mouse_y>yb+45 && mouse_y<yb+45+10 && mouse_released==0)
 {
 to_step_editing_mode[num_grid_player]=toggle(to_step_editing_mode[num_grid_player]);
 mouse_released=1;
 }

 if( index_enable_edit_Grider==1 && mouse_x>xb+60 && mouse_x<xb+60+40 && mouse_y>yb+45 && mouse_y<yb+45+15 && mouse_released==0  )
 {
 int tempstepto=atoi(numeric)-1;
 if(tempstepto>index_grider_step_is[num_grid_player] && tempstepto<1023)
 {index_StepTo[num_grid_player]=tempstepto;}
 reset_numeric_entry();
 mouse_released=1;
 }

 ///////////COPY TO ////////////////////////////////////////////////////////////



 //copy mode
 if(  index_enable_edit_Grider==1 && mouse_x>xb && mouse_x<xb+50 && mouse_y>yb+75 && mouse_y<yb+75+15 && mouse_released==0)
 {
  index_for_copy_grid=1;
  index_grid_tostep_or_not=to_step_editing_mode[num_grid_player];
  from_gridstep_to=index_StepTo[num_grid_player];
  destination_grid_for_copy= index_Grid_copyto[num_grid_player][0];
  destination_step_for_copy= index_Grid_copyto[num_grid_player][1];
  grid_to_clear=index_grider_selected[num_grid_player];       //utilisé pour menus confirm
  step_grid_to_clear=index_grider_step_is[num_grid_player]; //utilisé pour les menus confirm
  index_ask_confirm=1;
  mouse_released=1;
 }

  //insert mode
 if( index_enable_edit_Grider==1 &&  mouse_x>xb+55 && mouse_x<xb+55+50 && mouse_y>yb+75 && mouse_y<yb+75+15 )
 {
  index_for_insert_grid=1;
  destination_step_for_copy= index_Grid_copyto[num_grid_player][1];//le nombre de steps à insérer après la position actuelle
  grid_to_clear=index_grider_selected[num_grid_player];       //utilisé pour menus confirm
  step_grid_to_clear=index_grider_step_is[num_grid_player]; //utilisé pour les menus confirm
  index_ask_confirm=1;
  mouse_released=1;
 }
 //grid   entry
 if(index_enable_edit_Grider==1 && mouse_x>xb && mouse_x<xb+30 && mouse_y>yb+95 && mouse_y<yb+95+15 && mouse_released==0)
 {
 int tempstepto=atoi(numeric)-1;
 if(tempstepto>=0 && tempstepto<127)
 {index_Grid_copyto[num_grid_player][0]=tempstepto;}
  reset_numeric_entry();
  mouse_released=1;
 }
 //step entry
 if(index_enable_edit_Grider==1 && mouse_x>xb+45 && mouse_x<xb+45+40 && mouse_y>yb+95 && mouse_y<yb+95+15 && mouse_released==0 )
 {
  int tempstepto=atoi(numeric)-1;
 if(tempstepto>=0 && tempstepto<1023)
 {index_Grid_copyto[num_grid_player][1]=tempstepto;}
  reset_numeric_entry();
  mouse_released=1;
  }

  //snap fader
 if( index_enable_edit_Grider==1  &&  mouse_x>xb && mouse_x<xb+105 && mouse_y>yb+135 && mouse_y<yb+135+15 && mouse_released==0)
 {
 if(index_do_dock==1 && numeric_postext>0)
 {
 int getfad=atoi(numeric)-1;
 if(getfad>=0 && getfad<48)
 {GplSnapFader[num_grid_player]=getfad;}
 reset_numeric_entry();
  mouse_released=1;
  index_do_dock=0;
  }
  else//enregistrement
  {
  for(int i=0;i<513;i++)
   {
   if(i+grider_begin_channel_is+1<513)
   {
   grid_levels[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][i]=FaderDoDmx[(GplSnapFader[num_grid_player])][i+grider_begin_channel_is];
   }
   }
   mouse_released=1;
  }
 }



if(num_grid_player==0 )//asservissement speed au séquenciel
{
if(mouse_x>xb && mouse_x<xb+105 && mouse_y>yb+115 && mouse_y<yb+115+15 && mouse_released==0)
{
if(Midi_Faders_Affectation_Type!=0)
{
 attribute_midi_solo_affectation(1540,Midi_Faders_Affectation_Mode);
}

else
{
index_link_speed_crossfade_to_gpl1=toggle(index_link_speed_crossfade_to_gpl1);
if(index_link_speed_crossfade_to_gpl1==1)
{  grid_crossfade_speed[0]=crossfade_speed;
   midi_levels[1508]=crossfade_speed;
}
}
mouse_released=1;
}
}

return(0);
}
int do_logical_Sequenciel_Window(int xseq, int yseq,int largeur_seq,int hauteur_seq)
{

do_logical_refresh_vision_memories(xseq,yseq);
do_logical_x1_x2(xseq,yseq-25);

////////////////////MENUS///////////////////////////////////////////////////////
//options hautes

///alink
if(mouse_x>xseq+180 && mouse_x<xseq+180+35 && mouse_y>yseq+50 && mouse_y<yseq+50+15)
{
if(index_link_is_on==0){index_link_is_on=1;}
else if(index_link_is_on==1){index_link_is_on=0;}
mouse_released=1;
}

///banger
if(mouse_x>xseq+223 && mouse_x<xseq+263 && mouse_y>yseq+50 && mouse_y<yseq+50+15)
{
index_banger_is_on=toggle(index_banger_is_on);
mouse_released=1;
}

//grid player 1 embeded
if(mouse_x>xseq+275 && mouse_x<xseq+275+30 && mouse_y>yseq+50 && mouse_y<yseq+50+15 )
{
show_gridplayer_in_seq=toggle(show_gridplayer_in_seq);
mouse_released=1;
}



/////menus bas
int rangee_y= yseq+180+(35*(nbre_memoires_visualisables_en_preset+1));
int index_atoi=0;
for (int op=0;op<7;op++)
{
///actions mouse
if(mouse_x>xseq+20+(op*60) && mouse_x<xseq+20+(op*60)+50 && mouse_y>rangee_y && mouse_y<rangee_y+20)
{
switch(op)
{
case 0:         //create
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(768,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
reset_indexs_confirmation();
index_do_create_mem=1;
index_ask_confirm=1;
}
break;
case 1://delete mem
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(769,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
reset_indexs_confirmation();
index_do_delete_mem=1;
index_ask_confirm=1;
}
break;
case 2://stage minus
if(  Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(770,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
    if(index_go==0 && index_go_back==0 && index_pause==0)
           {
           position_onstage=mem_before_one;
           }
           else {index_go=0;index_pause=0; index_go_back=0;}

refresh_mem_onstage(position_onstage);
detect_mem_before_one();
detect_mem_preset();
refresh_mem_onpreset(position_preset);
niveauX1=255; niveauX2=0;
refresh_banger_wx();
refresh_integrated_gridplayer1();
}
break;
case 3://stage +
if(  Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(771,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{

 if(index_go==0 && index_go_back==0 && index_pause==0)
           {
           position_onstage=position_preset;
           }
            else {index_go=0;index_pause=0; index_go_back=0;}

refresh_mem_onstage(position_onstage);
detect_mem_before_one();
detect_mem_preset();
refresh_mem_onpreset(position_preset);
niveauX1=255; niveauX2=0;
refresh_banger_wx();
refresh_integrated_gridplayer1();
}
break;
case 4://preset -
if(Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(772,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
index_go=0;index_pause=0; index_go_back=0;
detect_mem_preset_previous();
refresh_mem_onpreset(position_preset);
niveauX2=0;
}
break;
case 5://preset +
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(773,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
index_go=0;index_pause=0; index_go_back=0;
detect_next_preset();
refresh_mem_onpreset(position_preset);
niveauX2=0;
}
break;
case 6://goto
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1645,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
if(numeric_postext>0)
{
index_atoi=(int)(atof(numeric)*10);
if(MemoiresExistantes[index_atoi]==1)
{
position_preset=index_atoi;
refresh_mem_onpreset(position_preset);
reset_numeric_entry();
numeric_postext=0;
}
}
}
break;

default:
break;
}//fin des switch
mouse_released=1;
}
}

//grid player 1 embarqué
if(show_gridplayer_in_seq==1)
{

//UP DOWN griders number selected

if(mouse_x>xseq+880-12 && mouse_x<xseq+880+12 && mouse_y>yseq+40-12 && mouse_y<yseq+40+12)
{

if(mouse_released==0)
{
if(Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1476,Midi_Faders_Affectation_Mode);
}
else
{
if(index_grider_selected[0]>0)
{index_grider_selected[0]--;}
}
 mouse_released=1;
}
}


if( mouse_x>xseq+910-12 && mouse_x<xseq+910+12 && mouse_y>yseq+40-12 && mouse_y<yseq+40+12)
{

if( mouse_released==0)
{
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1480,Midi_Faders_Affectation_Mode);
}
else
{
if(index_grider_selected[0]<127){index_grider_selected[0]++;}
}
mouse_released=1;
}
}

do_logical_TheStepBox(xseq+660,yseq+90,0);
do_logical_ThePlayCommands(xseq+760,yseq+90,0);
do_logical_TheGrid_commands(xseq+660,yseq+130,0);//pos x, posy y, num player

if(mouse_x>xseq+690 && mouse_x<xseq+690+105 && mouse_y>yseq+295 && mouse_y<yseq+295+15 && mouse_released==0)
{
if( Midi_Faders_Affectation_Type!=0)
{
 attribute_midi_solo_affectation(1540,Midi_Faders_Affectation_Mode);
}

else
{
index_link_speed_crossfade_to_gpl1=toggle(index_link_speed_crossfade_to_gpl1);
if(index_link_speed_crossfade_to_gpl1==1)
{  grid_crossfade_speed[0]=crossfade_speed;
   midi_levels[1508]=crossfade_speed;
}
}
mouse_released=1;
}
}


return(0);
}
int do_logical_refresh_vision_memories( int x_seq, int y_seq)
{
//Manipulation en stage
if(mouse_y>y_seq+110 && mouse_y<y_seq+140)
{
if(mouse_x> x_seq+10 && mouse_x<x_seq+50)//DELAYS
{
affect_time_entry_to_mem(2,position_preset);
mouse_released=1;
}
if(mouse_x> x_seq+50 && mouse_x<x_seq+110)//IN OUT
{
affect_time_entry_to_mem(3,position_preset);
mouse_released=1;
}
if(mouse_x> x_seq+110 && mouse_x<x_seq+170)//MEMS
{
if(index_go==0 && index_pause==0 && index_go_back==0 )
{

call_stage=1;call_preset=0;
do_call_time_and_rec_f1_f2_f3(position_onstage);
mouse_released=1;
}
}
if(mouse_x> x_seq+170 && mouse_x<x_seq+180)//exclude mem from cuelist
{
MemoiresExclues[position_onstage]=toggle(MemoiresExclues[position_onstage]);
mouse_released=1;
}

if(mouse_x> x_seq+185 && mouse_x<x_seq+185+40)//LINKS
{
reset_indexs_confirmation();
index_do_link_memonstage=1;
index_ask_confirm=1;
mouse_released=1;
}
if(mouse_x> x_seq+225 && mouse_x<x_seq+265)//BANGER
{
affect_banger_number=atol(numeric);
if(affect_banger_number>=0 && affect_banger_number<128)
{
reset_indexs_confirmation();
index_do_banger_memonstage=1;
index_ask_confirm=1;
mouse_released=1;
}
else {sprintf(string_Last_Order,">> Wrong entry: banger is between 1 and 127, 0 to desaffect !");}
}

if(mouse_x> x_seq+275 && mouse_x<x_seq+300)//Gridplayer
{
gpl1_affect_step_to_mem=atoi(numeric);
if(gpl1_affect_step_to_mem>=0 && gpl1_affect_step_to_mem<=1024)
{
reset_indexs_confirmation();
index_do_affect_step_gridplayer_to_mem=1;
index_mem_to_be_affected_by_gpl=position_onstage;
index_ask_confirm=1;
mouse_released=1;
}
else {sprintf(string_Last_Order,">> Wrong entry: step is between 1 and 1024, 0 to desaffect !");}
}

if(mouse_x> x_seq+310 && mouse_x<x_seq+470)//TEXT DECRIPTION
{

if(index_type==1)
{

if(mouse_y>y_seq+110 && mouse_y<y_seq+110+15)
{
for(int tt=0;tt<24;tt++)
{
descriptif_memoires[position_onstage][tt]=numeric[tt];
}
descriptif_memoires[position_onstage][24]='\0';
}
else
{
for(int tt=0;tt<24;tt++)
{
annotation_memoires[position_onstage][tt]=numeric[tt];
}
annotation_memoires[position_onstage][24]='\0';
}

reset_numeric_entry();numeric_postext=0;
someone_changed_in_sequences=1;//icat
mouse_released=1;
}
if(index_text_auto_close==1){index_type=0;}

}
}

//Manipulation en preset
if(mouse_y>y_seq+140 && mouse_y<y_seq+170)
{
if(mouse_x> x_seq+10 && mouse_x<x_seq+50)//DELAYS
{
affect_time_entry_to_mem(0,position_preset);
mouse_released=1;
}
if(mouse_x> x_seq+50 && mouse_x<x_seq+110)//IN OUT
{
affect_time_entry_to_mem(1,position_preset);
mouse_released=1;
}
if(mouse_x> x_seq+110 && mouse_x<x_seq+170)//MEMS
{
if(index_go==0 && index_pause==0 && index_go_back==0 )//pas de cross en cours
{

call_preset=1;call_stage=0;
do_call_time_and_rec_f1_f2_f3(position_preset);

mouse_released=1;
}
else if((index_go==1 || index_pause==1 ) && index_go_back==0 ) //cross ou pause en cours
{
 reset_indexs_confirmation();
 index_do_jump_while_cross=1;
 index_ask_confirm=1;
 mouse_released=1;
}
}
if(mouse_x> x_seq+170 && mouse_x<x_seq+180)//exclude mem from cuelist
{
MemoiresExclues[position_preset]=toggle(MemoiresExclues[position_preset]);
mouse_released=1;
}

if(mouse_x> x_seq+185  && mouse_x<x_seq+180+35)//LINKS
{
reset_indexs_confirmation();
index_do_link_memonpreset=1;
index_ask_confirm=1;
mouse_released=1;
}
if(mouse_x> x_seq+225 && mouse_x<x_seq+265)//BANGER
{
affect_banger_number=atol(numeric);
if(affect_banger_number>=0 && affect_banger_number<128)
{
reset_indexs_confirmation();
index_do_banger_memonpreset=1;
index_ask_confirm=1;
mouse_released=1;
}
else {sprintf(string_Last_Order,">> Wrong entry: banger is between 1 and 127 !");}
}
if(mouse_x> x_seq+275 && mouse_x<x_seq+300)//Gridplayer
{
gpl1_affect_step_to_mem=atoi(numeric);
if(gpl1_affect_step_to_mem>=0 && gpl1_affect_step_to_mem<1024)
{
reset_indexs_confirmation();
index_do_affect_step_gridplayer_to_mem=1;
index_mem_to_be_affected_by_gpl=position_preset;
index_ask_confirm=1;
mouse_released=1;
}
else {sprintf(string_Last_Order,">> Wrong entry: step is between 1 and 1023, 0 to desaffect !");}
}
if(mouse_x> x_seq+310 && mouse_x<x_seq+470)//TEXT DECRIPTION
{
if(index_type==1)
{
if(mouse_y>y_seq+140 && mouse_y<y_seq+155)
{
for(int tt=0;tt<24;tt++)
{
descriptif_memoires[position_preset][tt]=numeric[tt];
}
descriptif_memoires[position_preset][24]='\0';
}
else
{
for(int tt=0;tt<24;tt++)
{
annotation_memoires[position_preset][tt]=numeric[tt];
}
annotation_memoires[position_preset][24]='\0';
}
someone_changed_in_sequences=1;//icat
reset_numeric_entry();numeric_postext=0;if(index_text_auto_close==1){index_type=0;}
mouse_released=1;
}

}
}
//MANIPULATIONS MEM BEFORE ONE
if(mouse_y>y_seq+80 && mouse_y< y_seq+100)
{
if(mouse_x> x_seq+170 && mouse_x<x_seq+180)//exclude mem from cuelist
{
MemoiresExclues[mem_before_one]=toggle(MemoiresExclues[mem_before_one]);
mouse_released=1;
}

if(mouse_x> x_seq+185  && mouse_x<x_seq+180+35)//LINKS
{
reset_indexs_confirmation();
index_do_link_membefore=1;
index_ask_confirm=1;
mouse_released=1;
}

if(mouse_x> x_seq+225 && mouse_x<x_seq+265)//BANGER
{
affect_banger_number=atol(numeric);
if(affect_banger_number>=0 && affect_banger_number<128)
{
reset_indexs_confirmation();
index_do_banger_membeforeone=1;
index_ask_confirm=1;
mouse_released=1;
}
else {sprintf(string_Last_Order,">> Wrong entry: banger is between 1 and 127 !");}
}
if(mouse_x> x_seq+275 && mouse_x<x_seq+300)//Gridplayer
{
gpl1_affect_step_to_mem=atoi(numeric);
if(gpl1_affect_step_to_mem>=0 && gpl1_affect_step_to_mem<1024)
{
reset_indexs_confirmation();
index_do_affect_step_gridplayer_to_mem=1;
index_mem_to_be_affected_by_gpl=mem_before_one;
index_ask_confirm=1;
mouse_released=1;
}
else {sprintf(string_Last_Order,">> Wrong entry: step is between 1 and 1023, 0 to desaffect !");}
}
if(mouse_x> x_seq+310 && mouse_x<x_seq+470)//TEXT DECRIPTION
{
if(index_type==1)
{
if(mouse_y>y_seq+80 && mouse_y<y_seq+95)
{
for(int tt=0;tt<24;tt++)
{
descriptif_memoires[mem_before_one][tt]=numeric[tt];
}
descriptif_memoires[mem_before_one][24]='\0';
}
else
{
for(int tt=0;tt<24;tt++)
{
annotation_memoires[mem_before_one][tt]=numeric[tt];
}
annotation_memoires[mem_before_one][24]='\0';
}
reset_numeric_entry();numeric_postext=0;if(index_text_auto_close==1){index_type=0;}
mouse_released=1;
}
}
}


//LES MEMOIRES SUIVANTES USER DEFINED
int index_nbre_mem_visues=0;
//sab 02/03/2014  unused var int last_mem_visue=0;
for(int memsearch=position_preset+1; memsearch<10000;memsearch++)
{
if(memsearch>=9999){memsearch=0;}
if(MemoiresExistantes[memsearch]==1 && index_nbre_mem_visues<nbre_memoires_visualisables_en_preset)
{
index_nbre_mem_visues++;

///ACTIONS
if(mouse_y>y_seq+145+(35*index_nbre_mem_visues)  && mouse_y< y_seq+145+30+(35*index_nbre_mem_visues))
{

if(mouse_x> x_seq+110 && mouse_x<x_seq+170)//MEMS
{
call_stage=0; call_preset=0;
do_call_time_and_rec_f1_f2_f3(memsearch);
mouse_released=1;
}
if(mouse_x> x_seq+170 && mouse_x<x_seq+180)//exclude mem from cuelist
{
MemoiresExclues[memsearch]=toggle(MemoiresExclues[memsearch]);
mouse_released=1;
}

if(mouse_x> x_seq+185  && mouse_x<x_seq+180+35)//LINKS
{
other_mem_in_loop=memsearch;
reset_indexs_confirmation();
index_do_link_memother=1;
index_ask_confirm=1;
mouse_released=1;
}
if(mouse_x> x_seq+225 && mouse_x<x_seq+265)//BANGER
{
affect_banger_number=atol(numeric);
if(affect_banger_number>=0 && affect_banger_number<128)
{
other_mem_in_loop=memsearch;
reset_indexs_confirmation();
index_do_banger_memother=1;
index_ask_confirm=1;
mouse_released=1;
}
else {sprintf(string_Last_Order,">> Wrong entry: banger is between 1 and 127 !");}
}
if(mouse_x> x_seq+275 && mouse_x<x_seq+300)//Gridplayer
{
gpl1_affect_step_to_mem=atoi(numeric);
if(gpl1_affect_step_to_mem>=0 && gpl1_affect_step_to_mem<1024)
{
reset_indexs_confirmation();
index_do_affect_step_gridplayer_to_mem=1;
index_mem_to_be_affected_by_gpl=memsearch;
index_ask_confirm=1;
mouse_released=1;
}
else {sprintf(string_Last_Order,">> Wrong entry: step is between 1 and 1023, 0 to desaffect !");}
}
if(mouse_x> x_seq+310 && mouse_x<x_seq+470)//TEXT DECRIPTION
{
if(index_type==1)
{

if(mouse_y> y_seq+140+(35*index_nbre_mem_visues) && mouse_y < y_seq+140+(35*index_nbre_mem_visues)+15)
{
for(int tt=0;tt<24;tt++)
{
descriptif_memoires[memsearch][tt]=numeric[tt];
}
descriptif_memoires[memsearch][24]='\0';
}
else
{
for(int tt=0;tt<24;tt++)
{
annotation_memoires[memsearch][tt]=numeric[tt];
}
annotation_memoires[memsearch][24]='\0';
}
reset_numeric_entry();numeric_postext=0;if(index_text_auto_close==1){index_type=0;}
mouse_released=1;
}
}
}

if(index_nbre_mem_visues>=nbre_memoires_visualisables_en_preset){break;}

}
}

return(0);
}
int key_affectation()
{
if ((key_shifts & KB_SHIFT_FLAG  || index_false_shift==1) && index_patch_window==1)
{
if(numeric_postext>0)//attribution directe
{
iddim=atoi(numeric);
if(iddim<513 && iddim!=0)
{
Dimmers_selected[iddim]=1;
}
last_dim_selected=iddim;
reset_numeric_entry();
numeric_postext=0;
}

for(int i=0;i<513;i++)
{
if(Dimmers_selected[i]==1)
{
Patch[i]=last_ch_selected;

if(index_build_patch_from_plot==1)
{
for (int l=0;l<4;l++)
{
for(int u=1;u<=nbre_symbols_on_plot[l];u++)
{
//reaffectations frappes clavier
if  ( symbol_is_selected[l][u] == 1 &&  symbol_channel_is[l][u] == last_ch_selected  )
     {symbol_dimmer_is[l][u]= iddim;}
}
}
}

}
}



generate_channel_view_list_from_patched_circuits();
if(index_patch_affect_is_done==1)//reset de ma string de control
{
strcpy(string_monitor_patch,"");
index_patch_affect_is_done=0;
}



char tmp_str_ch[4];
sprintf(tmp_str_ch,"%d",last_ch_selected);
strcat(string_monitor_patch," To Ch:");
strcat(string_monitor_patch,tmp_str_ch);
index_patch_affect_is_done=1;
patch_unselect_all_dimmers();
for (int ci=1;ci<514;ci++)
{Selected_Channel[ci]=0;}
last_ch_selected=0;
}
else if (key_shifts & KB_CTRL_FLAG || index_false_control==1)
{
sprintf(string_Last_Order,">> Setted Time");
read_time_string_entry();
}

else{
if(index_ask_confirm==0)
{
if(index_type==0)
{

//affectation d un niveau a la selection
bool detect_selectch_on=0;
for(int chk_ch=1;chk_ch<514;chk_ch++)
{
if (Selected_Channel[chk_ch]==1){detect_selectch_on=1;}
}
if(detect_selectch_on==1)
{
int chlevelis=0;
if(dmx_view==0)
{
if(atof(numeric)>0)
{
chlevelis=(int)((atof(numeric) *2.55) +1);// + 1 pour arrondir le pourcentage lors de la conversion % -> dmx
}
else {chlevelis=0;}
}
else if (dmx_view==1)
{chlevelis= atol(numeric);}

if(chlevelis>255){chlevelis=255;}
if(chlevelis<0){chlevelis=0;}

 for (int ci=1;ci<514;ci++)
 {
 switch(index_do_hipass)
 {
 case 0://normal
 if(Selected_Channel[ci]==1 && index_blind==0)    {bufferSaisie[ci]=chlevelis;}
 else if(Selected_Channel[ci]==1  && index_blind==1)    {bufferBlind[ci]=chlevelis;}
 break;
 case 1://mode hipass faders
 if(Selected_Channel[ci]==1)
 {
  FaderManipulating=highest_level_comes_from_fader[ci]-1;
  if(DockTypeIs[FaderManipulating][dock_used_by_fader_is[FaderManipulating]]==0)//pas les contenus dynamiques, juste les circuits enregistrés on the fly
  {
   FaderDockContains[FaderManipulating][dock_used_by_fader_is[FaderManipulating]][ci]  =chlevelis;
  }

}
break;
 }
 }
switch(dmx_view)
{
case 0:
sprintf(string_Last_Order,">> Selection AT %d",(int)(chlevelis/2.55));
break;
case 1:
sprintf(string_Last_Order,">> Selection AT %d", chlevelis);
break;
}
reset_numeric_entry();
index_level_attribue=1;
}
}
}
else if(index_ask_confirm==1)
{

  operations_confirmation();

  reset_index_actions();
  reset_indexs_confirmation();

  substract_a_window(W_ASKCONFIRM);
  window_focus_id=previous_window_focus_id;

}
}
 return(0);
}
int do_logical_Interface_Trichromie(int xchroma, int ychroma, int rayon, int largeurchroma)
{

/////////////////TRICHRO / QUADRI CHOOSE//////////////////////////////////////

if(mouse_x>xchroma-60 && mouse_x<xchroma+80 && mouse_y>ychroma-190 && mouse_y<ychroma-160)
{

if(index_quadri==0){index_quadri=1;dock_color_type[dock_color_selected]=1;}
else if(index_quadri==1){index_quadri=0;dock_color_type[dock_color_selected]=0;}
mouse_released=1;
}

/////////////////////AFFECTATION ON / OFF AUX DOCKS FADERS///////////////////////////

if(mouse_x>xchroma+20 && mouse_x<xchroma+150 && mouse_y>ychroma+300 && mouse_y< ychroma+330)
{
if(index_affect_color_to_dock==0)
{
reset_index_actions();
reset_indexs_confirmation();
index_affect_color_to_dock=1;
}
else
{
reset_index_actions();
}
index_do_dock=index_affect_color_to_dock;
mouse_released=1;
}
/////////////////////////////////////////////////////////////////////////////////

//////////////////////ROUE DE COULEUR//////////////////////////////////////////////////////

//AFFECTATION MIDI
if( Midi_Faders_Affectation_Type!=0)//config midi
  {
  //midi report
  switch(miditable[0][497])
  {
  case 0: sprintf(thetypinfo,"Note");break;
  case 1: sprintf(thetypinfo,"Key On");break;
  case 2: sprintf(thetypinfo,"Key Off");break;
  case 4: sprintf(thetypinfo,"Ctrl Change");break;
  }
  sprintf(string_last_midi_id,"COLOR WHEEL FADER is Ch: %d Pitch: %d Typ: %s" , miditable[1][497],miditable[2][497],thetypinfo);

  if(mouse_x>xchroma-140 && mouse_x<xchroma+140 && mouse_y>ychroma-140 && mouse_y<ychroma+140)
  {
    attribute_midi_solo_affectation(497,Midi_Faders_Affectation_Mode);
    mouse_released=1;
   }
}


/////////////////////DOCKING DES COULEURS////////////////////////////////////////
//emplacement des box pour actions de storage RVB sur 6 presets

//affectation des circuits aux RVB Y

if(mouse_y>ychroma+165 && mouse_y<ychroma+185)
{
if(mouse_x> xchroma-130 && mouse_x< xchroma-80 )//RED
{
if (index_inspekt==1){show_who_is_in_dock_color(dock_color_selected,0);}
couleur_to_affect=0;
bool there_is_asel_chan=0;

switch(index_paste_on_the_fly)
{
case 0:
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1)
{there_is_asel_chan=1;break;}
}

if(there_is_asel_chan==1 && (index_do_dock==1|| index_do_modify==1 || index_do_report==1))
{index_do_affect_color_trichro=1;index_ask_confirm=1;}

else {index_do_affect_color_trichro=0;index_ask_confirm=0;sprintf(string_Last_Order,"No channel selected to store as color");}
break;
case 1:
if(index_blind==0)
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferSaisie[p]=my_red;}
}
}
else
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferBlind[p]=my_red;}
}
}
sprintf(string_Last_Order,"Pasted On the Fly RED result");
break;
}
mouse_released=1;
}

else if (mouse_x> xchroma-65 && mouse_x< xchroma-15 )//GREEN
{
if (index_inspekt==1){show_who_is_in_dock_color(dock_color_selected,1);}
couleur_to_affect=1;
bool there_is_asel_chan=0;
switch(index_paste_on_the_fly)
{
case 0:
for(int p=1;p<513;p++)
{if(Selected_Channel[p]==1){there_is_asel_chan=1;break;}}
if(there_is_asel_chan==1 && (index_do_dock==1|| index_do_modify==1 || index_do_report==1))
{index_do_affect_color_trichro=1;index_ask_confirm=1;}
else {sprintf(string_Last_Order,"No channel selected to store as color");}
break;
case 1:
if(index_blind==0)
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferSaisie[p]=my_green;}
}
}
else
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferBlind[p]=my_green;}
}
}
sprintf(string_Last_Order,"Pasted On the Fly GREEN result");
break;
}
mouse_released=1;
}

else if (mouse_x> xchroma && mouse_x< xchroma+50 )//BLUE
{
if (index_inspekt==1){show_who_is_in_dock_color(dock_color_selected,2);}

couleur_to_affect=2;
bool there_is_asel_chan=0;
switch(index_paste_on_the_fly)
{
case 0:
for(int p=1;p<513;p++)
{if(Selected_Channel[p]==1){there_is_asel_chan=1;break;}}
if(there_is_asel_chan==1 && (index_do_dock==1|| index_do_modify==1 || index_do_report==1)){index_do_affect_color_trichro=1;index_ask_confirm=1;}
else {sprintf(string_Last_Order,"No channel selected to store as color");}
break;
case 1:
if(index_blind==0)
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferSaisie[p]=my_blue;}
}
}
else
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferBlind[p]=my_blue;}
}
}
sprintf(string_Last_Order,"Pasted On the Fly BLUE result");
break;
}
mouse_released=1;
}

else if (mouse_x> xchroma+65 && mouse_x< xchroma+115 )//YELLOW
{
if (index_inspekt==1){show_who_is_in_dock_color(dock_color_selected,3);}
couleur_to_affect=3;
bool there_is_asel_chan=0;
switch(index_paste_on_the_fly)
{
case 0:
for(int p=1;p<513;p++)
{if(Selected_Channel[p]==1){there_is_asel_chan=1;break;}}
if(there_is_asel_chan==1&& (index_do_dock==1|| index_do_modify==1 || index_do_report==1)){index_do_affect_color_trichro=1;index_ask_confirm=1;}
else {sprintf(string_Last_Order,"No channel selected to store as color");}
break;
case 1:
if(index_blind==0)
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferSaisie[p]=my_yellow;}
}
}
else
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferBlind[p]=my_yellow;}
}
}
sprintf(string_Last_Order,"Pasted On the Fly YELLOW result");
break;
}
mouse_released=1;
}
}


//midi out de la roue

if(mouse_x> xchroma+140-10 && mouse_x< xchroma+140+10 && mouse_y>ychroma+110-10 && mouse_y<ychroma+110+10)
{

  if(midi_send_out[497]==0){midi_send_out[497]=1; }
  else if(midi_send_out[497]==1){midi_send_out[497]=0; }
  mouse_released=1;
  }

raccrochage_midi_logical_circulaire (xchroma-6, ychroma, 497, 125, 125);

do_colors();//ventilation des niveaux pickés ainsi que distrib dans faders et docks

//premiere rangee de dock colors

for (int dock_color=0;dock_color<4;dock_color++)
{
if(mouse_x>xchroma-130+(65*dock_color) && mouse_x<xchroma-80+(65*dock_color) && mouse_y>ychroma+215 && mouse_y<ychroma+235)
{
if( Midi_Faders_Affectation_Type!=0)
{
if(dock_color==0 && Midi_Faders_Affectation_Type==2)
{attribute_midi_to_control(949,Midi_Faders_Affectation_Type,Midi_Faders_Affectation_Mode);}
else{attribute_midi_solo_affectation(949+dock_color, Midi_Faders_Affectation_Mode);}
}
else
{
dock_color_selected=dock_color;
load_etat_picker_dans_dockcolor(dock_color_selected);
sprintf(string_Last_Order,">>Dock Color Selected %d",(dock_color_selected+1));
mouse_released=1;
}
}
}
//deuxième rangee de dockcolors
for (int dock_colortwo=0;dock_colortwo<4;dock_colortwo++)
{
if(mouse_x>xchroma-130+(65*dock_colortwo) && mouse_x<xchroma-80+(65*dock_colortwo) && mouse_y>ychroma+255 && mouse_y<ychroma+275)
{
if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(949+(dock_colortwo+4), Midi_Faders_Affectation_Mode);
}
else
{
dock_color_selected=dock_colortwo+4;
load_etat_picker_dans_dockcolor(dock_color_selected);
sprintf(string_Last_Order,">>Dock Color Selected %d",dock_color_selected+1);
mouse_released=1;
}
}
}

//PASTE ON THE FLY
if(mouse_x>xchroma-150 && mouse_x<xchroma-20 && mouse_y>ychroma+300 && mouse_y< ychroma+330)
{
if(mouse_b&1 &&  mouse_released==0 && window_focus_id==902)
{
index_paste_on_the_fly=toggle(index_paste_on_the_fly);
mouse_released=1;
}
}
return(0);
}