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)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WOPHONE)
|
||||||
#include "TG3.h"
|
#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;
|
NS_CC_BEGIN;
|
||||||
|
|
||||||
void CCLog(const char * pszFormat, ...)
|
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: ");
|
SS_printf("Cocos2d: ");
|
||||||
char szBuf[MAX_LEN];
|
char szBuf[MAX_LEN];
|
||||||
|
|
||||||
|
@ -86,7 +113,7 @@ void CCLog(const char * pszFormat, ...)
|
||||||
SS_printf("\n");
|
SS_printf("\n");
|
||||||
#else
|
#else
|
||||||
SS_printf("\r\n");
|
SS_printf("\r\n");
|
||||||
FILE * pf = fopen(LOG_FILE_PATH, "a+");
|
FILE * pf = fopen(s_szLogFilePath, "a+");
|
||||||
if (! pf)
|
if (! pf)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
// #define COCOS2D_DEBUG 1
|
||||||
|
|
||||||
#include "CCApplication_wophone.h"
|
#include "CCApplication_wophone.h"
|
||||||
|
|
||||||
#include "ssBackLightControl.h"
|
#include "ssBackLightControl.h"
|
||||||
#include "ssKeyLockControl.h"
|
//#include "ssKeyLockControl.h"
|
||||||
|
|
||||||
#include "CCScheduler.h"
|
#include "CCScheduler.h"
|
||||||
|
|
||||||
|
@ -113,8 +115,16 @@ Boolean CCApplication::EventHandler(EventType* pEvent)
|
||||||
{
|
{
|
||||||
StopMainLoop();
|
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)
|
else if (pEvent->sParam1 > 0)
|
||||||
{
|
{
|
||||||
|
@ -126,12 +136,19 @@ Boolean CCApplication::EventHandler(EventType* pEvent)
|
||||||
|
|
||||||
StartMainLoop();
|
StartMainLoop();
|
||||||
|
|
||||||
CfgTurnOnBackLightDelay(0x7fffffff);
|
// modify back light open mode
|
||||||
// if KeyLock disactived, disable it.
|
if (CfgGetBackLightStatus())
|
||||||
if (! CfgKeyLock_GetActive())
|
|
||||||
{
|
{
|
||||||
DisableKeyLock();
|
CfgTurnOnBackLightDelay(0x7fffffff);
|
||||||
|
CCLOG("AppActiveNotify::TurnOnBackLight:0x7fffffff");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if KeyLock disactived, disable it.
|
||||||
|
// if (! CfgKeyLock_GetActive())
|
||||||
|
// {
|
||||||
|
// DisableKeyLock();
|
||||||
|
// CCLOG("AppActiveNotify::DisableKeyLock");
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -172,6 +189,8 @@ void CCApplication::switchNotify(int nTurnOn)
|
||||||
{
|
{
|
||||||
bool bInBack = isInBackground();
|
bool bInBack = isInBackground();
|
||||||
|
|
||||||
|
// set the auto close screen and auto key lock status
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// if the app have be in background,don't handle this message
|
// if the app have be in background,don't handle this message
|
||||||
|
@ -182,9 +201,23 @@ void CCApplication::switchNotify(int nTurnOn)
|
||||||
// CCDirector::sharedDirector()->pause();
|
// CCDirector::sharedDirector()->pause();
|
||||||
applicationDidEnterBackground();
|
applicationDidEnterBackground();
|
||||||
StopMainLoop();
|
StopMainLoop();
|
||||||
|
|
||||||
|
// EnableKeyLock();
|
||||||
|
// CCLOG("BLswitchNotify::EnableKeyLock");
|
||||||
}
|
}
|
||||||
else
|
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();
|
// CCDirector::sharedDirector()->resume();
|
||||||
applicationWillEnterForeground();
|
applicationWillEnterForeground();
|
||||||
StartMainLoop();
|
StartMainLoop();
|
||||||
|
|
|
@ -17,6 +17,8 @@ static void ChangeOrientation(ccDeviceOrientation eOrientation)
|
||||||
|
|
||||||
static TestScene* CreateTestScene(int nIdx)
|
static TestScene* CreateTestScene(int nIdx)
|
||||||
{
|
{
|
||||||
|
CCDirector::sharedDirector()->purgeCachedData();
|
||||||
|
|
||||||
// change to default orientation
|
// change to default orientation
|
||||||
ChangeOrientation(CCDeviceOrientationPortrait);
|
ChangeOrientation(CCDeviceOrientationPortrait);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue