From 7c5a6d779c898f3b572ac16c55303aea9c01524f Mon Sep 17 00:00:00 2001 From: yangws Date: Thu, 5 May 2011 11:51:13 +0800 Subject: [PATCH 1/2] fixed #481 DisableKeyLock and DisableBackLightAutoTurnOff when BackLightTurnOn. --- cocos2dx/platform/CCCommon.cpp | 31 +++++++++++++++- .../wophone/CCApplication_wophone.cpp | 37 ++++++++++++++++++- tests/tests/controller.cpp | 2 + 3 files changed, 66 insertions(+), 4 deletions(-) diff --git a/cocos2dx/platform/CCCommon.cpp b/cocos2dx/platform/CCCommon.cpp index a00745d7ad..d40a026c67 100644 --- a/cocos2dx/platform/CCCommon.cpp +++ b/cocos2dx/platform/CCCommon.cpp @@ -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; diff --git a/cocos2dx/platform/wophone/CCApplication_wophone.cpp b/cocos2dx/platform/wophone/CCApplication_wophone.cpp index cd33ff2f56..dba3a48081 100644 --- a/cocos2dx/platform/wophone/CCApplication_wophone.cpp +++ b/cocos2dx/platform/wophone/CCApplication_wophone.cpp @@ -1,3 +1,5 @@ +// #define COCOS2D_DEBUG 1 + #include "CCApplication_wophone.h" #include "ssBackLightControl.h" @@ -113,8 +115,16 @@ Boolean CCApplication::EventHandler(EventType* pEvent) { StopMainLoop(); } - CfgTurnOnBackLight(); + + // 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,11 +136,18 @@ Boolean CCApplication::EventHandler(EventType* pEvent) StartMainLoop(); - CfgTurnOnBackLightDelay(0x7fffffff); + // modify back light open mode + if (CfgGetBackLightStatus()) + { + 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(); diff --git a/tests/tests/controller.cpp b/tests/tests/controller.cpp index 932adf5080..0978be735a 100644 --- a/tests/tests/controller.cpp +++ b/tests/tests/controller.cpp @@ -17,6 +17,8 @@ static void ChangeOrientation(ccDeviceOrientation eOrientation) static TestScene* CreateTestScene(int nIdx) { + CCDirector::sharedDirector()->purgeCachedData(); + // change to default orientation ChangeOrientation(CCDeviceOrientationPortrait); From 6eb24cafeeabf0e61725983677d786b38febd201 Mon Sep 17 00:00:00 2001 From: yangws Date: Thu, 5 May 2011 14:00:36 +0800 Subject: [PATCH 2/2] fixed #481 remove KeyLock control code. --- .../wophone/CCApplication_wophone.cpp | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/cocos2dx/platform/wophone/CCApplication_wophone.cpp b/cocos2dx/platform/wophone/CCApplication_wophone.cpp index dba3a48081..33175c5d71 100644 --- a/cocos2dx/platform/wophone/CCApplication_wophone.cpp +++ b/cocos2dx/platform/wophone/CCApplication_wophone.cpp @@ -3,7 +3,7 @@ #include "CCApplication_wophone.h" #include "ssBackLightControl.h" -#include "ssKeyLockControl.h" +//#include "ssKeyLockControl.h" #include "CCScheduler.h" @@ -123,8 +123,8 @@ Boolean CCApplication::EventHandler(EventType* pEvent) CCLOG("AppActiveNotify::TurnOnBackLight:MODE_TIME_LONG"); } - EnableKeyLock(); - CCLOG("AppActiveNotify::InBackground"); +// EnableKeyLock(); +// CCLOG("AppActiveNotify::InBackground"); } else if (pEvent->sParam1 > 0) { @@ -144,11 +144,11 @@ Boolean CCApplication::EventHandler(EventType* pEvent) } // if KeyLock disactived, disable it. - if (! CfgKeyLock_GetActive()) - { - DisableKeyLock(); - CCLOG("AppActiveNotify::DisableKeyLock"); - } +// if (! CfgKeyLock_GetActive()) +// { +// DisableKeyLock(); +// CCLOG("AppActiveNotify::DisableKeyLock"); +// } } break; } @@ -202,8 +202,8 @@ void CCApplication::switchNotify(int nTurnOn) applicationDidEnterBackground(); StopMainLoop(); - EnableKeyLock(); - CCLOG("BLswitchNotify::EnableKeyLock"); +// EnableKeyLock(); +// CCLOG("BLswitchNotify::EnableKeyLock"); } else { @@ -211,13 +211,13 @@ void CCApplication::switchNotify(int nTurnOn) CfgTurnOnBackLightDelay(0x7fffffff); CCLOG("AppActiveNotify::TurnOnBackLight:0x7fffffff"); - // if KeyLock disactived, disable it. - if (! CfgKeyLock_GetActive()) - { - DisableKeyLock(); - CCLOG("BLswitchNotify::DisableKeyLock"); - } - +// // if KeyLock disactived, disable it. +// if (! CfgKeyLock_GetActive()) +// { +// DisableKeyLock(); +// CCLOG("BLswitchNotify::DisableKeyLock"); +// } +// // CCDirector::sharedDirector()->resume(); applicationWillEnterForeground(); StartMainLoop();