mirror of https://github.com/axmolengine/axmol.git
Merge pull request #250 from yangws/481
fixed #481 DisableKeyLock and DisableBackLightAutoTurnOff when BackLightTurnOn.
This commit is contained in:
commit
dcdad9a81a
|
@ -63,12 +63,39 @@ NS_CC_END;
|
|||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WOPHONE)
|
||||
#include "TG3.h"
|
||||
|
||||
#define LOG_FILE_PATH "/NEWPLUS/TDA_DATA/UserData/Cocos2dLog.txt"
|
||||
static char s_szLogFilePath[EOS_FILE_MAX_PATH] = {0};
|
||||
|
||||
NS_CC_BEGIN;
|
||||
|
||||
void CCLog(const char * pszFormat, ...)
|
||||
{
|
||||
if (! s_szLogFilePath[0])
|
||||
{
|
||||
// save the log file named "Cocos2dxLog.txt" to the directory which the app.so in.
|
||||
TUChar AppID[EOS_FILE_MAX_PATH] = {0};
|
||||
UInt32 nCmdType = 0;
|
||||
Int32 nRet = SS_AppRequest_GetAppName(AppID, &nCmdType);
|
||||
if (nRet < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TUChar AppPath[EOS_FILE_MAX_PATH] = {0};
|
||||
if (SS_GetApplicationPath(AppID, SS_APP_PATH_TYPE_EXECUTABLE, AppPath) < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
char szAppPath[EOS_FILE_MAX_PATH] = {0};
|
||||
TUString::StrUnicodeToStrUtf8((Char*) szAppPath, AppPath);
|
||||
#ifndef _TRANZDA_VM_
|
||||
strcpy(s_szLogFilePath, "");
|
||||
#else
|
||||
strcpy(s_szLogFilePath, "D:/Work7");
|
||||
#endif
|
||||
strcat(s_szLogFilePath, szAppPath);
|
||||
strcat(s_szLogFilePath, "Cocos2dxLog.txt");
|
||||
}
|
||||
|
||||
SS_printf("Cocos2d: ");
|
||||
char szBuf[MAX_LEN];
|
||||
|
||||
|
@ -86,7 +113,7 @@ void CCLog(const char * pszFormat, ...)
|
|||
SS_printf("\n");
|
||||
#else
|
||||
SS_printf("\r\n");
|
||||
FILE * pf = fopen(LOG_FILE_PATH, "a+");
|
||||
FILE * pf = fopen(s_szLogFilePath, "a+");
|
||||
if (! pf)
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
// #define COCOS2D_DEBUG 1
|
||||
|
||||
#include "CCApplication_wophone.h"
|
||||
|
||||
#include "ssBackLightControl.h"
|
||||
#include "ssKeyLockControl.h"
|
||||
//#include "ssKeyLockControl.h"
|
||||
|
||||
#include "CCScheduler.h"
|
||||
|
||||
|
@ -113,8 +115,16 @@ Boolean CCApplication::EventHandler(EventType* pEvent)
|
|||
{
|
||||
StopMainLoop();
|
||||
}
|
||||
CfgTurnOnBackLight();
|
||||
EnableKeyLock();
|
||||
|
||||
// restore back light open mode
|
||||
if (CfgGetBackLightStatus())
|
||||
{
|
||||
CfgTurnOnBackLightEx(SYS_BACK_LIGHT_MODE_TIME_LONG);
|
||||
CCLOG("AppActiveNotify::TurnOnBackLight:MODE_TIME_LONG");
|
||||
}
|
||||
|
||||
// EnableKeyLock();
|
||||
// CCLOG("AppActiveNotify::InBackground");
|
||||
}
|
||||
else if (pEvent->sParam1 > 0)
|
||||
{
|
||||
|
@ -126,12 +136,19 @@ Boolean CCApplication::EventHandler(EventType* pEvent)
|
|||
|
||||
StartMainLoop();
|
||||
|
||||
CfgTurnOnBackLightDelay(0x7fffffff);
|
||||
// if KeyLock disactived, disable it.
|
||||
if (! CfgKeyLock_GetActive())
|
||||
// modify back light open mode
|
||||
if (CfgGetBackLightStatus())
|
||||
{
|
||||
DisableKeyLock();
|
||||
CfgTurnOnBackLightDelay(0x7fffffff);
|
||||
CCLOG("AppActiveNotify::TurnOnBackLight:0x7fffffff");
|
||||
}
|
||||
|
||||
// if KeyLock disactived, disable it.
|
||||
// if (! CfgKeyLock_GetActive())
|
||||
// {
|
||||
// DisableKeyLock();
|
||||
// CCLOG("AppActiveNotify::DisableKeyLock");
|
||||
// }
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -172,6 +189,8 @@ void CCApplication::switchNotify(int nTurnOn)
|
|||
{
|
||||
bool bInBack = isInBackground();
|
||||
|
||||
// set the auto close screen and auto key lock status
|
||||
|
||||
do
|
||||
{
|
||||
// if the app have be in background,don't handle this message
|
||||
|
@ -182,9 +201,23 @@ void CCApplication::switchNotify(int nTurnOn)
|
|||
// CCDirector::sharedDirector()->pause();
|
||||
applicationDidEnterBackground();
|
||||
StopMainLoop();
|
||||
|
||||
// EnableKeyLock();
|
||||
// CCLOG("BLswitchNotify::EnableKeyLock");
|
||||
}
|
||||
else
|
||||
{
|
||||
// modify back light open mode
|
||||
CfgTurnOnBackLightDelay(0x7fffffff);
|
||||
CCLOG("AppActiveNotify::TurnOnBackLight:0x7fffffff");
|
||||
|
||||
// // if KeyLock disactived, disable it.
|
||||
// if (! CfgKeyLock_GetActive())
|
||||
// {
|
||||
// DisableKeyLock();
|
||||
// CCLOG("BLswitchNotify::DisableKeyLock");
|
||||
// }
|
||||
//
|
||||
// CCDirector::sharedDirector()->resume();
|
||||
applicationWillEnterForeground();
|
||||
StartMainLoop();
|
||||
|
|
|
@ -17,6 +17,8 @@ static void ChangeOrientation(ccDeviceOrientation eOrientation)
|
|||
|
||||
static TestScene* CreateTestScene(int nIdx)
|
||||
{
|
||||
CCDirector::sharedDirector()->purgeCachedData();
|
||||
|
||||
// change to default orientation
|
||||
ChangeOrientation(CCDeviceOrientationPortrait);
|
||||
|
||||
|
|
Loading…
Reference in New Issue