aboutsummaryrefslogtreecommitdiff
path: root/core/qmpmidiplay.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2019-11-02 22:13:32 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2019-11-02 22:13:32 +0800
commitb2ef363f49db70219ac1eaebb7d69dcdade8d60b (patch)
treecfc0e8da88dc27b62578dccbce367736e020f63d /core/qmpmidiplay.cpp
parent23525e2a648a23f099c2b533aa91839a2f8e829f (diff)
downloadQMidiPlayer-b2ef363f49db70219ac1eaebb7d69dcdade8d60b.tar.xz
Keyboard plugin: show additional information on the side.
qmpPluginAPI::registerEventHandler now accepts an optional argument that determines whether the handler is called prior to or after an event is sent.
Diffstat (limited to 'core/qmpmidiplay.cpp')
-rw-r--r--core/qmpmidiplay.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/core/qmpmidiplay.cpp b/core/qmpmidiplay.cpp
index 46a2dae..2992e06 100644
--- a/core/qmpmidiplay.cpp
+++ b/core/qmpmidiplay.cpp
@@ -20,7 +20,8 @@ bool CMidiPlayer::processEvent(const SEvent *e)
for(int i=0;i<16;++i)if(eventHandlerCB[i])
eventHandlerCB[i]->callBack((void*)&fe,eventHandlerCBuserdata[i]);
for(auto i=event_handlers.begin();i!=event_handlers.end();++i)
- i->second.first((void*)e,i->second.second);
+ if(!std::get<2>(i->second))
+ std::get<0>(i->second)((void*)e,std::get<1>(i->second));
uint8_t ch=e->type&0x0F;
if((e->type&0xF0)<0xF0)
levtt[ch]=std::chrono::system_clock::now();
@@ -195,11 +196,16 @@ void CMidiPlayer::playEvents()
//fprintf(stderr,"@ tick %u, dtime %.6fus",getTick(),_dt/1000.);
}
for(;!tcstop&&midiReaders&&tceptr<ecnt&&ct==getEvent(tceptr)->time;++tceptr)
+ {
if(processEvent(getEvent(tceptr)))
{
SEvent* e=getEvent(tceptr);
mididev[mappedoutput[e->type&0x0F]].dev->basicMessage(e->type,e->p1,e->p2);
}
+ for(auto i=event_handlers.begin();i!=event_handlers.end();++i)
+ if(std::get<2>(i->second))
+ std::get<0>(i->second)((void*)getEvent(tceptr),std::get<1>(i->second));
+ }
if(tcstop||!midiReaders||tceptr>=ecnt)break;
high_resolution_clock::time_point a=high_resolution_clock::now();
auto sendtime=a-b;
@@ -553,10 +559,10 @@ int CMidiPlayer::setFileReadFinishedCB(ICallBack *cb,void *userdata)
}
void CMidiPlayer::unsetFileReadFinishedCB(int id)
{fileReadFinishCB[id]=nullptr;fileReadFinishCBuserdata[id]=nullptr;}
-int CMidiPlayer::registerEventHandler(callback_t cb,void *userdata)
+int CMidiPlayer::registerEventHandler(callback_t cb,void *userdata,bool post)
{
int ret;
- event_handlers[ret=event_handlers_id++]=std::make_pair(cb,userdata);
+ event_handlers[ret=event_handlers_id++]=std::make_tuple(cb,userdata,post);
return ret;
}
void CMidiPlayer::unregisterEventHandler(int id)