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

drivers: input: add driver for the nintendo nunchuk #82655

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

miggazElquez
Copy link
Contributor

This patch adds a driver for the Nunchuk, a joystick from Nintendo.

@zephyrbot zephyrbot added the area: Input Input Subsystem and Drivers label Dec 6, 2024
drivers/input/input_nunchuk.c Outdated Show resolved Hide resolved
drivers/input/input_nunchuk.c Outdated Show resolved Hide resolved
drivers/input/input_nunchuk.c Outdated Show resolved Hide resolved
drivers/input/input_nunchuk.c Outdated Show resolved Hide resolved
Comment on lines +98 to +107
uint8_t init_seq_1[2] = {0xf0, 0x55};
uint8_t init_seq_2[2] = {0xfb, 0x00};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to have a define for these 4 constants? normally I'd ask to use the datasheet name but in this case there's probably not much to go by...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I don't think there is any official datasheet... I'm not sure it would be cleaner with 4 defines, but if you think it's better I can do it.

drivers/input/input_nunchuk.c Outdated Show resolved Hide resolved
drivers/input/input_nunchuk.c Outdated Show resolved Hide resolved
drivers/input/input_nunchuk.c Outdated Show resolved Hide resolved
}

k_msleep(10);
ret = i2c_read_dt(&cfg->i2c_bus, buffer, 6);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ret = i2c_read_dt(&cfg->i2c_bus, buffer, 6);
ret = i2c_read_dt(&cfg->i2c_bus, buffer, sizeof(buffer));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buffer is passed as an argument, so sizeof doesn't work here. I put a #define for it, I'm not totally sure about the name ?

Copy link
Member

@fabiobaltieri fabiobaltieri Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, how about passing an extra argument to nunchuk_read_registers with the buffer size? then you can do nunchuk_read_registers(dev, buffer, sizeof(buffer)); and just use it as is in the function. Doesn't make any difference just not thrilled with the function taking a pointer to a buffer and assuming its size.

drivers/input/input_nunchuk.c Outdated Show resolved Hide resolved
@miggazElquez miggazElquez force-pushed the nunchuk branch 3 times, most recently from e59eca1 to 0da2333 Compare December 9, 2024 10:51
drivers/input/input_nunchuk.c Outdated Show resolved Hide resolved
drivers/input/input_nunchuk.c Outdated Show resolved Hide resolved
Add a binding for the Nintendo Nunchuk joystick through the I2C bus.

Signed-off-by: Miguel Gazquez <[email protected]>
Add a driver for the Nintendo Nunchuk, accessed through the I2C bus.
This driver only supports the joystick and the buttons, not the
accelerometer.

Signed-off-by: Miguel Gazquez <[email protected]>
@kartben kartben merged commit 49eff65 into zephyrproject-rtos:main Dec 12, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Input Input Subsystem and Drivers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants