📄 platform_palmos.c
字号:
}
bool_t GetDisplayPower()
{
#ifdef HAVE_PALMONE_SDK
if (HWU != sysInvalidRefNum)
{
static UInt16 HWU2 = sysInvalidRefNum;
Boolean b = HWUGetDisplayState(HWU);
// some graffiti utlitize can unload HWUtils
// (example Graffiti Anywhere on T|T: power off, action,action to turn on)
if (b!=1 && SysLibFind(kHWUtilsName, &HWU2) == sysErrLibNotFound)
{
SysLibLoad(kHWUtilsType, kHWUtilsCreator, &HWU2);
b = HWUGetDisplayState(HWU);
}
if (b && !HWUDisplayPower)
{
EvtEnableGraffiti(true);
HWUBlinkLED(HWU,0);
}
HWUDisplayPower = b!=0;
return HWUDisplayPower;
}
if (HALTreo650)
{
UInt32 n = 1;
HsAttrGet(hsAttrDisplayOn,0,&n);
return n != 0;
}
#endif
if (OEMSleep)
return (GetOEMSleepMode() & 2) == 0;
return 1;
}
int SetDisplayPower(bool_t State,bool_t Force)
{
if (OEMSleep)
{
int OldMode = GetOEMSleepMode();
int NewMode = State?(SleepCatch?1:0):2;
if ((OldMode & 2) != (NewMode & 2))
{
if ((OldMode & 3) && !NewMode)
EvtResetAutoOffTimer();
SetOEMSleepMode(NewMode);
}
return ERR_NONE;
}
if (!Force && State == GetDisplayPower())
return ERR_NONE;
#ifdef HAVE_PALMONE_SDK
if (HWU != sysInvalidRefNum && HWUEnableDisplay(HWU,(Boolean)State)==errNone)
{
if (!State)
HWUSetBlinkRate(HWU,1000);
else
EvtResetAutoOffTimer();
EvtEnableGraffiti((Boolean)State);
if (State || QueryAdvanced(ADVANCED_BLINKLED))
HWUBlinkLED(HWU,(Boolean)(!State));
HWUDisplayPower = State;
return ERR_NONE;
}
if (HALTreo650)
{
if (!State)
HALDisplayOff_TREO650();
else
HALDisplayWake();
return ERR_NONE;
}
#endif
return ERR_NOT_SUPPORTED;
}
void LaunchNotify(SysNotifyParamType* Params,bool_t HasFocus)
{
DIAResizedNotify(Params);
if (Params->notifyType == sysNotifyLateWakeupEvent)
{
bool_t b = 0;
node* Player = Context()->Player;
if (Player)
Player->Set(Player,PLAYER_POWEROFF,&b,sizeof(b));
}
if (Params->notifyType == sysNotifySleepNotifyEvent && !(SleepCatch && OEMSleep))
{
bool_t b = 1;
node* Player = Context()->Player;
if (Player)
Player->Set(Player,PLAYER_POWEROFF,&b,sizeof(b));
}
/*
if (Params->notifyType == sysNotifySleepRequestEvent && !OEMSleep && HasFocus &&
((SleepEventParamType*)Params->notifyDetailsP)->reason == sysSleepPowerButton && !GetDisplayPower())
{
((SleepEventParamType*)Params->notifyDetailsP)->deferSleep++;
Params->handled = 1;
SetDisplayPower(1,0);
SetKeyboardBacklight(1);
}
*/
if (Params->notifyType == sysNotifySleepRequestEvent && SleepCatch && !OEMSleep && HasFocus &&
((SleepEventParamType*)Params->notifyDetailsP)->reason == sysSleepAutoOff)
{
((SleepEventParamType*)Params->notifyDetailsP)->deferSleep++;
Params->handled = 1;
SetDisplayPower(0,0);
SetKeyboardBacklight(0);
}
if (Params->notifyType == sysNotifyVolumeMountedEvent)
{
Params->handled |= vfsHandledStartPrc|vfsHandledUIAppSwitch;
//todo: switch to this volume in open dialog...
}
}
void SleepTimerReset()
{
}
void SleepTimeout(bool_t KeepProcess,bool_t KeepDisplay)
{
bool_t Disable;
if (!DisplayPowerSupport || !KeepProcess)
KeepDisplay = KeepProcess;
Disable = KeepProcess && KeepDisplay;
SleepCatch = KeepProcess && !KeepDisplay;
if (SleepDisable != Disable)
{
SleepDisable = Disable;
if (Disable)
{
SetDisplayPower(1,0);
SleepSave = SysSetAutoOffTime(0);
}
else
{
if (!SleepCatch)
{
EvtResetAutoOffTimer();
GetDisplayPower(); // update
}
SysSetAutoOffTime(SleepSave);
}
}
if (OEMSleep)
{
int OldMode = GetOEMSleepMode();
if (((OldMode & 3)!=0) != SleepCatch)
{
if ((OldMode & 3) && !SleepCatch)
EvtResetAutoOffTimer();
SetOEMSleepMode(SleepCatch?1:0);
}
}
}
void _Assert(const char* Exp,const char* File,int Line)
{
tchar_t TExp[MAXPATH];
tchar_t TFile[MAXPATH];
AsciiToTcs(TExp,TSIZEOF(TExp),File);
stprintf_s(TFile,TSIZEOF(TFile),T("\n%s:%d"),TExp,Line);
AsciiToTcs(TExp,TSIZEOF(TExp),Exp);
FrmCustomAlert(WarningOKAlert,TExp,TFile," ");
}
void ShowMessage(const tchar_t* Title,const tchar_t* Msg,...)
{
tchar_t s[512];
va_list Args;
va_start(Args,Msg);
if (Title)
{
tcscpy_s(s,TSIZEOF(s),Title);
tcscat_s(s,TSIZEOF(s),T(":\n"));
}
else
s[0] = 0;
vstprintf_s(s+tcslen(s),TSIZEOF(s)-tcslen(s), Msg, Args);
va_end(Args);
DIASet(DIA_TASKBAR,DIA_TASKBAR);
FrmCustomAlert(WarningOKAlert, s, " ", " ");
}
void HotKeyToString(tchar_t* Out, size_t OutLen, int HotKey)
{
Out[0] = 0;
if (HotKey)
{
bool_t Keep = (HotKey & HOTKEY_KEEP) != 0;
HotKey &= HOTKEY_MASK;
stprintf_s(Out,OutLen,T("#%02X"),HotKey);
if (Keep) tcscat_s(Out,OutLen,T("*"));
}
}
void ThreadSleep(int Time)
{
SysTaskDelay(Time);
}
int GetTimeFreq()
{
return SysTicksPerSecond();
}
int GetTimeTick()
{
return TimGetTicks();
}
void GetTimeCycle(int* p)
{
int n=1;
int j;
int i = TimGetTicks();
while ((j = TimGetTicks())==i)
++n;
p[0] = j;
p[1] = n;
}
#ifdef _WIN32
#include <windows.h>
static FILE* Debug = NULL;
#endif
void DebugMessage(const tchar_t* Msg, ...)
{
va_list Args;
RectangleType r;
tchar_t s[512];
va_start(Args,Msg);
vstprintf_s(s,TSIZEOF(s), Msg, Args);
va_end(Args);
r.topLeft.x = 0;
r.topLeft.y = 0;
r.extent.x = 160;
r.extent.y = 15;
WinEraseRectangle(&r, 0);
WinDrawChars(s, (Int16)strlen(s), 1, 1);
#ifdef _WIN32
if (!Debug) Debug = fopen("\\debug.txt","w+");
tcscat_s(s,TSIZEOF(s),"\n");
OutputDebugString(s);
fprintf(Debug,"%s",s);
fflush(Debug);
#endif
}
void* BrushCreate(rgbval_t Color) { return (void*)Color; }
void BrushDelete(void* Handle) {}
void WinFill(void* DC,rect* Rect,rect* Exclude,void* Brush)
{
uint32_t Color = (uint32_t)Brush;
RGBColorType c,c0;
RectangleType r;
UInt16 OldCoord = 0;
WinHandle Old = NULL;
if (DC)
Old = WinSetDrawWindow(FrmGetWindowHandle((FormType*)DC));
if (HighDens)
OldCoord = WinSetCoordinateSystem(kCoordinatesNative);
c.index = 0;
c.r = ((rgb*)&Color)->c.r;
c.g = ((rgb*)&Color)->c.g;
c.b = ((rgb*)&Color)->c.b;
WinSetBackColorRGB(&c,&c0);
r.topLeft.x = (Coord)Rect->x;
r.topLeft.y = (Coord)Rect->y;
r.extent.x = (Coord)Rect->Width;
r.extent.y = (Coord)Rect->Height;
if (Exclude)
{
r.extent.y = (Coord)(Exclude->y - Rect->y);
if (r.extent.y > 0 && r.extent.x > 0)
WinEraseRectangle(&r,0);
r.extent.y = (Coord)(Rect->y + Rect->Height - Exclude->y - Exclude->Height);
r.topLeft.y = (Coord)(Exclude->y + Exclude->Height);
if (r.extent.y > 0 && r.extent.x > 0)
WinEraseRectangle(&r,0);
r.extent.y = (Coord)Rect->Height;
r.topLeft.y = (Coord)Rect->y;
r.extent.x = (Coord)(Exclude->x - Rect->x);
if (r.extent.x > 0 && r.extent.y > 0)
WinEraseRectangle(&r,0);
r.extent.x = (Coord)(Rect->x + Rect->Width - Exclude->x - Exclude->Width);
r.topLeft.x = (Coord)(Exclude->x + Exclude->Width);
if (r.extent.x > 0 && r.extent.y > 0)
WinEraseRectangle(&r,0);
}
else
if (r.extent.x > 0 && r.extent.y > 0)
WinEraseRectangle(&r,0);
WinSetBackColorRGB(&c0,&c);
if (HighDens)
WinSetCoordinateSystem(OldCoord);
if (Old)
WinSetDrawWindow(Old);
}
void WinUpdate()
{
}
void WinValidate(const rect* Rect)
{
}
void WinInvalidate(const rect* Rect, bool_t Local)
{
}
void ReleaseModule(void** Module)
{
if (*Module)
*Module = NULL;
}
int64_t GetTimeDate()
{
DateTimeType Date;
TimSecondsToDateTime(TimGetSeconds(),&Date);
return (((Date.hour*100)+Date.minute)*100+Date.second)*1000 +
(int64_t)(((Date.year*100)+Date.month)*100+Date.day) * 1000000000;
}
bool_t SaveDocument(const tchar_t* Name, const tchar_t* Text,tchar_t* URL,int URLLen)
{
//todo...
return 0;
}
void GetDebugPath(tchar_t* Path, int PathLen, const tchar_t* FileName)
{
stprintf_s(Path,PathLen,T("slot1:\\%s"),FileName);
}
void GetSystemPath(tchar_t* Path, int PathLen, const tchar_t* FileName)
{
if (PathLen>0)
*Path = 0;
}
double compability_with_old_aac(int i) { return i; } // needed for defining __floatsidf()
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -