📄 s3c2410x_lcd.cpp
字号:
pgxoi->cBPP = 8;
pgxoi->ffFormat = kfPalette;
break;
case 16:
pgxoi->cBPP = 16;
pgxoi->ffFormat = kfDirect | kfDirect565;
break;
case 24:
pgxoi->cBPP = 24;
pgxoi->ffFormat = kfDirect | kfDirect888;
break;
case 32:
pgxoi->cBPP = 32;
pgxoi->ffFormat = kfDirect | kfDirect888;
break;
}
}
#ifdef ROTATE
if (m_iRotate == DMDO_90 || m_iRotate == DMDO_270 )
pgxoi->ffFormat |= kfLandscape; // Rotated
#endif //ROTATE & ROTATE
pgxoi->vkButtonUpPortrait = VK_UP;
pgxoi->vkButtonUpLandscape = VK_LEFT;
pgxoi->ptButtonUp.x = 88;
pgxoi->ptButtonUp.y = 250;
pgxoi->vkButtonDownPortrait = VK_DOWN;
pgxoi->vkButtonDownLandscape = VK_RIGHT;
pgxoi->ptButtonDown.x = 88;
pgxoi->ptButtonDown.y = 270;
pgxoi->vkButtonLeftPortrait = VK_LEFT;
pgxoi->vkButtonLeftLandscape = VK_DOWN;
pgxoi->ptButtonLeft.x = 78;
pgxoi->ptButtonLeft.y = 260;
pgxoi->vkButtonRightPortrait = VK_RIGHT;
pgxoi->vkButtonRightLandscape = VK_UP;
pgxoi->ptButtonRight.x = 98;
pgxoi->ptButtonRight.y = 260;
pgxoi->vkButtonAPortrait = VK_F1; // Softkey 1
pgxoi->vkButtonALandscape = VK_F1;
pgxoi->ptButtonA.x = 10;
pgxoi->ptButtonA.y = 240;
pgxoi->vkButtonBPortrait = VK_F2; // Softkey 2
pgxoi->vkButtonBLandscape = VK_F2;
pgxoi->ptButtonB.x = 166;
pgxoi->ptButtonB.y = 240;
pgxoi->vkButtonCPortrait = VK_F8; // Asterisk on keypad
pgxoi->vkButtonCLandscape = VK_F8;
pgxoi->ptButtonC.x = 10;
pgxoi->ptButtonC.y = 320;
pgxoi->vkButtonStartPortrait = '\r';
pgxoi->vkButtonStartLandscape = '\r';
pgxoi->ptButtonStart.x = 88;
pgxoi->ptButtonStart.y = 260;
pgxoi->pvReserved1 = (void *) 0;
pgxoi->pvReserved2 = (void *) 0;
return 1;
}
}
return -1;
}
#ifdef ROTATE
if (iEsc == DRVESC_GETSCREENROTATION)
{
*(int *)pvOut = ((DMDO_0 | DMDO_90 | DMDO_180 | DMDO_270) << 8) | ((BYTE)m_iRotate);
return DISP_CHANGE_SUCCESSFUL;
}
else if (iEsc == DRVESC_SETSCREENROTATION)
{
if ((cjIn == DMDO_0) ||
(cjIn == DMDO_90) ||
(cjIn == DMDO_180) ||
(cjIn == DMDO_270) )
{
return DynRotate(cjIn);
}
return DISP_CHANGE_BADMODE;
}
#endif //ROTATE
#endif // CLEARTYPE || ROTATE
if (iEsc == SETBACKLIGHT)
{
if (cjIn == sizeof(BOOL) && pvIn != NULL)
{
if (*(BOOL*)pvIn)
{
// Switch backlight on by clearing bit 28
m_s2410LCD->LCDCON3 &= 0xefffffff;
}
else
{
// Switch backlight off by setting bit 28
m_s2410LCD->LCDCON3 |= 0x10000000;
}
return 1;
}
return -1;
}
else if (iEsc == GETBACKLIGHT)
{
if (cjOut == sizeof(BOOL) && pvOut != NULL)
{
if (m_s2410LCD->LCDCON3 & 0x10000000) // Examine bit 28 - backlight
{
*(BOOL*)pvOut = FALSE; // bit is set: backlight is off
}
else
{
*(BOOL*)pvOut = TRUE; // bit is clear: backlight is on
}
return 1;
}
return -1;
}
else if (iEsc == CONTRASTCOMMAND)
{
if (cjIn == sizeof(ContrastCmdInputParm) && pvIn != NULL &&
(pvOut == NULL || cjOut == sizeof(int)))
{
ContrastCmdInputParm InputParam;
BOOL fRet;
int temp;
// make local copy to ensure consistency
memcpy(&InputParam, pvIn, sizeof(ContrastCmdInputParm));
// CONTRAST_CMD_SET and others may be passed a NULL pvOut if the caller isn't
// interested in the return value
if (pvOut == NULL)
{
pvOut = &temp;
}
fRet = ContrastControlHelper(InputParam.command, InputParam.parm, (int*)pvOut);
if (fRet)
{
return 1;
}
}
return -1;
}
return 0;
}
ULONG *APIENTRY DrvGetMasks(DHPDEV dhpdev)
{
return gBitMasks;
}
#ifdef ROTATE
void S3C2410DISP::SetRotateParms()
{
int iswap;
switch(m_iRotate)
{
case DMDO_0:
m_nScreenHeightSave = m_nScreenHeight;
m_nScreenWidthSave = m_nScreenWidth;
break;
case DMDO_180:
m_nScreenHeightSave = m_nScreenHeight;
m_nScreenWidthSave = m_nScreenWidth;
break;
case DMDO_90:
case DMDO_270:
iswap = m_nScreenHeight;
m_nScreenHeight = m_nScreenWidth;
m_nScreenWidth = iswap;
m_nScreenHeightSave = m_nScreenWidth;
m_nScreenWidthSave = m_nScreenHeight;
break;
default:
m_nScreenHeightSave = m_nScreenHeight;
m_nScreenWidthSave = m_nScreenWidth;
break;
}
return;
}
LONG S3C2410DISP::DynRotate(int angle)
{
unsigned __int32 EmulatorAngle;
GPESurfRotate *pSurf = (GPESurfRotate *)m_pPrimarySurface;
if (angle == m_iRotate)
return DISP_CHANGE_SUCCESSFUL;
m_iRotate = angle;
switch(m_iRotate)
{
case DMDO_0:
m_nScreenHeight = m_nScreenHeightSave;
m_nScreenWidth = m_nScreenWidthSave;
EmulatorAngle = 0;
break;
case DMDO_90:
m_nScreenHeight = m_nScreenWidthSave;
m_nScreenWidth = m_nScreenHeightSave;
EmulatorAngle = 1;
break;
case DMDO_180:
m_nScreenHeight = m_nScreenHeightSave;
m_nScreenWidth = m_nScreenWidthSave;
EmulatorAngle = 2;
break;
case DMDO_270:
m_nScreenHeight = m_nScreenWidthSave;
m_nScreenWidth = m_nScreenHeightSave;
EmulatorAngle = 3;
break;
}
// Inform the DeviceEmulator of the change in rotation
m_s2410LCD->PAD[0] = EmulatorAngle;
m_pMode->width = m_nScreenWidth;
m_pMode->height = m_nScreenHeight;
pSurf->SetRotation(m_nScreenWidth, m_nScreenHeight, angle);
return DISP_CHANGE_SUCCESSFUL;
}
int
S3C2410DISP::GetRotateModeFromReg()
{
HKEY hKey;
int nRet = DMDO_0;
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SYSTEM\\GDI\\ROTATION"),0,0, &hKey))
{
DWORD dwSize, dwAngle, dwType = REG_DWORD;
dwSize = sizeof(DWORD);
if (ERROR_SUCCESS == RegQueryValueEx(hKey,
TEXT("ANGLE"),
NULL,
&dwType,
(LPBYTE)&dwAngle,
&dwSize))
{
switch (dwAngle)
{
case 90:
nRet = DMDO_90;
break;
case 180:
nRet = DMDO_180;
break;
case 270:
nRet = DMDO_270;
break;
case 0:
// fall through
default:
nRet = DMDO_0;
break;
}
}
RegCloseKey(hKey);
}
return nRet;
}
#endif //ROTATE
// See dispdrvr.h for documentation for this method
//
// If Cmd == CONTRAST_CMD_SET, pValue points to the new contrast setting.
// For all other cases, it points to the location to store the new contrast
// setting. This parameter may not be NULL.
BOOL
S3C2410DISP::ContrastControl(
ULONG cmd,
ULONG *pValue)
{
return ContrastControlHelper(cmd, (int)*pValue, (int*)pValue);
}
BOOL
S3C2410DISP::ContrastControlHelper(
ULONG cmd,
int InValue,
int *pOutValue)
{
int Contrast;
// Contrast is implemented as the top 4 bits of LCDCON3. They are
// inverted: 0 == highest contrast (default), and 15 == lowest.
switch (cmd)
{
case CONTRAST_CMD_GET:
*pOutValue = 15 - (m_s2410LCD->LCDCON3 >> 28);
return TRUE;
case CONTRAST_CMD_SET:
Contrast = InValue;
if (Contrast < 0)
{
Contrast = 0;
}
else if (Contrast > 15)
{
Contrast = 15;
}
m_s2410LCD->LCDCON3 = (m_s2410LCD->LCDCON3 & 0x0fffffff) | ((15-Contrast) << 28);
*pOutValue = Contrast;
return TRUE;
case CONTRAST_CMD_INCREASE:
Contrast = (m_s2410LCD->LCDCON3 >> 28);
if (Contrast > 0)
{
Contrast--; // Remember: 0 == highest contrast
m_s2410LCD->LCDCON3 = (m_s2410LCD->LCDCON3 & 0x0fffffff) | (Contrast << 28);
}
*pOutValue = 15-Contrast;
return TRUE;
case CONTRAST_CMD_DECREASE:
Contrast = (m_s2410LCD->LCDCON3 >> 28);
if (Contrast < 15)
{
Contrast++; // Remember: 15 == highest contrast
m_s2410LCD->LCDCON3 = (m_s2410LCD->LCDCON3 & 0x0fffffff) | (Contrast << 28);
}
*pOutValue = 15-Contrast;
return TRUE;
case CONTRAST_CMD_DEFAULT:
m_s2410LCD->LCDCON3 &= 0x0fffffff;
*pOutValue = 0;
return TRUE;
case CONTRAST_CMD_MAX:
*pOutValue = 15;
return TRUE;
default:
break;
}
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -