Skip to content
Permalink
Browse files

Browser keyValue

Signed-off-by: Peter Kovacs <peter.kovacs@sztaki.mta.hu>
  • Loading branch information...
pkovacs86 committed Nov 30, 2017
1 parent 7abd5bc commit 15633608f6f411ccc64df70d9e194fd955c8f3d8
@@ -220,6 +220,7 @@ namespace Ape
BROWSER_MOUSE_CLICK,
BROWSER_MOUSE_SCROLL,
BROWSER_MOUSE_MOVED,
BROWSER_KEY_VALUE,
BROWSER_DELETE,
WATER_CREATE = (WATER << 8) + 1,
WATER_SKY,
@@ -95,6 +95,10 @@ namespace Ape
virtual void mouseScroll(Ape::Vector2 delta) = 0;

virtual Ape::Browser::MouseState getMouseState() = 0;

virtual void keyASCIIValue(int keyASCIIValue) = 0;

virtual int getLastKeyASCIIValue() = 0;
};
}

@@ -36,6 +36,7 @@ Ape::BrowserImpl::BrowserImpl(std::string name, bool isHostCreated) : Ape::IBrow
mMouseScrollDelta = Ape::Vector2();
mMouseLastPosition = Ape::Vector2();
mID = 0;
mLastKeyValue = 0;
}

Ape::BrowserImpl::~BrowserImpl()
@@ -128,6 +129,16 @@ Ape::Browser::MouseState Ape::BrowserImpl::getMouseState()
return Ape::Browser::MouseState(mMouseLastPosition, mMouseLastClick, mMouseScrollDelta);
}

void Ape::BrowserImpl::keyASCIIValue(int keyASCIIValue)
{
mLastKeyValue = keyASCIIValue;
mpEventManagerImpl->fireEvent(Ape::Event(mName, Ape::Event::Type::BROWSER_KEY_VALUE));
}

int Ape::BrowserImpl::getLastKeyASCIIValue()
{
return mLastKeyValue;
}

void Ape::BrowserImpl::WriteAllocationID(RakNet::Connection_RM3 *destinationConnection, RakNet::BitStream *allocationIdBitstream) const
{
@@ -146,6 +157,7 @@ RakNet::RM3SerializationResult Ape::BrowserImpl::Serialize(RakNet::SerializePara
mVariableDeltaSerializer.SerializeVariable(&serializationContext, mMouseLastPosition);
mVariableDeltaSerializer.SerializeVariable(&serializationContext, mMouseLastClick);
mVariableDeltaSerializer.SerializeVariable(&serializationContext, mMouseScrollDelta);
mVariableDeltaSerializer.SerializeVariable(&serializationContext, mLastKeyValue);
mVariableDeltaSerializer.SerializeVariable(&serializationContext, RakNet::RakString(mGeometryName.c_str()));
mVariableDeltaSerializer.EndSerialize(&serializationContext);
return RakNet::RM3SR_SERIALIZED_ALWAYS;
@@ -171,6 +183,8 @@ void Ape::BrowserImpl::Deserialize(RakNet::DeserializeParameters *deserializePar
mpEventManagerImpl->fireEvent(Ape::Event(mName, Ape::Event::Type::BROWSER_MOUSE_CLICK));
if (mVariableDeltaSerializer.DeserializeVariable(&deserializationContext, mMouseScrollDelta))
mpEventManagerImpl->fireEvent(Ape::Event(mName, Ape::Event::Type::BROWSER_MOUSE_SCROLL));
if (mVariableDeltaSerializer.DeserializeVariable(&deserializationContext, mLastKeyValue))
mpEventManagerImpl->fireEvent(Ape::Event(mName, Ape::Event::Type::BROWSER_KEY_VALUE));
RakNet::RakString geometryName;
if (mVariableDeltaSerializer.DeserializeVariable(&deserializationContext, geometryName))
{
@@ -66,6 +66,10 @@ namespace Ape

Ape::Browser::MouseState getMouseState() override;

void keyASCIIValue(int keyASCIIValue) override;

int getLastKeyASCIIValue() override;

void WriteAllocationID(RakNet::Connection_RM3 *destinationConnection, RakNet::BitStream *allocationIdBitstream) const override;

RakNet::RM3SerializationResult Serialize(RakNet::SerializeParameters *serializeParameters) override;
@@ -96,6 +100,8 @@ namespace Ape
Ape::Vector2 mMouseLastPosition;

Ape::Vector2 mMouseScrollDelta;

int mLastKeyValue;
};
}

@@ -113,6 +113,12 @@ void Ape::CefBrowserPlugin::processEvent(Ape::Event event)
}
}
break;
case Ape::Event::Type::BROWSER_KEY_VALUE:
{
if (mBrowserIDNames[browser->getName()])
mpApeCefRenderHandlerImpl->keyValue(mBrowserIDNames[browser->getName()], browser->getLastKeyASCIIValue());
}
break;
case Ape::Event::Type::BROWSER_DELETE:
;
break;
@@ -79,7 +79,7 @@ void Ape::CefRenderHandlerImpl::mouseClick(int browserID, CefBrowserHost::MouseB
cefMouseEvent.y = mMouseCurrentPosition.y;
mBrowsers[browserID]->GetHost()->SendMouseClickEvent(cefMouseEvent, mouseButtonType, false, 1);
mBrowsers[browserID]->GetHost()->SendMouseClickEvent(cefMouseEvent, mouseButtonType, true, 1);
//std::cout << "Ape:::CefRenderHandlerImpl::mouseClick " << "x:" << cefMouseEvent.x << " y:" << cefMouseEvent.y << " type:" << mouseButtonType << std::endl;
//std::cout << "Ape::CefRenderHandlerImpl::mouseClick " << "x:" << cefMouseEvent.x << " y:" << cefMouseEvent.y << " type:" << mouseButtonType << std::endl;
}
}

