mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 12:12:45 +00:00 
			
		
		
		
	 8a0a3638f0
			
		
	
	
		8a0a3638f0
		
	
	
	
	
		
			
			This device will be used by userspace to read mouse packets from all mouse devices that are attached to the machine. This change is a preparation before we can enable seamless hotplug capabilities in WindowServer for mouse devices, without any major change on the userspace side.
		
			
				
	
	
		
			40 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2023, Liav A. <liavalb@hotmail.co.il>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/CircularQueue.h>
 | |
| #include <AK/Types.h>
 | |
| #include <Kernel/API/MousePacket.h>
 | |
| #include <Kernel/Devices/CharacterDevice.h>
 | |
| #include <Kernel/Security/Random.h>
 | |
| 
 | |
| namespace Kernel {
 | |
| 
 | |
| class AllMiceDevice final : public CharacterDevice {
 | |
|     friend class DeviceManagement;
 | |
| 
 | |
| public:
 | |
|     static NonnullRefPtr<AllMiceDevice> must_create();
 | |
| 
 | |
|     virtual ~AllMiceDevice() override;
 | |
| 
 | |
|     void enqueue_mouse_packet(MousePacket packet);
 | |
| 
 | |
| private:
 | |
|     AllMiceDevice();
 | |
| 
 | |
|     // ^CharacterDevice
 | |
|     virtual StringView class_name() const override { return "AllMiceDevice"sv; }
 | |
|     virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
 | |
|     virtual bool can_read(OpenFileDescription const&, u64) const override;
 | |
|     virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return EINVAL; }
 | |
|     virtual bool can_write(OpenFileDescription const&, u64) const override { return true; }
 | |
| 
 | |
|     mutable Spinlock<LockRank::None> m_queue_lock {};
 | |
|     CircularQueue<MousePacket, 1000> m_queue;
 | |
| };
 | |
| }
 |