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

Tracking issue for input device support #183

Open
HaoboGu opened this issue Dec 13, 2024 · 3 comments · May be fixed by #192
Open

Tracking issue for input device support #183

HaoboGu opened this issue Dec 13, 2024 · 3 comments · May be fixed by #192
Labels
enhancement New feature or request tracking-issue Tracking issue of a specific feature

Comments

@HaoboGu
Copy link
Owner

HaoboGu commented Dec 13, 2024

RMK should support other input devices, like touchpad, encoder, joystick, etc.

@HaoboGu HaoboGu added the enhancement New feature or request label Dec 13, 2024
@HaoboGu
Copy link
Owner Author

HaoboGu commented Dec 13, 2024

Related issue: #29 #69

@HaoboGu
Copy link
Owner Author

HaoboGu commented Dec 24, 2024

Since the generic task limitation(embassy-rs/embassy#2454), the only way for defining a generic input device task is to use macro. There are two options:

  1. Use a proc-macro like:
#[input_device]
struct RotaryEncoder {}
impl InputDevice for RotaryEncoder {...}

which could be expanded as:

struct RotaryEncoder {}
impl InputDevice for RotaryEncoder {...}
#[embassy_executor::task]
async fn rotaryencoder_task(device: RotaryEncoder) -> ! {
  device.run().await
}
  1. Use a decl macro
struct RotaryEncoder {}
impl InputDevice for RotaryEncoder {...}
impl_input_device!(RotaryEncoder, task_name);

expanded code:

struct RotaryEncoder {}
impl InputDevice for RotaryEncoder {...}
#[embassy_executor::task]
async fn task_name(device: RotaryEncoder) -> ! {
  device.run().await
}
  • option 1: simple and easy to use, but it's hard to make the task name customizable; better diagnosis if users misuse it.
  • option 2: the task name can be customized, but need calling impl_input_device for each device; might be hard to debug if users misuse it

Now I'm going to option 2 first, Any ideas are welcome:)

@HaoboGu
Copy link
Owner Author

HaoboGu commented Dec 24, 2024

Okay, after some testing I found neither work with generic tasks. So I have to give up embassy task. The only option seems to be join all input device's run together:

// Implement the input device for RotaryEncoder
struct RotaryEncoder {}
impl InputDevice for RotaryEncoder {...}

in user space:

let e1 = RotaryEncoder {};
let e2 = RotaryEncoder {};
join(run_rmk(), run_devices!(e1, e2)).await

@HaoboGu HaoboGu linked a pull request Dec 24, 2024 that will close this issue
7 tasks
@HaoboGu HaoboGu added the tracking-issue Tracking issue of a specific feature label Dec 26, 2024
@HaoboGu HaoboGu pinned this issue Dec 26, 2024
@HaoboGu HaoboGu changed the title Pointing device support Tracking issue for input device support Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tracking-issue Tracking issue of a specific feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant