Skip to content
Snippets Groups Projects
Commit 118b7985 authored by Sebastian Pape's avatar Sebastian Pape
Browse files

Using different EventIDs for different purposes

parent 3142c8a5
No related branches found
No related tags found
1 merge request!2Backporting many features from the study on top of the Dasher3D-Core
...@@ -60,11 +60,9 @@ FReply SDasherWidget::HandleMouseDownEvent(const FGeometry& Geometry, const FPoi ...@@ -60,11 +60,9 @@ FReply SDasherWidget::HandleMouseDownEvent(const FGeometry& Geometry, const FPoi
if(URWTHVRUtilities::IsRoomMountedMode()) if(URWTHVRUtilities::IsRoomMountedMode())
{ {
FDisplayClusterClusterEventBinary ClusterEvent; FDisplayClusterClusterEventBinary ClusterEvent;
ClusterEvent.EventId = DasherEventID; ClusterEvent.EventId = DasherEventID + static_cast<uint8>(DasherEventType::Input_MouseDown);
ClusterEvent.EventData.SetNumUninitialized(1);
ClusterEvent.EventData[0] = static_cast<uint8>(DasherEventType::Input_MouseDown);
IDisplayCluster::Get().GetClusterMgr()->EmitClusterEventBinary(ClusterEvent, false); IDisplayCluster::Get().GetClusterMgr()->EmitClusterEventBinary(ClusterEvent, false);
UE_LOG(LogTemp, Log, TEXT("MouseDownSend"));
return FReply::Handled().LockMouseToWidget(AsShared()); return FReply::Handled().LockMouseToWidget(AsShared());
} }
...@@ -84,9 +82,7 @@ FReply SDasherWidget::HandleMouseUpEvent(const FGeometry& Geometry, const FPoint ...@@ -84,9 +82,7 @@ FReply SDasherWidget::HandleMouseUpEvent(const FGeometry& Geometry, const FPoint
if(URWTHVRUtilities::IsRoomMountedMode()) if(URWTHVRUtilities::IsRoomMountedMode())
{ {
FDisplayClusterClusterEventBinary ClusterEvent; FDisplayClusterClusterEventBinary ClusterEvent;
ClusterEvent.EventId = DasherEventID; ClusterEvent.EventId = ClusterEvent.EventId = DasherEventID + static_cast<uint8>(DasherEventType::Input_MouseUp);
ClusterEvent.EventData.SetNumUninitialized(1);
ClusterEvent.EventData[0] = static_cast<uint8>(DasherEventType::Input_MouseUp);
IDisplayCluster::Get().GetClusterMgr()->EmitClusterEventBinary(ClusterEvent, false); IDisplayCluster::Get().GetClusterMgr()->EmitClusterEventBinary(ClusterEvent, false);
return FReply::Handled().ReleaseMouseLock(); return FReply::Handled().ReleaseMouseLock();
} }
...@@ -110,9 +106,7 @@ FReply SDasherWidget::HandleMouseDoubleClickEvent(const FGeometry& Geometry, con ...@@ -110,9 +106,7 @@ FReply SDasherWidget::HandleMouseDoubleClickEvent(const FGeometry& Geometry, con
if(URWTHVRUtilities::IsRoomMountedMode()) if(URWTHVRUtilities::IsRoomMountedMode())
{ {
FDisplayClusterClusterEventBinary ClusterEvent; FDisplayClusterClusterEventBinary ClusterEvent;
ClusterEvent.EventId = DasherEventID; ClusterEvent.EventId = ClusterEvent.EventId = DasherEventID + static_cast<uint8>(DasherEventType::Input_MouseDown);
ClusterEvent.EventData.SetNumUninitialized(1);
ClusterEvent.EventData[0] = static_cast<uint8>(DasherEventType::Input_MouseDown);
IDisplayCluster::Get().GetClusterMgr()->EmitClusterEventBinary(ClusterEvent, false); IDisplayCluster::Get().GetClusterMgr()->EmitClusterEventBinary(ClusterEvent, false);
return FReply::Handled(); return FReply::Handled();
} }
...@@ -146,13 +140,12 @@ bool SDasherWidget::GetScreenCoords(screenint& iX, screenint& iY, Dasher::CDashe ...@@ -146,13 +140,12 @@ bool SDasherWidget::GetScreenCoords(screenint& iX, screenint& iY, Dasher::CDashe
void SDasherWidget::HandleClusterEvent(const FDisplayClusterClusterEventBinary& Event) void SDasherWidget::HandleClusterEvent(const FDisplayClusterClusterEventBinary& Event)
{ {
if(Event.EventId != DasherEventID) return; switch(static_cast<DasherEventType>(Event.EventId - DasherEventID))
switch(static_cast<DasherEventType>(Event.EventData[0]))
{ {
case DasherEventType::Input_MouseDown: case DasherEventType::Input_MouseDown:
DasherMainInterface->KeyDown(FDateTime::Now().GetSecond() + FDateTime::Now().GetMillisecond(), Dasher::Keys::Primary_Input); DasherMainInterface->KeyDown(FDateTime::Now().GetSecond() + FDateTime::Now().GetMillisecond(), Dasher::Keys::Primary_Input);
MouseDownListeners.ExecuteIfBound(); MouseDownListeners.ExecuteIfBound();
UE_LOG(LogTemp, Log, TEXT("MouseDownReceived"));
break; break;
case DasherEventType::Input_MouseUp: case DasherEventType::Input_MouseUp:
DasherMainInterface->KeyUp(FDateTime::Now().GetSecond() + FDateTime::Now().GetMillisecond(), Dasher::Keys::Primary_Input); DasherMainInterface->KeyUp(FDateTime::Now().GetSecond() + FDateTime::Now().GetMillisecond(), Dasher::Keys::Primary_Input);
...@@ -161,9 +154,9 @@ void SDasherWidget::HandleClusterEvent(const FDisplayClusterClusterEventBinary& ...@@ -161,9 +154,9 @@ void SDasherWidget::HandleClusterEvent(const FDisplayClusterClusterEventBinary&
case DasherEventType::Tick: case DasherEventType::Tick:
double currentTime = 0; double currentTime = 0;
FMemory::Memcpy(&currentTime, &Event.EventData[1], sizeof(currentTime)); FMemory::Memcpy(&currentTime, Event.EventData.GetData(), sizeof(currentTime));
FMemory::Memcpy(&CursorPosition.x, &Event.EventData[1] + sizeof(currentTime), sizeof(CursorPosition.x)); FMemory::Memcpy(&CursorPosition.x, Event.EventData.GetData() + sizeof(currentTime), sizeof(CursorPosition.x));
FMemory::Memcpy(&CursorPosition.y, &Event.EventData[1] + sizeof(currentTime) + sizeof(CursorPosition.x), sizeof(CursorPosition.y)); FMemory::Memcpy(&CursorPosition.y, Event.EventData.GetData() + sizeof(currentTime) + sizeof(CursorPosition.x), sizeof(CursorPosition.y));
DasherMainInterface->Tick(static_cast<unsigned long>(currentTime * 1000.0)); DasherMainInterface->Tick(static_cast<unsigned long>(currentTime * 1000.0));
break; break;
...@@ -305,16 +298,13 @@ void SDasherWidget::Tick(const FGeometry& AllottedGeometry, const double InCurre ...@@ -305,16 +298,13 @@ void SDasherWidget::Tick(const FGeometry& AllottedGeometry, const double InCurre
else else
if(URWTHVRUtilities::IsPrimaryNode()) if(URWTHVRUtilities::IsPrimaryNode())
{ {
UE_LOG(LogTemp, Log, TEXT("EventSend: %d, %d"), CursorPosition.x, CursorPosition.y);
FDisplayClusterClusterEventBinary ClusterEvent; FDisplayClusterClusterEventBinary ClusterEvent;
ClusterEvent.EventId = DasherEventID; ClusterEvent.EventId = ClusterEvent.EventId = DasherEventID + static_cast<uint8>(DasherEventType::Tick);
ClusterEvent.EventData.SetNumUninitialized(sizeof(InCurrentTime) + sizeof(CursorPosition.x) + sizeof(CursorPosition.y) + 1); ClusterEvent.EventData.SetNumUninitialized(sizeof(InCurrentTime) + sizeof(CursorPosition.x) + sizeof(CursorPosition.y));
ClusterEvent.EventData[0] = static_cast<uint8>(DasherEventType::Tick); FMemory::Memcpy(ClusterEvent.EventData.GetData(), &InCurrentTime, sizeof(InCurrentTime));
FMemory::Memcpy(&ClusterEvent.EventData[1], &InCurrentTime, sizeof(InCurrentTime)); FMemory::Memcpy(ClusterEvent.EventData.GetData() + sizeof(InCurrentTime), &CursorPosition.x, sizeof(CursorPosition.x));
FMemory::Memcpy(&ClusterEvent.EventData[1] + sizeof(InCurrentTime), &CursorPosition.x, sizeof(CursorPosition.x)); FMemory::Memcpy(ClusterEvent.EventData.GetData() + sizeof(InCurrentTime) + sizeof(CursorPosition.x), &CursorPosition.y, sizeof(CursorPosition.y));
FMemory::Memcpy(&ClusterEvent.EventData[1] + sizeof(InCurrentTime) + sizeof(CursorPosition.x), &CursorPosition.y, sizeof(CursorPosition.y));
IDisplayCluster::Get().GetClusterMgr()->EmitClusterEventBinary(ClusterEvent, false); IDisplayCluster::Get().GetClusterMgr()->EmitClusterEventBinary(ClusterEvent, false);
} }
......
...@@ -175,7 +175,7 @@ private: ...@@ -175,7 +175,7 @@ private:
//CAVE Sync //CAVE Sync
FOnClusterEventBinaryListener ClusterEventListener; FOnClusterEventBinaryListener ClusterEventListener;
inline static int32 DasherEventID = 424242; inline static int32 DasherEventID = 424240;
protected: protected:
// stores color information // stores color information
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment