fixes in Mac modifier keys, remove enet/lua tests
This commit is contained in:
@@ -29,7 +29,7 @@ struct DrawGridData
|
||||
|
||||
struct CommonGraphicsApp
|
||||
{
|
||||
class b3gWindowInterface* m_window;
|
||||
class CommonWindowInterface* m_window;
|
||||
struct CommonRenderInterface* m_renderer;
|
||||
struct CommonParameterInterface* m_parameterInterface;
|
||||
struct Common2dCanvasInterface* m_2dCanvasInterface;
|
||||
@@ -94,8 +94,8 @@ struct CommonGraphicsApp
|
||||
{
|
||||
CommonCameraInterface* camera = m_renderer->getActiveCamera();
|
||||
|
||||
bool isAltPressed = m_window->isModifiedKeyPressed(B3G_ALT);
|
||||
bool isControlPressed = m_window->isModifiedKeyPressed(B3G_CONTROL);
|
||||
bool isAltPressed = m_window->isModifierKeyPressed(B3G_ALT);
|
||||
bool isControlPressed = m_window->isModifierKeyPressed(B3G_CONTROL);
|
||||
|
||||
|
||||
if (isAltPressed || isControlPressed)
|
||||
|
||||
@@ -249,7 +249,6 @@ struct CommonMultiBodyBase : public ExampleInterface
|
||||
|
||||
virtual bool mouseButtonCallback(int button, int state, float x, float y)
|
||||
{
|
||||
|
||||
CommonRenderInterface* renderer = m_guiHelper->getRenderInterface();
|
||||
|
||||
if (!renderer)
|
||||
@@ -257,12 +256,13 @@ struct CommonMultiBodyBase : public ExampleInterface
|
||||
btAssert(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
CommonWindowInterface* window = m_guiHelper->getAppInterface()->m_window;
|
||||
|
||||
b3gWindowInterface* window = m_guiHelper->getAppInterface()->m_window;
|
||||
|
||||
|
||||
if (state==1)
|
||||
{
|
||||
if(button==0 && (!window->isModifiedKeyPressed(B3G_ALT) && !window->isModifiedKeyPressed(B3G_CONTROL) ))
|
||||
if(button==0 && (!window->isModifierKeyPressed(B3G_ALT) && !window->isModifierKeyPressed(B3G_CONTROL) ))
|
||||
{
|
||||
btVector3 camPos;
|
||||
renderer->getActiveCamera()->getCameraPosition(camPos);
|
||||
|
||||
@@ -239,7 +239,6 @@ struct CommonRigidBodyBase : public ExampleInterface
|
||||
|
||||
virtual bool mouseButtonCallback(int button, int state, float x, float y)
|
||||
{
|
||||
|
||||
CommonRenderInterface* renderer = m_guiHelper->getRenderInterface();
|
||||
|
||||
if (!renderer)
|
||||
@@ -247,12 +246,39 @@ struct CommonRigidBodyBase : public ExampleInterface
|
||||
btAssert(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
CommonWindowInterface* window = m_guiHelper->getAppInterface()->m_window;
|
||||
|
||||
b3gWindowInterface* window = m_guiHelper->getAppInterface()->m_window;
|
||||
|
||||
#if 0
|
||||
if (window->isModifierKeyPressed(B3G_ALT))
|
||||
{
|
||||
printf("ALT pressed\n");
|
||||
} else
|
||||
{
|
||||
printf("NO ALT pressed\n");
|
||||
}
|
||||
|
||||
if (window->isModifierKeyPressed(B3G_SHIFT))
|
||||
{
|
||||
printf("SHIFT pressed\n");
|
||||
} else
|
||||
{
|
||||
printf("NO SHIFT pressed\n");
|
||||
}
|
||||
|
||||
if (window->isModifierKeyPressed(B3G_CONTROL))
|
||||
{
|
||||
printf("CONTROL pressed\n");
|
||||
} else
|
||||
{
|
||||
printf("NO CONTROL pressed\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (state==1)
|
||||
{
|
||||
if(button==0 && (!window->isModifiedKeyPressed(B3G_ALT) && !window->isModifiedKeyPressed(B3G_CONTROL) ))
|
||||
if(button==0 && (!window->isModifierKeyPressed(B3G_ALT) && !window->isModifierKeyPressed(B3G_CONTROL) ))
|
||||
{
|
||||
btVector3 camPos;
|
||||
renderer->getActiveCamera()->getCameraPosition(camPos);
|
||||
|
||||
@@ -67,11 +67,11 @@ struct b3gWindowConstructionInfo
|
||||
};
|
||||
|
||||
|
||||
class b3gWindowInterface
|
||||
class CommonWindowInterface
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~b3gWindowInterface()
|
||||
virtual ~CommonWindowInterface()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ class b3gWindowInterface
|
||||
|
||||
virtual void endRendering()=0;
|
||||
|
||||
virtual bool isModifiedKeyPressed(int key) = 0;
|
||||
virtual bool isModifierKeyPressed(int key) = 0;
|
||||
|
||||
virtual void setMouseMoveCallback(b3MouseMoveCallback mouseCallback)=0;
|
||||
virtual b3MouseMoveCallback getMouseMoveCallback()=0;
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "LinearMath/btIDebugDraw.h"
|
||||
CommonGraphicsApp* s_app=0;
|
||||
|
||||
b3gWindowInterface* s_window = 0;
|
||||
CommonWindowInterface* s_window = 0;
|
||||
CommonParameterInterface* s_parameterInterface=0;
|
||||
CommonRenderInterface* s_instancingRenderer=0;
|
||||
OpenGLGuiHelper* s_guiHelper=0;
|
||||
|
||||
@@ -867,7 +867,7 @@ void ForkLiftDemo::resetForklift()
|
||||
bool ForkLiftDemo::keyboardCallback(int key, int state)
|
||||
{
|
||||
bool handled = false;
|
||||
bool isShiftPressed = m_guiHelper->getAppInterface()->m_window->isModifiedKeyPressed(B3G_SHIFT);
|
||||
bool isShiftPressed = m_guiHelper->getAppInterface()->m_window->isModifierKeyPressed(B3G_SHIFT);
|
||||
|
||||
if (state)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#define b3gDefaultOpenGLWindow MacOpenGLWindow
|
||||
|
||||
class MacOpenGLWindow : public b3gWindowInterface
|
||||
class MacOpenGLWindow : public CommonWindowInterface
|
||||
{
|
||||
struct MacOpenGLWindowInternalData* m_internalData;
|
||||
float m_mouseX;
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
|
||||
void runMainLoop();
|
||||
|
||||
virtual bool isModifiedKeyPressed(int key);
|
||||
virtual bool isModifierKeyPressed(int key);
|
||||
|
||||
void setMouseButtonCallback(b3MouseButtonCallback mouseCallback)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,12 @@
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
MY_MAC_ALTKEY=1,
|
||||
MY_MAC_SHIFTKEY=2,
|
||||
MY_MAC_CONTROL_KEY=4
|
||||
};
|
||||
|
||||
/* report GL errors, if any, to stderr */
|
||||
static void checkError(const char *functionName)
|
||||
@@ -222,7 +227,7 @@ MacOpenGLWindow::~MacOpenGLWindow()
|
||||
}
|
||||
|
||||
|
||||
bool MacOpenGLWindow::isModifiedKeyPressed(int key)
|
||||
bool MacOpenGLWindow::isModifierKeyPressed(int key)
|
||||
{
|
||||
bool isPressed = false;
|
||||
|
||||
@@ -230,17 +235,17 @@ bool MacOpenGLWindow::isModifiedKeyPressed(int key)
|
||||
{
|
||||
case B3G_ALT:
|
||||
{
|
||||
isPressed = ((m_modifierFlags && NSAlternateKeyMask)!=0);
|
||||
isPressed = ((m_modifierFlags & MY_MAC_ALTKEY)!=0);
|
||||
break;
|
||||
};
|
||||
case B3G_SHIFT:
|
||||
{
|
||||
isPressed = ((m_modifierFlags && NSShiftKeyMask)!=0);
|
||||
isPressed = ((m_modifierFlags & MY_MAC_SHIFTKEY)!=0);
|
||||
break;
|
||||
};
|
||||
case B3G_CONTROL:
|
||||
{
|
||||
isPressed = ((m_modifierFlags && NSControlKeyMask )!=0);
|
||||
isPressed = ((m_modifierFlags & MY_MAC_CONTROL_KEY )!=0);
|
||||
break;
|
||||
};
|
||||
|
||||
@@ -772,37 +777,43 @@ void MacOpenGLWindow::startRendering()
|
||||
if ((modifiers & NSShiftKeyMask))
|
||||
{
|
||||
m_keyboardCallback(B3G_SHIFT,1);
|
||||
m_modifierFlags |= MY_MAC_SHIFTKEY;
|
||||
}else
|
||||
{
|
||||
if (m_modifierFlags&NSShiftKeyMask)
|
||||
if (m_modifierFlags& MY_MAC_SHIFTKEY)
|
||||
{
|
||||
m_keyboardCallback(B3G_SHIFT,0);
|
||||
m_keyboardCallback(B3G_SHIFT,0);
|
||||
m_modifierFlags &= ~MY_MAC_SHIFTKEY;
|
||||
}
|
||||
}
|
||||
if (modifiers & NSControlKeyMask)
|
||||
{
|
||||
m_keyboardCallback(B3G_CONTROL,1);
|
||||
m_modifierFlags |= MY_MAC_CONTROL_KEY;
|
||||
} else
|
||||
{
|
||||
if (m_modifierFlags&NSControlKeyMask)
|
||||
if (m_modifierFlags&MY_MAC_CONTROL_KEY)
|
||||
{
|
||||
m_keyboardCallback(B3G_CONTROL,0);
|
||||
m_modifierFlags &= ~MY_MAC_CONTROL_KEY;
|
||||
}
|
||||
}
|
||||
if (modifiers & NSAlternateKeyMask)
|
||||
{
|
||||
m_keyboardCallback(B3G_ALT,1);
|
||||
} else
|
||||
{
|
||||
if (m_modifierFlags&NSAlternateKeyMask)
|
||||
{
|
||||
m_keyboardCallback(B3G_ALT,0);
|
||||
}
|
||||
}
|
||||
{
|
||||
m_keyboardCallback(B3G_ALT,1);
|
||||
m_modifierFlags |= MY_MAC_ALTKEY;
|
||||
} else
|
||||
{
|
||||
if (m_modifierFlags&MY_MAC_ALTKEY)
|
||||
{
|
||||
m_keyboardCallback(B3G_ALT,0);
|
||||
m_modifierFlags &= ~MY_MAC_ALTKEY;
|
||||
|
||||
}
|
||||
}
|
||||
//handle NSCommandKeyMask
|
||||
|
||||
}
|
||||
m_modifierFlags=modifiers;
|
||||
}
|
||||
if ([event type] == NSKeyUp)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user