Skip to content

add handler for probe#297

Merged
lneto merged 2 commits intoluainkernel:hid-stagingfrom
qrsikno2:hid-staging
Jul 10, 2025
Merged

add handler for probe#297
lneto merged 2 commits intoluainkernel:hid-stagingfrom
qrsikno2:hid-staging

Conversation

@qrsikno2
Copy link
Contributor

@qrsikno2 qrsikno2 commented Jul 7, 2025

This pull request introduces significant enhancements to the lib/luahid.c file to improve HID (Human Interface Device) driver functionality. The changes include adding new dependencies, extending the luahid_t structure, implementing a probe mechanism for device initialization, and modifying the HID driver registration process to support Lua-based device handling.

Enhancements to HID driver functionality:

  • Added new dependencies for Lua and kernel utilities:
    Included linux/printk.h and lua.h headers to enable logging and Lua integration in the HID driver.

  • Extended luahid_t structure:
    Added a devtable member to store device-specific private data, improving the driver's ability to manage multiple devices.

Implementation of device initialization (probe mechanism):

  • Introduced luahid_probe and luahid_probe_handler:
    Implemented a probe function and its Lua-based handler to initialize devices using Lua scripts. The handler retrieves device information, calls an init function defined in Lua, and sets device-specific data (drvdata).

  • Lua example for device initialization:
    Added a sample Lua function (hid_driver:init) to demonstrate how device-specific features can be set based on devinfo.

Modifications to HID driver registration:

  • Updated luahid_register function:
    Integrated the probe mechanism into the HID driver registration process. This includes setting up the Lua registry for device handling and ensuring proper cleanup in case of registration failure.

@qrsikno2 qrsikno2 requested review from jperon, lneto and sheharyaar and removed request for jperon July 7, 2025 05:14
@sheharyaar
Copy link
Member

Also, have you tested this logic with an example lua script ? If yes, please share it with us or add it as an example script.
What do you suggest @lneto ?

@qrsikno2
Copy link
Contributor Author

qrsikno2 commented Jul 7, 2025

Also, have you tested this logic with an example lua script ? If yes, please share it with us or add it as an example script. What do you suggest @lneto ?

shared in the chat channel

@lneto
Copy link
Contributor

lneto commented Jul 7, 2025

Also, have you tested this logic with an example lua script ? If yes, please share it with us or add it as an example script. What do you suggest @lneto ?

I think we should have an example, but we don't need to block this PR for this.. but the sooner is better indeed..

@qrsikno2 qrsikno2 force-pushed the hid-staging branch 2 times, most recently from dc54118 to 0a41380 Compare July 10, 2025 14:31
@lneto lneto merged commit f788d78 into luainkernel:hid-staging Jul 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants