Exemplo n.º 1
0
void CUSBKeyboardDevice::ReportHandler (const u8 *pReport)
{
	if (pReport == 0)
	{
		return;
	}

	if (m_pKeyStatusHandlerRaw != 0)
	{
		(*m_pKeyStatusHandlerRaw) (pReport[0], pReport+2);

		return;
	}

	// report modifier keys
	for (unsigned i = 0; i < 8; i++)
	{
		unsigned nMask = 1 << i;

		if (    (pReport[0] & nMask)
		    && !(m_LastReport[0] & nMask))
		{
			m_Behaviour.KeyPressed (0x80 + i);
		}
		else if (   !(pReport[0] & nMask)
			 &&  (m_LastReport[0] & nMask))
		{
			m_Behaviour.KeyReleased (0x80 + i);
		}
	}

	// report released keys
	for (unsigned i = 2; i < USBKEYB_REPORT_SIZE; i++)
	{
		u8 ucKeyCode = m_LastReport[i];
		if (   ucKeyCode != 0
		    && !FindByte (pReport+2, ucKeyCode, USBKEYB_REPORT_SIZE-2))
		{
			m_Behaviour.KeyReleased (ucKeyCode);
		}
	}

	// report pressed keys
	for (unsigned i = 2; i < USBKEYB_REPORT_SIZE; i++)
	{
		u8 ucKeyCode = pReport[i];
		if (   ucKeyCode != 0
		    && !FindByte (m_LastReport+2, ucKeyCode, USBKEYB_REPORT_SIZE-2))
		{
			m_Behaviour.KeyPressed (ucKeyCode);
		}
	}

	memcpy (m_LastReport, pReport, sizeof m_LastReport);
}
Exemplo n.º 2
0
static LPBYTE CMem_Alloc (CMem* pThis, int nSize)
{
    int n;

	if (pThis->m_pData != NULL)
		return CMem_Realloc (pThis, nSize);

	if (nSize == 0)  return NULL;

	if (nSize <= PAGE_SIZE && pThis->m_pMemBuf->m_nPageUsedCount < PAGE_COUNT)
	{
		n = FindByte (pThis->m_pMemBuf->m_btaryUsed, PAGE_COUNT, 0);

		pThis->m_pMemBuf->m_btaryUsed [n] = 1;
		pThis->m_pMemBuf->m_nPageUsedCount++;

		pThis->m_nAllocedSize = PAGE_SIZE;
		pThis->m_pData = pThis->m_pMemBuf->m_buf + n * PAGE_SIZE;
		pThis->m_nSize = nSize;
		return pThis->m_pData;
	}

	pThis->m_pData = (LPBYTE)malloc (nSize + FM_GROW_SIZE);
	if (pThis->m_pData == NULL)
	{
		pThis->m_nAllocedSize = 0;
		pThis->m_nSize = 0;
	}
	else
	{
		pThis->m_nAllocedSize = nSize + FM_GROW_SIZE;
		pThis->m_nSize = nSize;
	}
	return pThis->m_pData;
}
Exemplo n.º 3
0
//---------------------------------------------------------------------------------------------------------------------------------------------------
void PainterMem_SetPoint(int x, int y, int color)
{
    uint8 *byte = FindByte(x, y);

    uint8 clearMask = GetClearMask(x, y);

    *byte &= clearMask;

    uint8 drawMask = GetMask(x, y, color);

    *byte |= drawMask;

}