I consider magic numbers in the code a bad practise. Magic numbers are confusing and error-prone. Furthermore, no one dares to touch them if they do not know all the information about the given magic number and its origin in fear of breaking something.
In a reaction to the discussion in the last PR, I propose a replacement of the discussed magic number for maximal input event code with a macro. As a result, no one gets confused about the meaning of this value in the future and it saves some time for others trying to figure out what it stands for.
Solution
I suggest defining a macro MAX_KEYS_TO_ENABLE_KEY_EVENTS_HANDLING_FOR. The identifier itself describes exactly what is the purpose of this value in the source code while keeping in mind the original MAX_KEYS identifier, which we aim for. This macro replaces the aforementioned magic number 572 for maximal input event code handled by TouchCursor with a comment explaining what this magical 572 stands for and what it should be ideally instead, if there were no issues connected to MAX_KEYS.
At least until we solve the issue with MAX_KEYS, this solution should help keep the code readable and approachable to everyone.
Testing
All tests from test.c pass. I am using my version of TouchCursor with this PR included and everything has worked flawlessly so far.
Reason for this pull request
I consider magic numbers in the code a bad practise. Magic numbers are confusing and error-prone. Furthermore, no one dares to touch them if they do not know all the information about the given magic number and its origin in fear of breaking something.
In a reaction to the discussion in the last PR, I propose a replacement of the discussed magic number for maximal input event code with a macro. As a result, no one gets confused about the meaning of this value in the future and it saves some time for others trying to figure out what it stands for.
Solution
I suggest defining a macro
MAX_KEYS_TO_ENABLE_KEY_EVENTS_HANDLING_FOR
. The identifier itself describes exactly what is the purpose of this value in the source code while keeping in mind the originalMAX_KEYS
identifier, which we aim for. This macro replaces the aforementioned magic number572
for maximal input event code handled by TouchCursor with a comment explaining what this magical572
stands for and what it should be ideally instead, if there were no issues connected toMAX_KEYS
.At least until we solve the issue with
MAX_KEYS
, this solution should help keep the code readable and approachable to everyone.Testing
All tests from test.c pass. I am using my version of TouchCursor with this PR included and everything has worked flawlessly so far.