InputEvent相关函数、变量改名
This commit is contained in:
@@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
#include<hgl/type/SortedSet.h>
|
#include<hgl/type/SortedSet.h>
|
||||||
#include<hgl/io/event/InputEventSource.h>
|
#include<hgl/io/event/InputEventSource.h>
|
||||||
|
|
||||||
namespace hgl::io
|
namespace hgl::io
|
||||||
{
|
{
|
||||||
struct EventHeader
|
struct EventHeader
|
||||||
{
|
{
|
||||||
InputEventSource type; ///<输入源类型
|
InputEventSource type; ///<输入源类型
|
||||||
uint8 index; ///<输入源索引(比如同一设备有多个)
|
uint8 index; ///<输入源索引(比如同一设备有多个)
|
||||||
uint16 id; ///<事件id
|
uint16 id; ///<事件id
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr size_t EventHeaderBytes=sizeof(EventHeader);
|
constexpr size_t EventHeaderBytes=sizeof(EventHeader);
|
||||||
@@ -26,11 +27,13 @@ namespace hgl::io
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
InputEventSource source_type;
|
InputEventSource source_type;
|
||||||
|
|
||||||
InputEvent *parent_input_event;
|
InputEvent * parent_input_event;
|
||||||
|
|
||||||
SortedSet<InputEvent *> sub_event_proc;
|
SortedSet<InputEvent *> event_dispatch_subscribers;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
void SetParent(InputEvent *ie){parent_input_event=ie;}
|
void SetParent(InputEvent *ie){parent_input_event=ie;}
|
||||||
|
|
||||||
@@ -43,9 +46,9 @@ namespace hgl::io
|
|||||||
if(!RangeCheck(header.type))
|
if(!RangeCheck(header.type))
|
||||||
return(EventProcResult::Break);
|
return(EventProcResult::Break);
|
||||||
|
|
||||||
if(!sub_event_proc.IsEmpty())
|
if(!event_dispatch_subscribers.IsEmpty())
|
||||||
{
|
{
|
||||||
for(InputEvent *ie:sub_event_proc)
|
for(InputEvent *ie:event_dispatch_subscribers)
|
||||||
if(ie->OnEvent(header,data)==EventProcResult::Break)
|
if(ie->OnEvent(header,data)==EventProcResult::Break)
|
||||||
return EventProcResult::Break;
|
return EventProcResult::Break;
|
||||||
}
|
}
|
||||||
@@ -70,10 +73,10 @@ namespace hgl::io
|
|||||||
virtual ~InputEvent()
|
virtual ~InputEvent()
|
||||||
{
|
{
|
||||||
if(parent_input_event)
|
if(parent_input_event)
|
||||||
parent_input_event->Unjoin(this);
|
parent_input_event->UnregistryEventDispatch(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool Join(InputEvent *ie)
|
virtual bool RegistryEventDispatch(InputEvent *ie)
|
||||||
{
|
{
|
||||||
if(!ie)
|
if(!ie)
|
||||||
return(false);
|
return(false);
|
||||||
@@ -85,10 +88,10 @@ namespace hgl::io
|
|||||||
|
|
||||||
ie->SetParent(this);
|
ie->SetParent(this);
|
||||||
|
|
||||||
return(sub_event_proc.Add(ie)!=-1);
|
return(event_dispatch_subscribers.Add(ie)!=-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Unjoin(InputEvent *ie)
|
bool UnregistryEventDispatch(InputEvent *ie)
|
||||||
{
|
{
|
||||||
if(!ie)return(false);
|
if(!ie)return(false);
|
||||||
|
|
||||||
@@ -99,7 +102,7 @@ namespace hgl::io
|
|||||||
|
|
||||||
ie->SetParent(nullptr);
|
ie->SetParent(nullptr);
|
||||||
|
|
||||||
return sub_event_proc.Delete(ie);
|
return event_dispatch_subscribers.Delete(ie);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool Update(){return true;}
|
virtual bool Update(){return true;}
|
||||||
|
Reference in New Issue
Block a user