You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EDIT: Nothing to see here, everything is considered for XAP
I want to disambiguate the words/variables/functions that make use of report, data and usage to describe the state of switches, HID reports and their implementation for the different platforms/drivers.
I am also hoping to get comments on how wrong / right I am about the analysis.
⚠️ This is either partially or completely redundant with the introduction of XAP
TL;DR;
In the name of separation of concerns, I propose refactoring of the HID report datastructures and their respective send_*() functions.
In particular, I am suggesting the usage of these terms and conventions for their specific cases
hid_report_foo_t to describe a struct that contains at least uint8_t .report_id
host_foo_send() and send_foo() have to use hid_report_foo as argument
Example
staticvoidsend_foo(hid_report_foo_t*hid_report);
⚠️ The changes to functions arguments would be breaking / non backwards compatible
Vocabulary confusion between different abstractions
Inconsistent vocabulary ...
The words report, data and usage are sometimes used interchangeably, but not exclusively for a specific usage. Because they bleed out onto different data structures and meanings, they can obfuscate each others purpose.
// vusb.c// Here there is additionally the word `data` usedstaticvoidsend_programmable_button(uint32_tdata) {
staticreport_programmable_button_treport= {
.report_id=REPORT_ID_PROGRAMMABLE_BUTTON,
};
report.usage=data;
// [...]usbSetInterruptShared((void*)&report, sizeof(report));
}
If a report has a single field (outside of .report_id, then the field is used interchangeably/liberaly instead of being wrapped in the report struct. The reason might be to cut down on overall lines of code but I don't think it helps with the size of the final binary.
This means that all the driver interfaces have to know the underlying data structure and size to forward the call. Changes to data type and structure is therefore made more difficult.
This means the HID report is either created on the device driver side (tmk_core/protocol), or on the side of the key processor (quantum/), which is also an inconsistent behaviour.
I suggest to have all the HID reports
generated in the key processors (quantum/)
Forwarded through the appropriate channels (sometimes through host driver)
Final drivers read the HID report and send packets
The extra keys (EXTRA_KEYS_ENABLE) using host_system_send() or host_consumer_send() have their HID report generated on the device driver, e.g. tmk_core/protocol/arm_atsam/main_arm_atsam.c
Using non-descriptive variable names
When referencing the state of the switches, the word data is often used as a stopgap term for single attribute hid reports, especially for driver implementations. At that stage the data does have a meaning and can benefit from a specific term. Among other benefits, increased visibility makes it easier to lookup other definitions/usage of that term.
Additionally, the attribute could be assigned a typedef if the type could be foreseen to change (as it was for layer_state_t). Changing the size of the variable type could all be done from report.h. Every driver implementation probably needs to be updated anyway.
// host.cstaticattr_1_foo_tlast_foo_attr_1=0voidhost_foo_send(attr_1_foo_tattr_1) {
if (attr_1==last_foo_attr_1) return;
last_foo_attr_1=attr_1;
if (!driver) return;
(*driver->send_foo)(usage);
}
Finally
I apologise if the over-documentation comes across as condescending, but I prefer to specify goal, argumentation and examples as much as possible; even when discussing with strangers of the internet that are way more knowledgeable than myself.
I would be happy to make those changes if they are deemed reasonable.
EDIT: I made a mistake about assuming the HID report was generated from key processors in quantum/
The text was updated successfully, but these errors were encountered:
EDIT: Nothing to see here, everything is considered for XAP
I want to disambiguate the words/variables/functions that make use of
report
,data
andusage
to describe the state of switches, HID reports and their implementation for the different platforms/drivers.I am also hoping to get comments on how wrong / right I am about the analysis.
TL;DR;
In the name of separation of concerns, I propose refactoring of the HID report datastructures and their respective
send_*()
functions.In particular, I am suggesting the usage of these terms and conventions for their specific cases
hid_report_foo_t
to describe astruct
that contains at leastuint8_t .report_id
Example
Ideally
hid_report_foo
would be a subset/implementation of ahid_report
(like an abstract base class)Use descriptive names for the attributes of
hid_report_foo_t
Example
instead of
data
orusage
, useswitch_state
,closed_switches
,reported_keys
orpressed_btns
host_foo_send()
andsend_foo()
have to usehid_report_foo
as argumentExample
Vocabulary confusion between different abstractions
Inconsistent vocabulary ...
The words
report
,data
andusage
are sometimes used interchangeably, but not exclusively for a specific usage. Because they bleed out onto different data structures and meanings, they can obfuscate each others purpose.Examples
And in the case of
send_consumer()
:... leading to mismatching interfaces ...
If a
report
has a single field (outside of.report_id
, then the field is used interchangeably/liberaly instead of being wrapped in thereport
struct. The reason might be to cut down on overall lines of code but I don't think it helps with the size of the final binary.This means that all the driver interfaces have to know the underlying data structure and size to forward the call. Changes to data type and structure is therefore made more difficult.
Examples
send_*
functions:... and different implementationsRetracted
This means the HID report is either created on the device driver side (tmk_core/protocol
), or on the side of the key processor (quantum/
), which is also an inconsistent behaviour.I suggest to have all the HID reports
quantum/
)Example
quantum/pointing_device.c
~~host_system_send()
orhost_consumer_send()
have their HID report generated on the device driver, e.g.tmk_core/protocol/arm_atsam/main_arm_atsam.c
Using non-descriptive variable names
When referencing the state of the switches, the word
data
is often used as a stopgap term for single attribute hid reports, especially for driver implementations. At that stage the data does have a meaning and can benefit from a specific term. Among other benefits, increased visibility makes it easier to lookup other definitions/usage of that term.See : Article written against the usage of vague terms / names
Additionally, the attribute could be assigned a
typedef
if the type could be foreseen to change (as it was forlayer_state_t
). Changing the size of the variable type could all be done fromreport.h
. Every driver implementation probably needs to be updated anyway.Example
Finally
I apologise if the over-documentation comes across as condescending, but I prefer to specify goal, argumentation and examples as much as possible; even when discussing with strangers of the internet that are way more knowledgeable than myself.
I would be happy to make those changes if they are deemed reasonable.
EDIT: I made a mistake about assuming the HID report was generated from key processors in
quantum/
The text was updated successfully, but these errors were encountered: