Skip to content
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

Rust binary literals. #298

Open
Josh015 opened this issue Feb 25, 2025 · 1 comment
Open

Rust binary literals. #298

Josh015 opened this issue Feb 25, 2025 · 1 comment

Comments

@Josh015
Copy link

Josh015 commented Feb 25, 2025

Forgive me if I'm missing something obvious, but in lego/hid_report.rs and dualsense/hid_report.rs couldn't you just use Rust binary literals rather than bit-shifts for the as_bitflag() functions?

Example:

impl DPadDirection {
    pub fn as_bitflag(&self) -> u8 {
        match *self {
            Self::Up => 0b0001,
            Self::UpRight => 0b0011,
            Self::Right => 0b0010,
            Self::DownRight => 0b0110,
            Self::Down => 0b0100,
            Self::DownLeft => 0b1100,
            Self::Left => 0b1000,
            Self::UpLeft => 0b1001,
            Self::None => 0b0000,
        }
    }
}
@pastaq
Copy link
Contributor

pastaq commented Feb 25, 2025

We could, and have started in newer drivers. The new horipad uses binary literals for example. We probably need to review the older drivers for a lot of lessons learned soon. Thanks for pointing this out

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

No branches or pull requests

2 participants