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

Have ColormapOverlay behave more like Colormap #1427

Merged
merged 8 commits into from
Aug 7, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace plugin {

// Data structure for an individual qukey
struct Overlay {
int8_t layer;
uint8_t layer;
KeyAddr addr;
uint8_t palette_index;

Expand All @@ -53,6 +53,19 @@ class ColormapOverlay : public kaleidoscope::Plugin {
overlay_count_ = _overlay_count;
}

template<uint8_t _layer_count>
void configureOverlays(uint8_t const (&overlays)[_layer_count][kaleidoscope_internal::device.matrix_rows * kaleidoscope_internal::device.matrix_columns]) {
overlays_ = Overlay[];
overlay_count_ = 0;
for (int layer_ = 0; layer_ < _layer_count; layer_++) {
for (int key_index_ = 0; key_index_ < kaleidoscope_internal::device.matrix_rows * kaleidoscope_internal::device.matrix_columns; key_index_++) {
color_index_ = overlays[layer_][key_index_];
// TODO(EvyBongers): validate the color index?
EvyBongers marked this conversation as resolved.
Show resolved Hide resolved
overlays_[overlay_count_] = Overlay(layer_, /* TODO(EvyBongers) */, color_index_);
EvyBongers marked this conversation as resolved.
Show resolved Hide resolved
overlay_count_++;
}
}
}
// A wildcard value for a qukey that exists on every layer.
static constexpr int8_t layer_wildcard{-1};

Expand All @@ -69,6 +82,36 @@ class ColormapOverlay : public kaleidoscope::Plugin {
void setLEDOverlayColors();
};

// clang-format off

#define COLORMAP_OVERLAYS_MAP(layers...) \
namespace kaleidoscope { \
namespace plugin { \
const uint8_t overlays_[][kaleidoscope_internal::device.matrix_rows * kaleidoscope_internal::device.matrix_columns] = { \
layers \
}; \
ColormapOverlay.configureOverlays(overlays_); \
} /* plugin */ \
} /* kaleidoscope */

#define __IDENTITY__(X) X

#ifdef PER_KEY_DATA_STACKED
#define COLORMAP_OVERLAY_STACKED(...) \
{ \
MAP_LIST(__IDENTITY__, PER_KEY_DATA_STACKED(0, __VA_ARGS__)) \
}
#endif

#ifdef PER_KEY_DATA
#define COLORMAP_OVERLAY(...) \
{ \
MAP_LIST(__IDENTITY__, PER_KEY_DATA(0, __VA_ARGS__)) \
}
#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is mostly copy/paste from DefaultColormap. I'm wondering if the namespaces need to be specified like they are 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Hm. I guess test it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't felt motivated to pursue this and messing with it could open a can of worms, so I just marked the PR ready to be merged. If I end up pursuing this, I'll do so in a separate PR.


// clang-format on

} // namespace plugin
} // namespace kaleidoscope

Expand Down
Loading