This commit is contained in:
parent
ef77c8f3bb
commit
c9b118bbe0
3 changed files with 33 additions and 32 deletions
|
|
@ -140,6 +140,7 @@ namespace DMX2
|
|||
|
||||
public void EventCallBack (EventData data)
|
||||
{
|
||||
Console.WriteLine("Event {0} => {1}",data.id,data.value);
|
||||
if (bindings.ContainsKey (data.id)) {
|
||||
foreach (IEventTarget target in bindings[data.id].Targets) {
|
||||
target.FireEvent(data);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace DMX2
|
|||
{
|
||||
public partial class MidiEventProvider
|
||||
{
|
||||
const string ASOUND_LIB_NAME = "libasound.so";
|
||||
const string ASOUND_LIB_NAME = "libasound.so.2";
|
||||
const int SND_SEQ_NONBLOCK = 1;
|
||||
const int SND_SEQ_OPEN_INPUT = 1;
|
||||
const int SND_SEQ_OPEN_OUTPUT = 2;
|
||||
|
|
|
|||
|
|
@ -15,16 +15,6 @@ namespace DMX2
|
|||
internalName=_id;
|
||||
description=_desc;
|
||||
}
|
||||
bool hasTargets;
|
||||
|
||||
public bool HasTargets {
|
||||
get {
|
||||
return hasTargets;
|
||||
}
|
||||
set {
|
||||
hasTargets = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<string,internalEvent> eventlist = new Dictionary<string, internalEvent>();
|
||||
|
|
@ -59,28 +49,34 @@ namespace DMX2
|
|||
|
||||
bool IEventProvider.Bind (string eventId)
|
||||
{
|
||||
if (!eventlist.ContainsKey (eventId)) {
|
||||
return false;
|
||||
}
|
||||
//TODO
|
||||
eventlist[eventId].HasTargets = true;
|
||||
// TODO : check if "MIDI ..."
|
||||
return true;
|
||||
}
|
||||
|
||||
void IEventProvider.Unbind (string eventId)
|
||||
{
|
||||
if (!eventlist.ContainsKey (eventId)) return;
|
||||
eventlist[eventId].HasTargets =false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Gtk.Menu IEventProvider.GetProviderSubMenu (EventManager.EventMenuData state, Gtk.ButtonPressEventHandler handler)
|
||||
{
|
||||
Gtk.Menu retmenu = new Gtk.Menu ();
|
||||
//Gtk.MenuItem evmenuitem = new Gtk.MenuItem ("Events");
|
||||
//retmenu.Add (evmenuitem);
|
||||
Gtk.Menu evmenu = retmenu ;// new Gtk.Menu ();
|
||||
//evmenuitem.Submenu = evmenu;
|
||||
if (levent != null) {
|
||||
Gtk.MenuItem lmenuitem = new Gtk.MenuItem ("Dernier");
|
||||
retmenu.Add (lmenuitem);
|
||||
Gtk.Menu lmenu = new Gtk.Menu ();
|
||||
lmenuitem.Submenu = lmenu;
|
||||
Gtk.MenuItem item = new Gtk.MenuItem(levent.description);
|
||||
item.Data[EventManager.EventIdKey] = levent.internalName;
|
||||
item.Data[EventManager.StateKey] = state;
|
||||
item.ButtonPressEvent += handler;
|
||||
lmenu.Add (item);
|
||||
}
|
||||
Gtk.MenuItem evmenuitem = new Gtk.MenuItem ("Events");
|
||||
retmenu.Add (evmenuitem);
|
||||
Gtk.Menu evmenu = new Gtk.Menu ();
|
||||
evmenuitem.Submenu = evmenu;
|
||||
|
||||
List<string> sortedKeys = new List<string>(eventlist.Keys);
|
||||
sortedKeys.Sort();
|
||||
|
|
@ -98,6 +94,8 @@ namespace DMX2
|
|||
|
||||
}
|
||||
|
||||
EventData last; internalEvent levent=null;
|
||||
|
||||
void IEventProvider.ProcessEvents (EventManagerCallback callback)
|
||||
{
|
||||
IntPtr evPtr;
|
||||
|
|
@ -124,28 +122,30 @@ namespace DMX2
|
|||
description = string.Format("Note {1} Ch {0}",evS.data_ev_note.channel, evS.data_ev_note.note );
|
||||
value = 0;
|
||||
break;
|
||||
case snd_seq_event_type_t.SND_SEQ_EVENT_CLOCK:
|
||||
case snd_seq_event_type_t.SND_SEQ_EVENT_SENSING:
|
||||
continue;
|
||||
|
||||
//TODO : Regarder si d'autres controles interessants.
|
||||
default:
|
||||
id= null;
|
||||
Info.Publish(string.Format ("event {0}", evS.type) );
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(id!=null)
|
||||
{
|
||||
if(!eventlist.ContainsKey(id))
|
||||
eventlist.Add(id,new internalEvent(id,description));
|
||||
else{
|
||||
if(eventlist[id].HasTargets)
|
||||
{
|
||||
levent= eventlist[id];
|
||||
EventData evData = new EventData();
|
||||
evData.id = id;
|
||||
evData.value = (byte)value;
|
||||
if(evData.Equals(last)) continue;
|
||||
callback(evData);
|
||||
last = evData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue