-
Notifications
You must be signed in to change notification settings - Fork 24
feat: add input device #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: 朝倉水希 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds input device driver support to the axdriver ecosystem by introducing a new axdriver_input crate with common traits and types for input devices, and implementing a VirtIO-compliant input device driver.
Key Changes:
- New
axdriver_inputcrate defining theInputDriverOpstrait and related types (Event,InputDeviceId,EventType, etc.) - VirtIO input device implementation (
VirtIoInputDev) inaxdriver_virtiosupporting both keyboard and mouse events - Integration of the new
Inputdevice type into the driver base and VirtIO infrastructure
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
axdriver_input/src/lib.rs |
Defines core traits and types for input device drivers, including InputDriverOps, Event, EventType, and InputDeviceId |
axdriver_input/Cargo.toml |
Package configuration for the new input driver crate |
axdriver_virtio/src/input.rs |
Implements VirtIoInputDev providing VirtIO input device support with event reading and configuration querying |
axdriver_virtio/src/lib.rs |
Integrates the input module and maps VirtIO Input device type to DeviceType::Input |
axdriver_virtio/Cargo.toml |
Adds input feature flag and axdriver_input dependency |
axdriver_base/src/lib.rs |
Adds Input variant to the DeviceType enum |
Cargo.toml |
Adds workspace dependency for axdriver_input |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d9fec33 to
b097147
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ForceFeedback = 0x15, | ||
| } | ||
|
|
||
| impl EventType { |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MAX constant is set to 0x1f (31), but the largest EventType enum variant is ForceFeedback = 0x15 (21). This inconsistency could lead to incorrect behavior when code relies on this constant to represent the maximum event type value. Consider either setting MAX to 0x15 to match the actual maximum enum value, or adding a comment explaining why MAX is 0x1f if it represents a protocol-defined maximum rather than the enum's maximum value.
| impl EventType { | |
| impl EventType { | |
| /// Protocol-defined maximum event type value (matches Linux `EV_MAX` = 0x1f), | |
| /// which may be larger than the largest `EventType` variant. |
| fn physical_location(&self) -> &str { | ||
| // TODO: unique physical location | ||
| "virtio0/input0" | ||
| } | ||
|
|
||
| fn unique_id(&self) -> &str { | ||
| // TODO: unique ID | ||
| "virtio" | ||
| } |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hard-coded strings "virtio0/input0" and "virtio" mean that all VirtIO input devices will report the same physical location and unique ID, making them indistinguishable from each other. This violates the intended purpose of these methods, which is to provide unique identification for each device instance. Consider generating unique identifiers, perhaps by incorporating the device's bus address or a counter into these strings.
Co-authored-by: Copilot <[email protected]>
axdriver_inputwith traits (InputDriverOps) and types (EventType,Event,InputDeviceId, etc.) for input device drivers.VirtIoInputDevstruct inaxdriver_virtio, providing a VirtIO-compliant input device driver that implements bothBaseDriverOpsand the newInputDriverOpstraits.