diff options
| author | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-25 08:06:38 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-25 08:06:38 +0100 |
| commit | 9be51d883414584db0926ab854d6026e1785048b (patch) | |
| tree | 6afb5cec25c48ac76a8e26b2cc0b09dd1dc2c1ea /Private/Drivers | |
| parent | 27e0af3ecfe0be226f88837634111299121e5ddb (diff) | |
Kernel: Morning bump.
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private/Drivers')
| -rw-r--r-- | Private/Drivers/PS2/Mouse.hxx | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/Private/Drivers/PS2/Mouse.hxx b/Private/Drivers/PS2/Mouse.hxx index 20cac560..9e9607e1 100644 --- a/Private/Drivers/PS2/Mouse.hxx +++ b/Private/Drivers/PS2/Mouse.hxx @@ -19,8 +19,30 @@ namespace HCore { -class PS2Mouse { - explicit PS2Mouse() = default; +class PS2Mouse final { + public: + explicit PS2Mouse() { + HAL::Out8(0x64, 0xa8); + this->Wait(); + auto stat = HAL::In8(0x60); + + stat |= 0b10; + + this->Wait(); + + HAL::Out8(0x64, 0x60); + + this->Wait(); + + HAL::Out8(0x60, stat); + + this->Write(0xF6); + this->Read(); + + this->Write(0xF4); + this->Read(); + } + ~PS2Mouse() = default; HCORE_COPY_DEFAULT(PS2Mouse); @@ -30,14 +52,10 @@ class PS2Mouse { Int32 X, Y; }; - PS2MouseTraits Read() noexcept { - PS2MouseTraits stat; - - return stat; - } + Boolean operator>>(PS2MouseTraits& stat) noexcept { return true; } private: - UInt8 Wait() { + Bool Wait() noexcept { while (!(HAL::In8(0x64) & 1)) { asm("pause"); } // wait until we can read @@ -45,5 +63,18 @@ class PS2Mouse { // return the ack bit. return HAL::In8(0x64); } + + Void Write(UInt8 port) { + this->Wait(); + HAL::Out8(0x64, 0xD4); + this->Wait(); + + HAL::Out8(0x60, port); + } + + UInt8 Read() { + this->Wait(); + return HAL::In8(0x60); + } }; } // namespace HCore |
