mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 09:19:01 +00:00
Fixed: #1174 Mac - Alpha Build - Mouse Behavior
This commit is contained in:
parent
dab1bec1aa
commit
3d3f1abb9c
2 changed files with 35 additions and 0 deletions
|
@ -246,6 +246,25 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
|
|||
mousePos.x /= (float)viewRect.size.width;
|
||||
mousePos.y /= (float)viewRect.size.height;
|
||||
|
||||
// if the mouse event was placed outside the view, don't tell NeL :)
|
||||
if((mousePos.x < 0.0 || mousePos.x > 1.0 ||
|
||||
mousePos.y < 0.0 || mousePos.y > 1.0) &&
|
||||
event.type != NSKeyDown && event.type != NSKeyUp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// first event about mouse movement after setting to emulateRawMode
|
||||
if(_setToEmulateRawMode &&
|
||||
(event.type == NSMouseMoved ||
|
||||
event.type == NSLeftMouseDragged ||
|
||||
event.type == NSRightMouseDragged))
|
||||
{
|
||||
// do not report because it reflects wrapping pointer to 0.5/0.5
|
||||
_setToEmulateRawMode = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// convert the modifiers for nel to pass them with the events
|
||||
NLMISC::TKeyButton modifiers =
|
||||
modifierFlagsToNelKeyButton([event modifierFlags]);
|
||||
|
@ -399,6 +418,12 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
|
|||
}
|
||||
}
|
||||
|
||||
if(_emulateRawMode && _driver && (event.type == NSMouseMoved ||
|
||||
event.type == NSLeftMouseDragged || event.type == NSRightMouseDragged))
|
||||
{
|
||||
_driver->setMousePos(0.5, 0.5);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -453,6 +478,14 @@ void CCocoaEventEmitter::submitEvents(CEventServer& server, bool /* allWins */)
|
|||
void CCocoaEventEmitter::emulateMouseRawMode(bool enable)
|
||||
{
|
||||
_emulateRawMode = enable;
|
||||
|
||||
if(_emulateRawMode)
|
||||
{
|
||||
_setToEmulateRawMode = true;
|
||||
|
||||
if(_driver)
|
||||
_driver->setMousePos(0.5, 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace NLMISC
|
|||
class CCocoaEventEmitter : public IEventEmitter
|
||||
{
|
||||
bool _emulateRawMode;
|
||||
bool _setToEmulateRawMode;
|
||||
NL3D::IDriver* _driver;
|
||||
CocoaOpenGLView* _glView;
|
||||
|
||||
|
@ -42,6 +43,7 @@ class CCocoaEventEmitter : public IEventEmitter
|
|||
public:
|
||||
CCocoaEventEmitter() :
|
||||
_emulateRawMode(false),
|
||||
_setToEmulateRawMode(false),
|
||||
_driver(NULL),
|
||||
_glView(nil),
|
||||
_server(NULL) { }
|
||||
|
|
Loading…
Reference in a new issue