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

X-Macros for keycode definitions. #21078

Closed
wants to merge 1 commit into from

Conversation

tzarc
Copy link
Member

@tzarc tzarc commented May 29, 2023

Description

Converts keycode generation to X-Macros. Useful for conversion to text-equivalents.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@tzarc tzarc requested a review from a team May 29, 2023 10:44
@github-actions github-actions bot added cli qmk cli command core python labels May 29, 2023
@tzarc
Copy link
Member Author

tzarc commented May 29, 2023

Random selection of 100 boards show SHA1s match.

Copy link
Member

@fauxpark fauxpark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

X() is already used by Unicodemap (for now)... and I feel like this is overcomplicating things a little.

@tzarc
Copy link
Member Author

tzarc commented Jun 1, 2023

X() is already used by Unicodemap (for now)... and I feel like this is overcomplicating things a little.

For now, will change it to XX(...).

This is mainly for future work with scripting languages, inserting text-equivalent names into the scripting VM.
If there's no desire for it, I can close the PR.

Example:

// Register keycodes
const struct keycode_table_entry {
    const char *name;
    int         value;
} keycode_table[] = {
#define REGISTER_KEYCODE(name, value) {#name, name},
    FOREACH_QK_KEYCODE(REGISTER_KEYCODE)
#undef REGISTER_KEYCODE
        {NULL, 0}};

LUAMOD_API void register_globals(lua_State *L) {
    for (const struct keycode_table_entry *e = keycode_table; e->name != NULL; e++) {
        lua_pushinteger(L, e->value);
        lua_setglobal(L, e->name);
    }
}

@tzarc tzarc force-pushed the feature/keycode-x-macros branch from 35909f1 to 5c24ae4 Compare June 1, 2023 20:57
@zvecr
Copy link
Member

zvecr commented Jun 1, 2023

I share similar concerns, could we not just generate a different header from the cli? I guess that would be my preference. Would the test header not be close to whats required?

@fauxpark
Copy link
Member

fauxpark commented Jun 1, 2023

As of #21092 X() is now free to use.

There's also the sendstring keycodes which use an X_ prefix but it doesn't affect this PR as much, and I'm not sure what to do about those yet - things like X_LCTL -> SS_LCTL vs the existing SS_LCTL().

@tzarc
Copy link
Member Author

tzarc commented Jun 1, 2023

No probs, will move further discussion to Discord.

@tzarc tzarc closed this Jun 1, 2023
@tzarc tzarc deleted the feature/keycode-x-macros branch September 20, 2023 23:12
@tzarc tzarc restored the feature/keycode-x-macros branch September 20, 2023 23:12
@tzarc tzarc deleted the feature/keycode-x-macros branch September 20, 2023 23:12
@tzarc tzarc restored the feature/keycode-x-macros branch September 20, 2023 23:12
@tzarc tzarc deleted the feature/keycode-x-macros branch June 13, 2024 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli qmk cli command core python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants