CBenchmark() { for (dword i = 0; i < 4; i++) m_PerfData[i] = 0; m_SurfID = CreateSurface(300, 200, 256, 256 + 16); FillSurface(m_SurfID, 0xFFFFFFFF); DrawFrameRect(m_SurfID, 0, 0, 256, 256 + 16, 0xFF808080); ShowSurface(m_SurfID); KeEnableNotification(Nf_VirtualKey); KeEnableNotification(NfKe_TerminateProcess); double T = 0.0; dword FPS = 0; dword T1 = KeGetTime(); for (;;) { for (dword i = 0; i < 6; i++) DrawIter(T - 4.0 * (5 - i), 0xFFFFFFFF); T += 1.0; for (dword i = 0; i < 6; i++) DrawIter(T - 4.0 * (5 - i), 0x004070FF | (((i + 1) * 0x10) << 24)); WaitRedraw(); FPS++; dword T2 = KeGetTime(); if (T2 - T1 >= 1000) { dword AvgFPS = AddPerfData(FPS); T1 = T2; FPS = 0; ShowStat(AvgFPS); } CNotification<4> Nf; dword NfCount = KeGetNotificationCount(); for (dword i = 0; i < NfCount; i++) { Nf.Recv(); if (Nf.GetID() == Nf_VirtualKey) { if (Nf.GetByte(0) == VK_Esc) return; } else if (Nf.GetID() == NfKe_TerminateProcess) return; } } }
CPS2Mouse() { buttonPressed[0] = false; buttonPressed[1] = false; m_Flags = 0; m_DeltaX = 0; m_DeltaY = 0; m_DataIndex = 0; KeEnableNotification(NfKe_TerminateProcess); KeEnableNotification(Nfi8043_MouseData); CNotification<1> N; for (;;) { KeWaitFor(1); N.Recv(); if (N.GetID() == Nfi8043_MouseData) { byte Param = N.GetByte(0); if (m_DataIndex == 0) { byte Flags = Param; if (Flags & 0x8) { m_Flags = Flags; m_DataIndex++; } } else if (m_DataIndex == 1) { m_DeltaX = Param; m_DataIndex++; } else { m_DeltaY = Param; m_DataIndex = 0; int DeltaX = m_DeltaX; int DeltaY = m_DeltaY; DeltaX |= TestBit(m_Flags, 4) * 0xFFFFFF00; DeltaY |= TestBit(m_Flags, 5) * 0xFFFFFF00; DeltaY = -DeltaY; bool buttonPressedNew[2] = { TestBit(m_Flags, 0), TestBit(m_Flags, 1) }; if ((DeltaX != 0) || (DeltaY != 0)) { int moveData[2] = {DeltaX, DeltaY}; KeNotify(Nf_MouseDeltaMove, (byte*)moveData, 8); } for (int i = 0; i < 2; i++) { if (buttonPressed[i] != buttonPressedNew[i]) { if (buttonPressedNew[i]) KeNotify(Nf_MouseButtonDown, (byte*)(&i), 1); else KeNotify(Nf_MouseButtonUp, (byte*)(&i), 1); buttonPressed[i] = buttonPressedNew[i]; } } } } else if (N.GetID() == NfKe_TerminateProcess) { return; } } }
Ci8042() { m_IsScrollActive = false; m_IsNumActive = false; m_IsCapsActive = false; KeLinkIrq(1); KeLinkIrq(12); KeEnableNotification(NfKe_Irq); KeEnableNotification(NfKe_TimerTick); KeEnableNotification(NfKe_TerminateProcess); KeEnableNotification(NfKeyboard_SwitchLEDStatus); InitDevices(); CNotification<16> N; for (;;) { KeWaitFor(1); dword NfCount = KeGetNotificationCount(); for (dword z = 0; z < NfCount; z++) { N.Recv(); if (N.GetID() == NfKe_TimerTick) { m_TimeoutTimer++; if (m_TimeoutTimer >= 20) { KeDisableNotification(NfKe_TimerTick); //DebugOut("[MouseInitTimeout]", 18); KeInPortByte(0x60); m_IsInitFinished = true; } } else if (N.GetID() == NfKe_Irq) { if (N.GetByte(0) == 1) { byte D = KeInPortByte(0x60); //DebugOut("[fK:", 4); //DebugOut(D); //DebugOut("]", 1); OnKeybByte(D); KeEndOfInterrupt(1); } else if (N.GetByte(0) == 12) { bool M = false; if (KeInPortByte(0x64) & 0x20) M = true; byte D = KeInPortByte(0x60); //if (M) // DebugOut("[fM:", 4); //else // DebugOut("[fm:", 4); //DebugOut(D); //DebugOut("]", 1); if (M) OnMouseByte(D); KeEndOfInterrupt(12); } } else if (N.GetID() == NfKeyboard_SwitchLEDStatus) { SwitchLEDStatus(N.GetByte(0)); } else if (N.GetID() == NfKe_TerminateProcess) return; } if (KeGetNotificationCount() == 0) { if (m_LEDSwitchState == 1) { SendKeyboardData(0xED); m_LEDSwitchState = 2; } else if (m_LEDSwitchState == 3) { SendKeyboardData(m_LEDStatus); m_LEDSwitchState = 4; } } } }