-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
applications: nrf_desktop: Support passthrough reports in hid state #19690
base: main
Are you sure you want to change the base?
Conversation
CI InformationTo view the history of this post, clich the 'edited' button above Inputs:Sources:sdk-nrf: PR head: 911b0e43413099845edbb17a32fdfeca3643fe2b more detailssdk-nrf:
Github labels
List of changed files detected by CI (4)
Outputs:ToolchainVersion: b77d8c1312 Test Spec & Results: ✅ Success; ❌ Failure; 🟠 Queued; 🟡 Progress; ◻️ Skipped;
|
why @nrfconnect/ncs-co-build-system is needed for review of app specific kconfig? |
Because of the amount of abuse and wrong things in Kconfigs all over the tree that have improved substantially now things are actually reviewed and issues pointed out |
You can find the documentation preview for this PR at this link. It will be updated about 10 minutes after the documentation build succeeds. Note: This comment is automatically posted by the Documentation Publish GitHub Action. |
7ce0144
to
4a866a4
Compare
Appease pedantic checkpatch |
@@ -60,6 +60,13 @@ config DESKTOP_HID_EVENT_QUEUE_SIZE | |||
help | |||
Size of the HID event queue. | |||
|
|||
config DESKTOP_HID_STATE_RAW_REPORTS | |||
bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing a prompt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could add the prompt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not added prompt as I want this to be selected only when specific type of report is actually enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then none of this makes sense, the help text clearly states it can be enabled and there is no way to enable it, and none of this code is tested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not added prompt as I want this to be selected only when specific type of report is actually enabled.
but no Kconfigs are selecting this symbol.
And which specific type of reports are you referring to ?
The setting has no depends on
.
I think help text should be improved so that NCS users at least are able to understand when / how this setting is supposed to be used / why it is a hidden (prompt-less) setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then none of this makes sense
It can be that I have simply failed at writing simple enough help. Have not focus on this really. I have checked help text in various promptless options in Zephyr repo. I see that the word "Enable/d" is often used so I expect it's not impossible to get that enable means select in such cases.
I think help text should be improved so that NCS users...
@tejlmand , this change is part of more work needed, which is not public. I don't expect this will impact a generic NCS user since this app is very specific. Anyway this time waste is a good example of what I meant in my original comment. You clearly don't understand what is being done (which is fine as you have your own problems) and we have entered a bikeshedding discussion which is simply a time waste.
I will need to run one more edit as test failed and will add additional explanation to make you happy. Let's focus on something more productive on both ends.
@@ -60,6 +60,13 @@ config DESKTOP_HID_EVENT_QUEUE_SIZE | |||
help | |||
Size of the HID event queue. | |||
|
|||
config DESKTOP_HID_STATE_RAW_REPORTS | |||
bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could add the prompt
#define INPUT_REPORT_DATA_COUNT (ARRAY_SIZE(input_reports) - \ | ||
IS_ENABLED(CONFIG_DESKTOP_HID_REPORT_BOOT_INTERFACE_MOUSE) - \ | ||
IS_ENABLED(CONFIG_DESKTOP_HID_REPORT_BOOT_INTERFACE_KEYBOARD)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#define INPUT_REPORT_DATA_COUNT (ARRAY_SIZE(input_reports) - \ | |
IS_ENABLED(CONFIG_DESKTOP_HID_REPORT_BOOT_INTERFACE_MOUSE) - \ | |
IS_ENABLED(CONFIG_DESKTOP_HID_REPORT_BOOT_INTERFACE_KEYBOARD)) | |
#define INPUT_REPORT_DATA_COUNT (ARRAY_SIZE(input_reports) - \ | |
IS_ENABLED(CONFIG_DESKTOP_HID_BOOT_INTERFACE_MOUSE) - \ | |
IS_ENABLED(CONFIG_DESKTOP_HID_BOOT_INTERFACE_KEYBOARD)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also in other places
{ | ||
if (raw_data->data) { | ||
k_free((void *)raw_data->data); | ||
__ASSERT_NO_MSG(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is purpose of this assert? Shouldn't we submit hid_report_sent_event
informing about an error ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should never occur - I have left the free in case this happens for any reason but we can stick to assert only
|
||
/* Encode report. */ | ||
size_t report_size = rd->raw_data.size; | ||
struct hid_report_event *event = new_hid_report_event(report_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could enqueue the raw report instantly as hid_report_event
and just submit it here? That would significantly speed up processing of the external HID reports (1 less allocation+free, no copy)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe we could even add Event Manager API that would allow to "steal" processed event (app_event_steal(const struct app_event_header *aeh)
). The API could be called only while processing a given event (we could assert that) and it would be used to mark event as "stolen". Event Manager would consume the "stolen" event (later subscribers would not see the event) and pass the memory to module that "stole" the event (then the module is responsible for submitting/freeing the event).
"Stealing" events could be quite generic and useful feature. We might even think about splitting report formatting functionality out of HID state completely if we opt for adding it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about this. Also about moving the report composition outside of this file and so splitting the responsibilities. At this point I don't want to make such a big rework as there is no value in it.
@@ -923,7 +992,7 @@ static bool report_send(struct report_state *rs, | |||
} | |||
|
|||
/* Ensure that report marked as send_always will be sent. */ | |||
if (send_always && !report_sent) { | |||
if (try_send_always && !report_sent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we set it also in case we try to send raw HID report but have nothing to send? Maybe we need ability to generate an empty external report to "clear state"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was no use case for this. I would stick only to what is required to achieve the required functionality.
(usb_hid->report_bm & BIT(REPORT_ID_MOUSE))) { | ||
struct hid_report_subscription_event *event = | ||
new_hid_report_subscription_event(); | ||
for (size_t i = 0; i < ARRAY_SIZE(input_reports); i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
USB related changes looks good already. Maybe we could add it under a separate PR to speed up introducing this part ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kept it here as it is a change following the input_reports.
I don't see a reason why we would spend more then few more minutes in this PR, why opening new PR then?
LOG_INF("Report id %u was not subscribed", report_id); | ||
error = true; | ||
} else { | ||
rd->raw_data.data = k_malloc(size + sizeof(report_id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we handle case with queuing multiple reports (or at least properly emit an error here)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't see what you refer to.
This will work similarly to consumer/system ctrl report - no pipeline. It serves the purpose it was created for.
Error is handled, unless I missed something...
/* Nothing to send. */ | ||
return false; | ||
} | ||
LOG_WRN("Sending raw data report %d of size %zu", rs->report_id, rd->raw_data.size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOG_DBG
/LOG_INF
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the log - there is no reason as this occurrence will be logged in the event manager.
|
||
state.report_data[data_id].items.item_count_max = KEYBOARD_REPORT_KEY_COUNT_MAX; | ||
if (IS_ENABLED(CONFIG_DESKTOP_HID_REPORT_KEYBOARD_SUPPORT) || | ||
IS_ENABLED(CONFIG_DESKTOP_HID_REPORT_BOOT_INTERFACE_MOUSE)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IS_ENABLED(CONFIG_DESKTOP_HID_REPORT_BOOT_INTERFACE_MOUSE)) { | |
IS_ENABLED(CONFIG_DESKTOP_HID_BOOT_INTERFACE_KEYBOARD)) { |
report_data_index[REPORT_ID_MOUSE] = data_id; | ||
report_state_index[REPORT_ID_MOUSE] = state_id; | ||
if (IS_ENABLED(CONFIG_DESKTOP_HID_REPORT_MOUSE_SUPPORT) || | ||
IS_ENABLED(CONFIG_DESKTOP_HID_REPORT_BOOT_INTERFACE_MOUSE)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IS_ENABLED(CONFIG_DESKTOP_HID_REPORT_BOOT_INTERFACE_MOUSE)) { | |
IS_ENABLED(CONFIG_DESKTOP_HID_BOOT_INTERFACE_MOUSE)) { |
Each should focus on making they part work and be done on time, instead of worrying about "abuse and wrong things" in source they are not responsible for. |
4e1ae07
to
2ad29ca
Compare
rebased |
Allow the hid state module to handle reports created by external modules. These reports will still be sent according to the his state rules. Signed-off-by: Pawel Dunaj <[email protected]>
2ad29ca
to
911b0e4
Compare
Fixed issue that appeared after fixing boot report config option names. |
Allow the hid state module to handle reports created by external modules. These reports will still be sent according to the his state rules.