|
@@ -99,6 +99,50 @@ namespace BansheeEngine
|
|
|
mOSInputHandler->_update();
|
|
mOSInputHandler->_update();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ void Input::_triggerCallbacks()
|
|
|
|
|
+ {
|
|
|
|
|
+ for (auto& event : mQueuedEvents)
|
|
|
|
|
+ {
|
|
|
|
|
+ switch (event.type)
|
|
|
|
|
+ {
|
|
|
|
|
+ case EventType::ButtonDown:
|
|
|
|
|
+ onButtonDown(mButtonDownEvents[event.idx]);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case EventType::ButtonUp:
|
|
|
|
|
+ onButtonUp(mButtonUpEvents[event.idx]);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case EventType::PointerDown:
|
|
|
|
|
+ onPointerPressed(mPointerPressedEvents[event.idx]);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case EventType::PointerUp:
|
|
|
|
|
+ onPointerReleased(mPointerReleasedEvents[event.idx]);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case EventType::PointerDoubleClick:
|
|
|
|
|
+ onPointerDoubleClick(mPointerDoubleClickEvents[event.idx]);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case EventType::PointerMoved:
|
|
|
|
|
+ onPointerMoved(mPointerMovedEvents[event.idx]);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case EventType::TextInput:
|
|
|
|
|
+ onCharInput(mTextInputEvents[event.idx]);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case EventType::Command:
|
|
|
|
|
+ onInputCommand(mCommandEvents[event.idx]);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ mQueuedEvents.clear();
|
|
|
|
|
+ mButtonDownEvents.clear();
|
|
|
|
|
+ mButtonUpEvents.clear();
|
|
|
|
|
+ mPointerPressedEvents.clear();
|
|
|
|
|
+ mPointerReleasedEvents.clear();
|
|
|
|
|
+ mPointerDoubleClickEvents.clear();
|
|
|
|
|
+ mPointerMovedEvents.clear();
|
|
|
|
|
+ mTextInputEvents.clear();
|
|
|
|
|
+ mCommandEvents.clear();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
void Input::inputWindowChanged(RenderWindow& win)
|
|
void Input::inputWindowChanged(RenderWindow& win)
|
|
|
{
|
|
{
|
|
|
if(mRawInputHandler != nullptr)
|
|
if(mRawInputHandler != nullptr)
|
|
@@ -115,15 +159,13 @@ namespace BansheeEngine
|
|
|
|
|
|
|
|
mDevices[deviceIdx].keyStates[code & 0x0000FFFF] = ButtonState::ToggledOn;
|
|
mDevices[deviceIdx].keyStates[code & 0x0000FFFF] = ButtonState::ToggledOn;
|
|
|
|
|
|
|
|
- if(!onButtonDown.empty())
|
|
|
|
|
- {
|
|
|
|
|
- ButtonEvent btnEvent;
|
|
|
|
|
- btnEvent.buttonCode = code;
|
|
|
|
|
- btnEvent.timestamp = timestamp;
|
|
|
|
|
- btnEvent.deviceIdx = deviceIdx;
|
|
|
|
|
|
|
+ ButtonEvent btnEvent;
|
|
|
|
|
+ btnEvent.buttonCode = code;
|
|
|
|
|
+ btnEvent.timestamp = timestamp;
|
|
|
|
|
+ btnEvent.deviceIdx = deviceIdx;
|
|
|
|
|
|
|
|
- onButtonDown(btnEvent);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ mQueuedEvents.push_back(QueuedEvent(EventType::ButtonDown, (UINT32)mButtonDownEvents.size()));
|
|
|
|
|
+ mButtonDownEvents.push_back(btnEvent);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Input::buttonUp(UINT32 deviceIdx, ButtonCode code, UINT64 timestamp)
|
|
void Input::buttonUp(UINT32 deviceIdx, ButtonCode code, UINT64 timestamp)
|
|
@@ -136,15 +178,13 @@ namespace BansheeEngine
|
|
|
else
|
|
else
|
|
|
mDevices[deviceIdx].keyStates[code & 0x0000FFFF] = ButtonState::ToggledOff;
|
|
mDevices[deviceIdx].keyStates[code & 0x0000FFFF] = ButtonState::ToggledOff;
|
|
|
|
|
|
|
|
- if(!onButtonUp.empty())
|
|
|
|
|
- {
|
|
|
|
|
- ButtonEvent btnEvent;
|
|
|
|
|
- btnEvent.buttonCode = code;
|
|
|
|
|
- btnEvent.timestamp = timestamp;
|
|
|
|
|
- btnEvent.deviceIdx = deviceIdx;
|
|
|
|
|
|
|
+ ButtonEvent btnEvent;
|
|
|
|
|
+ btnEvent.buttonCode = code;
|
|
|
|
|
+ btnEvent.timestamp = timestamp;
|
|
|
|
|
+ btnEvent.deviceIdx = deviceIdx;
|
|
|
|
|
|
|
|
- onButtonUp(btnEvent);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ mQueuedEvents.push_back(QueuedEvent(EventType::ButtonUp, (UINT32)mButtonUpEvents.size()));
|
|
|
|
|
+ mButtonUpEvents.push_back(btnEvent);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Input::axisMoved(UINT32 deviceIdx, const RawAxisState& state, UINT32 axis)
|
|
void Input::axisMoved(UINT32 deviceIdx, const RawAxisState& state, UINT32 axis)
|
|
@@ -161,8 +201,8 @@ namespace BansheeEngine
|
|
|
|
|
|
|
|
void Input::cursorMoved(const PointerEvent& event)
|
|
void Input::cursorMoved(const PointerEvent& event)
|
|
|
{
|
|
{
|
|
|
- if(!onPointerMoved.empty())
|
|
|
|
|
- onPointerMoved(event);
|
|
|
|
|
|
|
+ mQueuedEvents.push_back(QueuedEvent(EventType::PointerMoved, (UINT32)mPointerMovedEvents.size()));
|
|
|
|
|
+ mPointerMovedEvents.push_back(event);
|
|
|
|
|
|
|
|
if (mLastPositionSet)
|
|
if (mLastPositionSet)
|
|
|
mPointerDelta = event.screenPos - mPointerPosition;
|
|
mPointerDelta = event.screenPos - mPointerPosition;
|
|
@@ -175,8 +215,8 @@ namespace BansheeEngine
|
|
|
{
|
|
{
|
|
|
mPointerButtonStates[(UINT32)event.button] = ButtonState::ToggledOn;
|
|
mPointerButtonStates[(UINT32)event.button] = ButtonState::ToggledOn;
|
|
|
|
|
|
|
|
- if(!onPointerPressed.empty())
|
|
|
|
|
- onPointerPressed(event);
|
|
|
|
|
|
|
+ mQueuedEvents.push_back(QueuedEvent(EventType::PointerDown, (UINT32)mPointerPressedEvents.size()));
|
|
|
|
|
+ mPointerPressedEvents.push_back(event);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Input::cursorReleased(const PointerEvent& event)
|
|
void Input::cursorReleased(const PointerEvent& event)
|
|
@@ -186,33 +226,31 @@ namespace BansheeEngine
|
|
|
else
|
|
else
|
|
|
mPointerButtonStates[(UINT32)event.button] = ButtonState::ToggledOff;
|
|
mPointerButtonStates[(UINT32)event.button] = ButtonState::ToggledOff;
|
|
|
|
|
|
|
|
- if(!onPointerReleased.empty())
|
|
|
|
|
- onPointerReleased(event);
|
|
|
|
|
|
|
+ mQueuedEvents.push_back(QueuedEvent(EventType::PointerUp, (UINT32)mPointerReleasedEvents.size()));
|
|
|
|
|
+ mPointerReleasedEvents.push_back(event);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Input::cursorDoubleClick(const PointerEvent& event)
|
|
void Input::cursorDoubleClick(const PointerEvent& event)
|
|
|
{
|
|
{
|
|
|
mPointerDoubleClicked = true;
|
|
mPointerDoubleClicked = true;
|
|
|
|
|
|
|
|
- if(!onPointerDoubleClick.empty())
|
|
|
|
|
- onPointerDoubleClick(event);
|
|
|
|
|
|
|
+ mQueuedEvents.push_back(QueuedEvent(EventType::PointerDoubleClick, (UINT32)mPointerDoubleClickEvents.size()));
|
|
|
|
|
+ mPointerDoubleClickEvents.push_back(event);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Input::inputCommandEntered(InputCommandType commandType)
|
|
void Input::inputCommandEntered(InputCommandType commandType)
|
|
|
{
|
|
{
|
|
|
- if(!onInputCommand.empty())
|
|
|
|
|
- onInputCommand(commandType);
|
|
|
|
|
|
|
+ mQueuedEvents.push_back(QueuedEvent(EventType::Command, (UINT32)mCommandEvents.size()));
|
|
|
|
|
+ mCommandEvents.push_back(commandType);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Input::charInput(UINT32 chr)
|
|
void Input::charInput(UINT32 chr)
|
|
|
{
|
|
{
|
|
|
- if(!onCharInput.empty())
|
|
|
|
|
- {
|
|
|
|
|
- TextInputEvent textInputEvent;
|
|
|
|
|
- textInputEvent.textChar = chr;
|
|
|
|
|
|
|
+ TextInputEvent textInputEvent;
|
|
|
|
|
+ textInputEvent.textChar = chr;
|
|
|
|
|
|
|
|
- onCharInput(textInputEvent);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ mQueuedEvents.push_back(QueuedEvent(EventType::TextInput, (UINT32)mTextInputEvents.size()));
|
|
|
|
|
+ mTextInputEvents.push_back(textInputEvent);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
float Input::getAxisValue(UINT32 type, UINT32 deviceIdx) const
|
|
float Input::getAxisValue(UINT32 type, UINT32 deviceIdx) const
|