Skip to content

Conversation

@eternalcomet
Copy link
Contributor

  • Added a new crate axdriver_input with traits (InputDriverOps) and types (EventType, Event, InputDeviceId, etc.) for input device drivers.
  • Implemented the VirtIoInputDev struct in axdriver_virtio, providing a VirtIO-compliant input device driver that implements both BaseDriverOps and the new InputDriverOps traits.

Co-authored-by: 朝倉水希 <[email protected]>
Copy link

Copilot AI left a 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_input crate defining the InputDriverOps trait and related types (Event, InputDeviceId, EventType, etc.)
  • VirtIO input device implementation (VirtIoInputDev) in axdriver_virtio supporting both keyboard and mouse events
  • Integration of the new Input device 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.

Copy link

Copilot AI left a 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 {
Copy link

Copilot AI Dec 29, 2025

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.

Suggested change
impl EventType {
impl EventType {
/// Protocol-defined maximum event type value (matches Linux `EV_MAX` = 0x1f),
/// which may be larger than the largest `EventType` variant.

Copilot uses AI. Check for mistakes.
Comment on lines +60 to +68
fn physical_location(&self) -> &str {
// TODO: unique physical location
"virtio0/input0"
}

fn unique_id(&self) -> &str {
// TODO: unique ID
"virtio"
}
Copy link

Copilot AI Dec 29, 2025

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.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants