📄 lcdcclass.cpp
字号:
int yHot,
int cx,
int cy)
{
UCHAR *andPtr; // input pointer
UCHAR *xorPtr; // input pointer
UCHAR *andLine; // output pointer
UCHAR *xorLine; // output pointer
char bAnd;
char bXor;
int row;
int col;
int i;
int bitMask;
DEBUGMSG(GPE_ZONE_CURSOR,(TEXT("RGPEFlat::SetPointerShape(0x%X, 0x%X, %d, %d, %d, %d)\r\n"),pMask, pColorSurf, xHot, yHot, cx, cy));
// turn current cursor off
CursorOff();
// release memory associated with old cursor
if (!pMask) // do we have a new cursor shape
{
m_CursorDisabled = TRUE; // no, so tag as disabled
}
else
{
m_CursorDisabled = FALSE; // yes, so tag as not disabled
// store size and hotspot for new cursor
m_CursorSize.x = cx;
m_CursorSize.y = cy;
m_CursorHotspot.x = xHot;
m_CursorHotspot.y = yHot;
andPtr = (UCHAR*)pMask->Buffer();
xorPtr = (UCHAR*)pMask->Buffer() + (cy * pMask->Stride());
// store OR and AND mask for new cursor
for (row = 0; row < cy; row++)
{
andLine = &m_CursorAndShape[cx * row];
xorLine = &m_CursorXorShape[cx * row];
for (col = 0; col < cx / 8; col++)
{
bAnd = andPtr[row * pMask->Stride() + col];
bXor = xorPtr[row * pMask->Stride() + col];
for (bitMask = 0x0080, i = 0; i < 8; bitMask >>= 1, i++)
{
andLine[(col * 8) + i] = bAnd & bitMask ? 0xFF : 0x00;
xorLine[(col * 8) + i] = bXor & bitMask ? 0xFF : 0x00;
}
}
}
}
return S_OK;
}
//------------------------------------------------------------------------------
//
// FUNCTION: MovePointer
//
// DESCRIPTION: This method executes from applications either
// to move the hot spot of the cursor to
// a specific screen location or to hide the cursor.
//
// PARAMETERS:
// x [in] Horizontal screen location to move the cursor to.
// Applications can pass a value of -1 to hide the cursor.
// y [in] Vertical screen location to move the cursor to.
// RETURNS:
// S_OK successful
// others failed
//
//------------------------------------------------------------------------------
SCODE LcdcClass::MovePointer(int x, int y)
{
DEBUGMSG(GPE_ZONE_CURSOR, (TEXT("RGPEFlat::MovePointer(%d, %d)\r\n"), x, y));
CursorOff();
if (x != -1 || y != -1)
{
// compute new cursor rect
m_CursorRect.left = x - m_CursorHotspot.x;
m_CursorRect.right = m_CursorRect.left + m_CursorSize.x;
m_CursorRect.top = y - m_CursorHotspot.y;
m_CursorRect.bottom = m_CursorRect.top + m_CursorSize.y;
CursorOn();
}
return S_OK;
}
//------------------------------------------------------------------------------
//
// FUNCTION: SetCursorColor
//
// DESCRIPTION: This method set the color of cursor
// The color fomat is 18 bits
//
// PARAMETERS:
// red [in]red component of the cursor color, in 6 bits format
// green[in]green component of the cursor color, in 6 bits format
// blue [in]blue component of the cursor color, in 6 bits format
// RETURNS:
// S_OK successful
// others failed
//
//------------------------------------------------------------------------------
SCODE LcdcClass::SetCursorColor(UINT8 red, UINT8 green, UINT8 blue)
{
if ( red > 0x3f ||
green > 0x3f ||
blue > 0x3f)
{
DEBUGMSG(GPE_ZONE_ERROR,(TEXT("LcdcClass::SetCursorColor: Bad color 0x%x 0x%x 0x%x\r\n"), red, green, blue));
return E_INVALIDARG;
}
// disable cursor
INSREG32BF(&m_pLCDC->CPR, LCDC_CPR_OP, LCDC_CPR_OP_DISABLE);
INSREG32BF(&m_pLCDC->CPR, LCDC_CPR_CC, LCDC_CPR_CC_DISABLED);
//set cursor color
m_pLCDC->CCMR = blue | green<<6 | red<<12;
//enable cusor
INSREG32BF(&m_pLCDC->CPR, LCDC_CPR_OP, LCDC_CPR_OP_ENABLE);
INSREG32BF(&m_pLCDC->CPR, LCDC_CPR_CC, LCDC_CPR_CC_OR);
DEBUGMSG(GPE_ZONE_CURSOR, (TEXT("lcdcClass SetCursorColor: the new cursor color is 0x%x 0x%x 0x%x! \r\n"),red, green, blue));
return S_OK;
}
//------------------------------------------------------------------------------
//
// FUNCTION: DrvEscape
//
// DESCRIPTION: This routine handles the needed DrvEscape codes.
//
// PARAMETERS: pso - pointer to SURFOBJ structure decribing desired surface
// iEsc - Escape codes
// pvIn - pointer to input buffer
// cjIn - size of input buffer
// cjOut - size of output buffer
// pvOut - pointer to output buffer
//
// RETURNS:
// TRUE successful
// FALSE failed
//
//------------------------------------------------------------------------------
ULONG LcdcClass::DrvEscape(SURFOBJ *pso, ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
{
ULONG retval = ESC_FAILED;
PVIDEO_POWER_MANAGEMENT psPowerManagement;
switch(iEsc)
{
case QUERYESCSUPPORT:
if(pvIn != NULL && cjIn == sizeof(DWORD))
{
// Query DrvEscap support functions
DWORD EscapeFunction;
EscapeFunction = *(DWORD *)pvIn;
if ((EscapeFunction == QUERYESCSUPPORT) ||
(EscapeFunction == SETPOWERMANAGEMENT) ||
(EscapeFunction == GETPOWERMANAGEMENT) ||
(EscapeFunction == IOCTL_POWER_CAPABILITIES) ||
(EscapeFunction == IOCTL_POWER_QUERY) ||
(EscapeFunction == IOCTL_POWER_SET) ||
(EscapeFunction == IOCTL_POWER_GET) ||
(EscapeFunction == LCDC_ESC_REQUEST_WINDOW) ||
(EscapeFunction == LCDC_ESC_RELEASE_WINDOW) ||
(EscapeFunction == LCDC_ESC_ENABLE_WINDOW) ||
(EscapeFunction == LCDC_ESC_DISABLE_WINDOW) ||
(EscapeFunction == LCDC_ESC_FLIP_WINDOW) ||
(EscapeFunction == LCDC_ESC_GET_TRANSPARENCY) ||
(EscapeFunction == LCDC_ESC_SET_TRANSPARENCY) )
retval = ESC_SUCCESS;
else
retval = LcdcDrvEscape(pso, iEsc, cjIn, pvIn, cjOut, pvOut);
}
else
SetLastError(ERROR_INVALID_PARAMETER);
break;
case SETPOWERMANAGEMENT :
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("SETPOWERMANAGEMENT\r\n")));
if (psPowerManagement = (PVIDEO_POWER_MANAGEMENT) pvIn)
{
if (cjIn >= sizeof(VIDEO_POWER_MANAGEMENT))
{
DWORD err = ERROR_SUCCESS;
//Ask Power Manager to update the system power state,
//PM will call us back with IOCTL_POWER_SET
switch(psPowerManagement->PowerState)
{
case VideoPowerOff:
DEBUGMSG(GPE_ZONE_WARNING,(TEXT("Requesting POWER_STATE_IDLE\r\n")));
err = SetSystemPowerState(0, POWER_STATE_IDLE, POWER_FORCE);
break;
case VideoPowerOn:
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("Requesting POWER_STATE_ON\r\n")));
err = SetSystemPowerState(0, POWER_STATE_ON, POWER_FORCE);
break;
default:
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("SetPowerManagement : unsupported power state requested\r\n")));
break;
}
if(ERROR_SUCCESS == err)
retval = ESC_SUCCESS;
}
else
SetLastError(ERROR_INVALID_PARAMETER);
}
else
SetLastError(ERROR_INVALID_PARAMETER);
break;
case GETPOWERMANAGEMENT:
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("GETPOWERMANAGEMENT\r\n")));
if (psPowerManagement = (PVIDEO_POWER_MANAGEMENT) pvOut)
{
if (cjOut >= sizeof(VIDEO_POWER_MANAGEMENT))
{
psPowerManagement->Length = sizeof(VIDEO_POWER_MANAGEMENT);
psPowerManagement->DPMSVersion = 0x0100;
psPowerManagement->PowerState = PmToVideoPowerState(m_Dx);
retval = ESC_SUCCESS;
}
else
SetLastError(ERROR_INVALID_PARAMETER);
}
else
SetLastError(ERROR_INVALID_PARAMETER);
break;
case IOCTL_POWER_CAPABILITIES:
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("IOCTL_POWER_CAPABILITIES\r\n")));
if(pvOut != NULL && cjOut == sizeof(POWER_CAPABILITIES))
{
PPOWER_CAPABILITIES ppc = (PPOWER_CAPABILITIES)pvOut;
memset(ppc, 0, sizeof(POWER_CAPABILITIES));
ppc->DeviceDx = 0x11; // support D0 and D4
ppc->WakeFromDx = 0x00; // No wake capability
ppc->InrushDx = 0x00; // No in rush requirement
ppc->Power[D0] = 600; // 0.6W
ppc->Power[D1] = PwrDeviceUnspecified;
ppc->Power[D2] = PwrDeviceUnspecified;
ppc->Power[D3] = PwrDeviceUnspecified;
ppc->Power[D4] = 0;
ppc->Latency[D0] = 0;
ppc->Latency[D1] = PwrDeviceUnspecified;
ppc->Latency[D2] = PwrDeviceUnspecified;
ppc->Latency[D3] = PwrDeviceUnspecified;
ppc->Latency[D4] = 0;
ppc->Flags = 0;
retval = ESC_SUCCESS;
}
else
SetLastError(ERROR_INVALID_PARAMETER);
break;
case IOCTL_POWER_QUERY:
if(pvOut != NULL && cjOut == sizeof(CEDEVICE_POWER_STATE))
{
// return a good status on any valid query, since we are always ready to
// change power states.
CEDEVICE_POWER_STATE NewDx = *(PCEDEVICE_POWER_STATE)pvOut;
if(VALID_DX(NewDx))
{
// this is a valid Dx state so return a good status
retval = ESC_SUCCESS;
}
else
SetLastError(ERROR_INVALID_PARAMETER);
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("IOCTL_POWER_QUERY %u %s\r\n"),
NewDx, retval? L"succeeded" : L"failed"));
}
else
SetLastError(ERROR_INVALID_PARAMETER);
break;
case IOCTL_POWER_GET:
if(pvOut != NULL && cjOut == sizeof(CEDEVICE_POWER_STATE))
{
CEDEVICE_POWER_STATE CurrentDx = m_Dx;
*(PCEDEVICE_POWER_STATE)pvOut = CurrentDx;
retval = ESC_SUCCESS;
DEBUGMSG(GPE_ZONE_WARNING, (L"%s IOCTL_POWER_GET: passing back %u\r\n", m_szDevName, CurrentDx));
}
else
SetLastError(ERROR_INVALID_PARAMETER);
break;
case IOCTL_POWER_SET:
if(pvOut != NULL && cjOut == sizeof(CEDEVICE_POWER_STATE))
{
CEDEVICE_POWER_STATE NewDx = *(PCEDEVICE_POWER_STATE)pvOut;
if(VALID_DX(NewDx))
{
SetDisplayPower(NewDx);
retval = ESC_SUCCESS;
DEBUGMSG(GPE_ZONE_WARNING, (L"%s IOCTL_POWER_SET %u: passing back %u\r\n", m_szDevName, NewDx, m_Dx));
}
else
{
SetLastError(ERROR_INVALID_PARAMETER);
DEBUGMSG(GPE_ZONE_WARNING, (L"IOCTL_POWER_SET: invalid state request %u\r\n", NewDx));
}
}
else
SetLastError(ERROR_INVALID_PARAMETER);
break;
case LCDC_ESC_REQUEST_WINDOW:
if(pvIn != NULL && cjIn == sizeof(lcdcGraphicWindowOP_t))
{
pLcdcGraphicWindowOP_t pGWop = (pLcdcGraphicWindowOP_t)pvIn;
if(m_hGraphicWindowHdl)
{
// Graphic window is in use, reject the request
pGWop->Result = ESC_FAILED;
pGWop->BufHandle = NULL;
}
else
{
// Graphic window is free, grant the request
UINT32 timeNow = GetTickCount(); // Get a pseudorandom number from OS time
if(timeNow)
m_hGraphicWindowHdl = (HANDLE)timeNow;
else
m_hGraphicWindowHdl = (HANDLE)(timeNow++);
pGWop->Result = ESC_SUCCESS;
pGWop->BufHandle = m_hGraphicWindowHdl;
m_bGraphicWindowFlipped = FALSE;
m_bGraphicWindowRunning = FALSE;
ClearGraphicWindowRegs(m_pLCDC);
retval = ESC_SUCCESS;
}
}
else
{
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("LCDC: LCDC_ESC_REQUEST_WINDOW, invalid parameter\r\n")));
SetLastError(ERROR_INVALID_PARAMETER);
}
break;
case LCDC_ESC_RELEASE_WINDOW:
if(pvIn != NULL && cjIn == sizeof(lcdcGraphicWindowOP_t))
{
pLcdcGraphicWindowOP_t pGWop = (pLcdcGraphicWindowOP_t)pvIn;
if(pGWop->BufHandle && (pGWop->BufHandle == m_hGraphicWindowHdl))
{
if(m_bGraphicWindowRunning)
DisableGraphicWindow(pGWop);
pGWop->Result = ESC_SUCCESS;
pGWop->BufHandle = NULL;
m_bGraphicWindowFlipped = FALSE;
m_bGraphicWindowRunning = FALSE;
m_hGraphicWindowHdl = NULL;
retval = ESC_SUCCESS;
}
else
{
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("LCDC: LCDC_ESC_RELEASE_WINDOW, wrong request\r\n")));
pGWop->Result = ESC_FAILED;
SetLastError(ERROR_BUSY);
}
}
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -