2019-01-11 01:28:53 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <VirtualFileSystem/CharacterDevice.h>
|
2019-01-12 04:20:56 +00:00
|
|
|
#include "DoubleBuffer.h"
|
2019-01-11 01:28:53 +00:00
|
|
|
#include "IRQHandler.h"
|
|
|
|
|
|
|
|
class PS2MouseDevice final : public IRQHandler, public CharacterDevice {
|
|
|
|
public:
|
|
|
|
PS2MouseDevice();
|
|
|
|
virtual ~PS2MouseDevice() override;
|
|
|
|
|
2019-01-11 02:52:09 +00:00
|
|
|
static PS2MouseDevice& the();
|
|
|
|
|
2019-01-12 04:20:56 +00:00
|
|
|
// ^CharacterDevice
|
2019-01-15 23:10:13 +00:00
|
|
|
virtual bool can_read(Process&) const override;
|
2019-01-15 23:20:38 +00:00
|
|
|
virtual ssize_t read(Process&, byte* buffer, size_t) override;
|
|
|
|
virtual ssize_t write(Process&, const byte* buffer, size_t) override;
|
2019-01-15 08:17:22 +00:00
|
|
|
virtual bool can_write(Process&) const override { return true; }
|
2019-01-11 01:28:53 +00:00
|
|
|
|
2019-01-12 04:20:56 +00:00
|
|
|
private:
|
|
|
|
// ^IRQHandler
|
2019-01-11 01:28:53 +00:00
|
|
|
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);
|
|
|
|
|
2019-01-12 04:20:56 +00:00
|
|
|
DoubleBuffer m_buffer;
|
2019-01-11 01:28:53 +00:00
|
|
|
byte m_data_state { 0 };
|
|
|
|
signed_byte m_data[3];
|
|
|
|
};
|