Files
OpenRGB/Controllers/QMKController/QMKOpenRGBController/QMKOpenRGBRevDController/RGBController_QMKOpenRGBRevD.h
Adam Honse 403ea4e6a6 RGBController API Overhaul
* Reorganize and clean up RGBController API functions
    * Add functions to get protected RGBController member values
    * Make NetworkClient, ProfileManager, and ResourceManager friend classes so they can access protected members
    * Protected previously-public RGBController members
        * Information strings (name, vendor, description, version, serial location)
        * Device type
        * Active mode
        * Flags
        * LEDs vector
        * LED alternate names vector
        * Modes vector
        * Colors vector
        * Zones vector
    * Add CONTROLLER_FLAG_HIDDEN to allow plugins to hide controllers from control GUI
    * Add update reason codes to RGBController update callback and signal updates on more RGBController events
    * Add loop zone types and segmented zone type
    * Add matrix map field to segments
    * Rework matrix_map_type from using pointers to vector to prevent memory leaks
    * Rework KeyboardLayoutManager to return new matrix_map_type
    * Add access mutex to RGBController API
    * Add per-zone modes ot RGBController API
    * Add JSON description functions to RGBController API
2026-01-31 22:05:38 -06:00

100 lines
4.6 KiB
C++

/*---------------------------------------------------------*\
| RGBController_QMKOpenRGBRevD.h |
| |
| RGBController for OpenRGB QMK Keyboard Protocol |
| Revision D |
| |
| Neneya 26 Dec 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include "RGBController.h"
#include "QMKOpenRGBRevDController.h"
#define NO_LED 0xFFFFFFFF
typedef std::vector<std::vector<unsigned int>> VectorMatrix;
class RGBController_QMKOpenRGBRevD : public RGBController
{
public:
RGBController_QMKOpenRGBRevD(QMKOpenRGBRevDController* controller_ptr, bool save);
~RGBController_QMKOpenRGBRevD();
void SetupZones();
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
void DeviceUpdateSingleLED(int led);
void DeviceUpdateMode();
void DeviceSaveMode();
private:
QMKOpenRGBRevDController* controller;
std::vector<unsigned int> flat_matrix_map;
std::vector<unsigned int> flat_underglow_map;
void InitializeMode
(
std::string name,
unsigned int &current_mode,
unsigned int flags,
unsigned int color_mode,
bool save
);
unsigned int CalculateDivisor
(
std::vector<point_t> led_points,
std::set<int> rows,
std::set<int> columns
);
void CountKeyTypes
(
std::vector<unsigned int> led_flags,
unsigned int total_led_count,
unsigned int& key_leds,
unsigned int& underglow_leds
);
void PlaceLEDsInMaps
(
std::set<int> unique_rows,
std::set<int> unique_cols,
unsigned int divisor,
std::vector<point_t> led_points,
std::vector<unsigned int> led_flags,
VectorMatrix& matrix_map_xl,
VectorMatrix& underglow_map_xl
);
VectorMatrix MakeEmptyMatrixMap
(
std::size_t height,
std::size_t width
);
void CleanMatrixMaps
(
VectorMatrix& matrix_map,
VectorMatrix& underglow_map,
unsigned int height,
bool has_underglow
);
std::vector<unsigned int> FlattenMatrixMap
(
VectorMatrix matrix_map
);
};