mirror of https://github.com/axmolengine/axmol.git
Second half of commit for adding Accelerometer simulation to Win32.
This commit is contained in:
parent
ffc4457991
commit
aa06de2fb3
|
@ -25,6 +25,8 @@ THE SOFTWARE.
|
|||
#ifndef __PLATFORM_WIN32_UIACCELEROMETER_H__
|
||||
#define __PLATFORM_WIN32_UIACCELEROMETER_H__
|
||||
|
||||
#include "CCAccelerometerDelegate.h"
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
class CC_DLL CCAccelerometer
|
||||
|
@ -33,8 +35,13 @@ public:
|
|||
CCAccelerometer();
|
||||
~CCAccelerometer();
|
||||
|
||||
static CCAccelerometer* sharedAccelerometer() { return NULL; }
|
||||
void setDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);}
|
||||
static CCAccelerometer* sharedAccelerometer();
|
||||
void setDelegate(CCAccelerometerDelegate* pDelegate);
|
||||
void update( double x,double y,double z,double timestamp );
|
||||
private:
|
||||
static CCAccelerometer* m_spCCAccelerometer;
|
||||
CCAccelerometerDelegate* m_pAccelDelegate;
|
||||
CCAcceleration m_obAccelerationValue;
|
||||
};
|
||||
|
||||
}//namespace cocos2d
|
||||
|
|
|
@ -191,6 +191,7 @@ CCEGLView::CCEGLView()
|
|||
, m_hWnd(NULL)
|
||||
, m_eInitOrientation(CCDeviceOrientationPortrait)
|
||||
, m_fScreenScaleFactor(1.0f)
|
||||
, m_lpfnAccelerometerKeyHook(NULL)
|
||||
{
|
||||
m_pTouch = new CCTouch;
|
||||
m_pSet = new CCSet;
|
||||
|
@ -329,6 +330,16 @@ LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
if (GetKeyState(VK_LSHIFT) < 0 || GetKeyState(VK_RSHIFT) < 0 || GetKeyState(VK_SHIFT) < 0)
|
||||
CCKeypadDispatcher::sharedDispatcher()->dispatchKeypadMSG(wParam == VK_F1 ? kTypeBackClicked : kTypeMenuClicked);
|
||||
}
|
||||
if ( m_lpfnAccelerometerKeyHook!=NULL )
|
||||
{
|
||||
(*m_lpfnAccelerometerKeyHook)( message,wParam,lParam );
|
||||
}
|
||||
break;
|
||||
case WM_KEYUP:
|
||||
if ( m_lpfnAccelerometerKeyHook!=NULL )
|
||||
{
|
||||
(*m_lpfnAccelerometerKeyHook)( message,wParam,lParam );
|
||||
}
|
||||
break;
|
||||
case WM_CHAR:
|
||||
{
|
||||
|
@ -364,6 +375,10 @@ LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
|
||||
CCIMEDispatcher::sharedDispatcher()->dispatchInsertText(szUtf8, nLen);
|
||||
}
|
||||
if ( m_lpfnAccelerometerKeyHook!=NULL )
|
||||
{
|
||||
(*m_lpfnAccelerometerKeyHook)( message,wParam,lParam );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -386,6 +401,11 @@ LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void CCEGLView::setAccelerometerKeyHook( LPFN_ACCELEROMETER_KEYHOOK lpfnAccelerometerKeyHook )
|
||||
{
|
||||
m_lpfnAccelerometerKeyHook=lpfnAccelerometerKeyHook;
|
||||
}
|
||||
|
||||
CCSize CCEGLView::getSize()
|
||||
{
|
||||
if (m_bOrientationReverted)
|
||||
|
|
|
@ -67,6 +67,8 @@ public:
|
|||
void resize(int width, int height);
|
||||
void centerWindow();
|
||||
void setScreenScale(float factor);
|
||||
typedef void (*LPFN_ACCELEROMETER_KEYHOOK)( UINT message,WPARAM wParam, LPARAM lParam );
|
||||
void setAccelerometerKeyHook( LPFN_ACCELEROMETER_KEYHOOK lpfnAccelerometerKeyHook );
|
||||
|
||||
// static function
|
||||
|
||||
|
@ -94,6 +96,7 @@ private:
|
|||
SIZE m_tSizeInPoints;
|
||||
float m_fScreenScaleFactor;
|
||||
RECT m_rcViewPort;
|
||||
LPFN_ACCELEROMETER_KEYHOOK m_lpfnAccelerometerKeyHook;
|
||||
};
|
||||
|
||||
NS_CC_END;
|
||||
|
|
|
@ -834,6 +834,10 @@
|
|||
<Filter
|
||||
Name="win32"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\platform\win32\CCAccelerometer_win32.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\platform\win32\CCAccelerometer_win32.h"
|
||||
>
|
||||
|
|
|
@ -1151,6 +1151,18 @@
|
|||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="AccelerometerTest"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\tests\AccelerometerTest\AccelerometerTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\tests\AccelerometerTest\AccelerometerTest.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Files>
|
||||
|
|
|
@ -83,10 +83,8 @@ static TestScene* CreateTestScene(int nIdx)
|
|||
pScene = new EffectAdvanceScene(); break;
|
||||
case TEST_HIRES:
|
||||
pScene = new HiResTestScene(); break;
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32)
|
||||
case TEST_ACCELEROMRTER:
|
||||
pScene = new AccelerometerTestScene(); break;
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA)
|
||||
case TEST_KEYPAD:
|
||||
pScene = new KeypadTestScene(); break;
|
||||
|
|
Loading…
Reference in New Issue