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

[Feature] Add user functionality #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

elpekenin
Copy link
Contributor

@elpekenin elpekenin commented Feb 16, 2023

Description

Litle code allowing users to develop custom logic.

  1. Parse incoming user-level(id==3) XAP broadcast messages (receive info from the keyboard) and generate events to be handled by user. Un-populated struct representing the message's content to be filled by user

  2. Hooks for

    • Handling custom messages
    • Pre init
    • On exit
    • New device
    • Device disconnected
    • Housekeeping (run every 0.5 seconds)

    These currently are just empty placeholder functions within user.rs

  3. UserData struct so custom data can be stored/used on user's functions. In the same way as UserBroadcast, the specific implementation is left as an exercise to the reader

Extra: Some minor refactors due to cargo fmt

PS: Haven't tested this particular code further than seeing it compiles, but my fork's code (which is way more complex) works, so this one should too... Unless i forgot copying some small piece

@HigherOrderLogic
Copy link

If the funtionalities only exist in the app, in other word, not compiled or downloaded into the device, then maybe we can use Lua? Lua is pretty much easier for end users to learn; also, it's quite easy to integrate it with Rust code.

@elpekenin
Copy link
Contributor Author

elpekenin commented Sep 3, 2023

not compiled [...] into the device

If there's some custom communication involved, there is going to be code for that on the device's fw, and most likely on the client too (to receive & process them)

Lua would indeed be useful for stuff like: there are already messages defined for RGB/OLED, and then user's code wants to draw a custom effect/image

However, prior to that, we need some place where users can plug their logic (i.e.: this PR). Also, probably the easiest thing to integrate would be JavaScript (already used on the frontend), perhaps user writing code and saving it on a file + eval'ing it

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