@@ -91,7 +91,7 @@ void Ape::CefRenderHandlerImpl::mouseScroll(int browserID, int deltaX, int delta
cefMouseEvent.x = mMouseCurrentPosition.x;
cefMouseEvent.y = mMouseCurrentPosition.y;
mBrowsers[browserID]->GetHost()->SendMouseWheelEvent(cefMouseEvent, deltaX, deltaY);
//std::cout << "Ape:::CefRenderHandlerImpl::mouseScroll " << "x:" << cefMouseEvent.x << " y:" << cefMouseEvent.y << " deltaY:" << deltaY << std::endl;
//std::cout << "Ape::CefRenderHandlerImpl::mouseScroll " << "x:" << cefMouseEvent.x << " y:" << cefMouseEvent.y << " deltaY:" << deltaY << std::endl;
}
}

@@ -105,6 +105,21 @@ void Ape::CefRenderHandlerImpl::mouseMoved(int browserID, int x, int y)
cefMouseEvent.x = mMouseCurrentPosition.x;
cefMouseEvent.y = mMouseCurrentPosition.y;
mBrowsers[browserID]->GetHost()->SendMouseMoveEvent(cefMouseEvent, false);
//std::cout << "Ape:::CefRenderHandlerImpl::mouseMoved " << "x:" << cefMouseEvent.x << " y:" << cefMouseEvent.y << std::endl;
//std::cout << "Ape::CefRenderHandlerImpl::mouseMoved " << "x:" << cefMouseEvent.x << " y:" << cefMouseEvent.y << std::endl;
}
}

void Ape::CefRenderHandlerImpl::keyValue(int browserID, int keyASCIIValue)
{
if (mBrowsers.size() && mBrowsers[browserID])
{
CefKeyEvent cefKeyEvent;
cefKeyEvent.windows_key_code = keyASCIIValue;
if (keyASCIIValue == 8 || keyASCIIValue == 9 || keyASCIIValue == 13 || keyASCIIValue == 14)
cefKeyEvent.type = cef_key_event_type_t::KEYEVENT_RAWKEYDOWN;
else
cefKeyEvent.type = cef_key_event_type_t::KEYEVENT_CHAR;
mBrowsers[browserID]->GetHost()->SendKeyEvent(cefKeyEvent);
std::cout << "Ape::CefRenderHandlerImpl::keyValue " << "windows_key_code:" << cefKeyEvent.windows_key_code << "keyASCIIValue:" << keyASCIIValue << std::endl;
}
}
@@ -63,6 +63,8 @@ namespace Ape

void mouseMoved(int browserID, int x, int y);

void keyValue(int browserID,int keyASCIIValue);

IMPLEMENT_REFCOUNTING(CefRenderHandlerImpl);
};
}
@@ -202,7 +202,7 @@ void ApePresentationScenePlugin::Init()
storyElement.browserHeight = 157;
manageBrowser(storyElement);
storyElement.browserName = "first";
storyElement.browserURL = "http://apertusvr.org";
storyElement.browserURL = "http://google.com";
storyElement.browserPosition = Ape::Vector3(15, 367, 206) - mOldXMLFormatTranslateVector;
storyElement.browserOrientation = Ape::Quaternion(1, 0, 0, 0) * mOldXMLFormatRotationQuaternion;
storyElement.browserWidth = 267;
@@ -527,6 +527,22 @@ void ApePresentationScenePlugin::saveUserNodePose(Ape::NodeSharedPtr userNode)

bool ApePresentationScenePlugin::keyPressed(const OIS::KeyEvent& e)
{
if (auto activeBrowser = mActiveBrowser.lock())
{
std::string keyAsString = mpKeyboard->getAsString(e.key);
std::transform(keyAsString.begin(), keyAsString.end(), keyAsString.begin(), ::tolower);
std::cout << "ApePresentationScenePlugin::keyPressed " << "keyAsString:" << keyAsString << std::endl;
std::wstring keyAsWString(keyAsString.begin(), keyAsString.end());
if (e.key == OIS::KeyCode::KC_BACK)
keyAsWString = 8;
else if (e.key == OIS::KeyCode::KC_TAB)
keyAsWString = 9;
else if (e.key == OIS::KeyCode::KC_RETURN)
keyAsWString = 13;
else if (e.key == OIS::KeyCode::KC_LSHIFT)
keyAsWString = 14;
activeBrowser->keyASCIIValue(keyAsWString[0]);
}
mKeyCodeMap[e.key] = true;
auto userNode = mUserNode.lock();
if (userNode)
@@ -26,4 +26,4 @@
"ApeTexasEEGPlugin"
]
}
}
}
@@ -28,4 +28,4 @@
"ApeTexasEEGPlugin"
]
}
}
}

0 comments on commit 1563360

Please sign in to comment.
You can’t perform that action at this time.