1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:47:35 +00:00

Add a simple PS/2 mouse device.

It's not hooked up to anything just yet, but it does read movement deltas.
This commit is contained in:
Andreas Kling 2019-01-11 02:28:53 +01:00
parent d1ceb4b603
commit e740f1195a
4 changed files with 146 additions and 1 deletions

28
Kernel/PS2MouseDevice.h Normal file
View file

@ -0,0 +1,28 @@
#pragma once
#include <VirtualFileSystem/CharacterDevice.h>
#include "IRQHandler.h"
class PS2MouseDevice final : public IRQHandler, public CharacterDevice {
public:
PS2MouseDevice();
virtual ~PS2MouseDevice() override;
private:
virtual bool has_data_available_for_reading() const override;
virtual ssize_t read(byte* buffer, size_t buffer_size) override;
virtual ssize_t write(const byte* buffer, size_t buffer_size) override;
virtual void handle_irq() override;
void initialize();
void prepare_for_input();
void prepare_for_output();
void mouse_write(byte);
byte mouse_read();
void wait_then_write(byte port, byte data);
byte wait_then_read(byte port);
byte m_data_state { 0 };
signed_byte m_data[3];
};