diff --git a/OVMFbin/OVMF_VARS-pure-efi.fd b/OVMFbin/OVMF_VARS-pure-efi.fd index f858912..2df1ac3 100644 Binary files a/OVMFbin/OVMF_VARS-pure-efi.fd and b/OVMFbin/OVMF_VARS-pure-efi.fd differ diff --git a/kernel/bin/CustomOS.img b/kernel/bin/CustomOS.img index ab359a6..331e24f 100644 Binary files a/kernel/bin/CustomOS.img and b/kernel/bin/CustomOS.img differ diff --git a/kernel/bin/kernel.elf b/kernel/bin/kernel.elf index 406f1d1..12310c5 100755 Binary files a/kernel/bin/kernel.elf and b/kernel/bin/kernel.elf differ diff --git a/kernel/lib/BasicRenderer.o b/kernel/lib/BasicRenderer.o index 4188871..fbb3ed7 100644 Binary files a/kernel/lib/BasicRenderer.o and b/kernel/lib/BasicRenderer.o differ diff --git a/kernel/lib/kernelUtil.o b/kernel/lib/kernelUtil.o index 3bc73e9..4f5a5a9 100644 Binary files a/kernel/lib/kernelUtil.o and b/kernel/lib/kernelUtil.o differ diff --git a/kernel/lib/panic.o b/kernel/lib/panic.o index e422991..9e810b3 100644 Binary files a/kernel/lib/panic.o and b/kernel/lib/panic.o differ diff --git a/kernel/lib/userinput/mouse.o b/kernel/lib/userinput/mouse.o index 3ce3aab..79b08f8 100644 Binary files a/kernel/lib/userinput/mouse.o and b/kernel/lib/userinput/mouse.o differ diff --git a/kernel/src/BasicRenderer.cpp b/kernel/src/BasicRenderer.cpp index bcc696a..0eec6d1 100644 --- a/kernel/src/BasicRenderer.cpp +++ b/kernel/src/BasicRenderer.cpp @@ -51,13 +51,13 @@ void BasicRenderer::Print(const char* str) { } } -void BasicRenderer::PutPixel(uint32_t x, uint32_t y, uint32_t colour) { +inline void BasicRenderer::PutPixel(uint32_t x, uint32_t y, uint32_t colour) { *(uint32_t*)((uint64_t)targetFramebuffer->BaseAddress + (x*4) + (y * targetFramebuffer->PixelsPerScanline * 4)) = colour; } -uint32_t BasicRenderer::GetPixel(uint32_t x, uint32_t y){ +inline uint32_t BasicRenderer::GetPixel(uint32_t x, uint32_t y){ return *(uint32_t*)((uint64_t)targetFramebuffer->BaseAddress + (x*4) + (y * targetFramebuffer->PixelsPerScanline * 4)); } @@ -78,7 +78,9 @@ void BasicRenderer::ClearMouseCursor(uint8_t* mouseCursor, Point position) { int byte = bit / 8; if (mouseCursor[byte] & (0b10000000 >> (x % 8))) { - PutPixel(position.x + x, position.y + y, mouseCursorBuffer[x + y*16]); + if (GetPixel(position.x + x, position.y + y) == mouseCursorBufferAfter[x + y * 16]) { + PutPixel(position.x + x, position.y + y, mouseCursorBuffer[x + y*16]); + } } } } @@ -101,6 +103,8 @@ void BasicRenderer::DrawOverlayMouseCursor(uint8_t* mouseCursor, Point position, if (mouseCursor[byte] & (0b10000000 >> (x % 8))) { mouseCursorBuffer[x + y*16] = GetPixel(position.x + x, position.y + y); PutPixel(position.x + x, position.y + y, colour); + mouseCursorBufferAfter[x + y*16] = GetPixel(position.x + x, position.y + y); + } } } diff --git a/kernel/src/BasicRenderer.h b/kernel/src/BasicRenderer.h index 4780845..17a3b1b 100644 --- a/kernel/src/BasicRenderer.h +++ b/kernel/src/BasicRenderer.h @@ -11,13 +11,14 @@ class BasicRenderer { Framebuffer* targetFramebuffer; PSF1_FONT* PSF1_Font; uint32_t mouseCursorBuffer[16*19]; + uint32_t mouseCursorBufferAfter[16*19]; unsigned int Colour; unsigned int ClearColour; void Print(const char* str); void PutChar(char chr, unsigned int xOff, unsigned int yOff); void PutChar(char chr); - void PutPixel(uint32_t x, uint32_t y, uint32_t colour); - uint32_t GetPixel(uint32_t x, uint32_t y); + inline void PutPixel(uint32_t x, uint32_t y, uint32_t colour); + inline uint32_t GetPixel(uint32_t x, uint32_t y); void ClearMouseCursor(uint8_t* mouseCursor, Point position); void ClearChar(); void Clear(); diff --git a/kernel/src/userinput/mouse.cpp b/kernel/src/userinput/mouse.cpp index b8d77d9..7571aff 100644 --- a/kernel/src/userinput/mouse.cpp +++ b/kernel/src/userinput/mouse.cpp @@ -58,6 +58,12 @@ uint8_t mouseCycle = 0; uint8_t mousePacket[4]; bool mousePacketReady = false; +bool mouseButtons[] = { + false, // left + false, // right + false // middle +}; + Point mousePosition; Point mousePositionOld; @@ -138,6 +144,10 @@ void ProcessMousePacket() { if (mousePosition.y < 0) mousePosition.y = 0; if (mousePosition.y > GlobalRenderer->targetFramebuffer->Height-1) mousePosition.y = GlobalRenderer->targetFramebuffer->Height; + mouseButtons[0] = mousePacket[0] & PS2LeftButton; + mouseButtons[1] = mousePacket[1] & PS2RightButton; + mouseButtons[2] = mousePacket[2] & PS2MiddleButton; + GlobalRenderer->ClearMouseCursor(MousePointer, mousePositionOld); GlobalRenderer->DrawOverlayMouseCursor(MousePointer, mousePosition, 0xFFFFFFFF); diff --git a/kernel/src/userinput/mouse.h b/kernel/src/userinput/mouse.h index 7ad0186..a9f2e90 100644 --- a/kernel/src/userinput/mouse.h +++ b/kernel/src/userinput/mouse.h @@ -5,8 +5,8 @@ extern uint8_t MousePointer[]; #define PS2LeftButton 0b00000001 -#define PS2MiddleButton 0b00000010 -#define PS2RightButton 0b00000100 +#define PS2MiddleButton 0b00000100 +#define PS2RightButton 0b00000010 #define PS2XSign 0b00010000 #define PS2YSign 0b00100000 @@ -14,6 +14,7 @@ extern uint8_t MousePointer[]; #define PS2YOverflow 0b10000000 extern Point mousePosition; +extern bool mouseButtons[]; void InitPS2Mouse(); void HandlePS2Mouse(uint8_t data);