Formatting and organizational cleanup for controllers beginning with A

This commit is contained in:
Adam Honse 2024-04-30 23:37:19 -05:00
parent 89645dff38
commit b6d5c64c5b
78 changed files with 356 additions and 379 deletions

View file

@ -40,7 +40,7 @@ std::string BloodyB820RController::GetSerial()
std::wstring wName = std::wstring(tmpName);
std::string serial = std::string(wName.begin(), wName.end());
return serial;
return(serial);
}
std::string BloodyB820RController::GetLocation()
@ -50,12 +50,12 @@ std::string BloodyB820RController::GetLocation()
void BloodyB820RController::SendControlPacket(uint8_t data)
{
uint8_t buffer[BLOODY_B820R_PACKET_SIZE] = { 0x07, 0x03, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00 };
uint8_t buffer[BLOODY_B820R_PACKET_SIZE] = { 0x07, 0x03, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00 };
hid_send_feature_report(dev, buffer, BLOODY_B820R_PACKET_SIZE);
buffer[BLOODY_B820R_MODE_BYTE] = 0;
buffer[BLOODY_B820R_DATA_BYTE] = data;
buffer[BLOODY_B820R_MODE_BYTE] = 0;
buffer[BLOODY_B820R_DATA_BYTE] = data;
hid_send_feature_report(dev, buffer, BLOODY_B820R_PACKET_SIZE);
}
@ -75,14 +75,12 @@ void BloodyB820RController::SetLEDDirect(std::vector<RGBColor> colors)
| packet_map is the index of the Key from full_matrix_map and |
| the value is the position in the direct packet buffer |
\*-----------------------------------------------------------------*/
for(size_t i = 0; i < colors.size(); i++)
{
RGBColor color = colors[i];
uint8_t offset = BLOODY_B820R_RGB_OFFSET;
uint8_t buffer_idx = offset + i % BLOODY_B820R_RGB_BUFFER_SIZE;
uint8_t* buffers[2][3] =
RGBColor color = colors[i];
uint8_t offset = BLOODY_B820R_RGB_OFFSET;
uint8_t buffer_idx = offset + i % BLOODY_B820R_RGB_BUFFER_SIZE;
uint8_t* buffers[2][3] =
{
{r1_buffer, g1_buffer, b1_buffer},
{r2_buffer, g2_buffer, b2_buffer}
@ -99,4 +97,4 @@ void BloodyB820RController::SetLEDDirect(std::vector<RGBColor> colors)
hid_send_feature_report(dev, g2_buffer, BLOODY_B820R_PACKET_SIZE);
hid_send_feature_report(dev, b1_buffer, BLOODY_B820R_PACKET_SIZE);
hid_send_feature_report(dev, b2_buffer, BLOODY_B820R_PACKET_SIZE);
}
}

View file

@ -7,13 +7,13 @@
| |
\*-------------------------------------------------------------------*/
#pragma once
#include <string>
#include <hidapi/hidapi.h>
#include "RGBController.h"
#pragma once
#define NA 0xFFFFFFFF
#define HID_MAX_STR 255
#define HID_MAX_STR 255
#define BLOODY_B820R_RGB_BUFFER_SIZE 58
#define BLOODY_B820R_RGB_OFFSET 6

View file

@ -10,128 +10,131 @@
#include "RGBControllerKeyNames.h"
#include "RGBController_BloodyB820R.h"
//0xFFFFFFFF indicates an unused entry in matrix
#define NA 0xFFFFFFFF
static unsigned int matrix_map[6][21] =
{
{0, NA, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, NA, NA, NA, NA, 13, 14, 15},
{16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36},
{37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57},
{58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, NA, NA, NA, NA, 71, 72, 73, NA},
{74, NA, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, NA, NA, 86, NA, 87, 88, 89, 90},
{91, 92, 93, 94, NA, NA, NA, NA, NA, NA, 95, 96, 97, 98, 99, 100, 101, 102, NA, 103, NA},
};
{
{0, NA, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, NA, NA, NA, NA, 13, 14, 15},
{16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36},
{37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57},
{58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, NA, NA, NA, NA, 71, 72, 73, NA},
{74, NA, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, NA, NA, 86, NA, 87, 88, 89, 90},
{91, 92, 93, 94, NA, NA, NA, NA, NA, NA, 95, 96, 97, 98, 99, 100, 101, 102, NA, 103, NA},
};
static const char *led_names[] =
{
KEY_EN_ESCAPE, //00
KEY_EN_F1,
KEY_EN_F2,
KEY_EN_F3,
KEY_EN_F4,
KEY_EN_F5,
KEY_EN_F6,
KEY_EN_F7,
KEY_EN_F8,
KEY_EN_F9,
KEY_EN_F10,
KEY_EN_F11,
KEY_EN_F12,
KEY_EN_PRINT_SCREEN,
KEY_EN_SCROLL_LOCK,
KEY_EN_PAUSE_BREAK,
{
KEY_EN_ESCAPE, //00
KEY_EN_F1,
KEY_EN_F2,
KEY_EN_F3,
KEY_EN_F4,
KEY_EN_F5,
KEY_EN_F6,
KEY_EN_F7,
KEY_EN_F8,
KEY_EN_F9,
KEY_EN_F10,
KEY_EN_F11,
KEY_EN_F12,
KEY_EN_PRINT_SCREEN,
KEY_EN_SCROLL_LOCK,
KEY_EN_PAUSE_BREAK,
KEY_EN_BACK_TICK, //10
KEY_EN_1,
KEY_EN_2,
KEY_EN_3,
KEY_EN_4,
KEY_EN_5,
KEY_EN_6,
KEY_EN_7,
KEY_EN_8,
KEY_EN_9,
KEY_EN_0,
KEY_EN_MINUS,
KEY_EN_EQUALS,
KEY_EN_BACKSPACE,
KEY_EN_INSERT,
KEY_EN_HOME,
KEY_EN_PAGE_UP,
KEY_EN_NUMPAD_LOCK,
KEY_EN_NUMPAD_DIVIDE,
KEY_EN_NUMPAD_TIMES,
KEY_EN_NUMPAD_MINUS,
KEY_EN_BACK_TICK, //10
KEY_EN_1,
KEY_EN_2,
KEY_EN_3,
KEY_EN_4,
KEY_EN_5,
KEY_EN_6,
KEY_EN_7,
KEY_EN_8,
KEY_EN_9,
KEY_EN_0,
KEY_EN_MINUS,
K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ROW,
KEY_EN_RIGHT_ARROW,
KEY_EN_NUMPAD_0,
KEY_EN_NUMPAD_PERIOD
};
/**------------------------------------------------------------------*\
@name A4Tech Bloody B820R
@ -225,6 +228,7 @@ void RGBController_BloodyB820R::DeviceUpdateLEDs()
void RGBController_BloodyB820R::UpdateZoneLEDs(int zone)
{
std::vector<RGBColor> colour;
for(size_t i = 0; i < zones[zone].leds_count; i++)
{
colour.push_back(zones[zone].colors[i]);
@ -244,4 +248,4 @@ void RGBController_BloodyB820R::UpdateSingleLED(int led)
void RGBController_BloodyB820R::DeviceUpdateMode()
{
/* This device does not support modes yet */
}
}

View file

@ -1,16 +1,17 @@
/*-------------------------------------------------------------------*\
| RGBController_BloodyB820R.h |
| RGBController_BloodyB820R.h |
| |
| Driver for A4Tech Bloody B820R Keyboard Controller |
| Driver for A4Tech Bloody B820R Keyboard Controller |
| |
| Mohammed Julfikar Ali Mahbub (o-julfikar) 01 Apr 2024 |
| |
\*-------------------------------------------------------------------*/
#pragma once
#include <vector>
#include "RGBController.h"
#include "BloodyB820RController.h"
#include <vector>
class RGBController_BloodyB820R : public RGBController
{
@ -29,4 +30,4 @@ public:
private:
BloodyB820RController* controller;
};
};

View file

@ -26,7 +26,7 @@ BloodyMouseController::~BloodyMouseController()
uint16_t BloodyMouseController::GetPid()
{
return pid;
return(pid);
}
std::string BloodyMouseController::GetSerial()
@ -45,7 +45,7 @@ std::string BloodyMouseController::GetSerial()
std::wstring w_tmp = std::wstring(tmp);
std::string serial = std::string(w_tmp.begin(), w_tmp.end());
return serial;
return(serial);
}
std::string BloodyMouseController::GetLocation()
@ -53,7 +53,7 @@ std::string BloodyMouseController::GetLocation()
return("HID: " + location);
}
void BloodyMouseController::InitDevice()
void BloodyMouseController::InitDevice()
{
uint8_t buffer[BLOODYMOUSE_WRITE_PACKET_SIZE] = { 0x07, 0x03, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00 };
@ -65,7 +65,7 @@ void BloodyMouseController::InitDevice()
hid_send_feature_report(dev, buffer, BLOODYMOUSE_WRITE_PACKET_SIZE);
}
void BloodyMouseController::SetLedsDirect(std::vector<RGBColor> colors)
void BloodyMouseController::SetLedsDirect(std::vector<RGBColor> colors)
{
uint8_t buffer[BLOODYMOUSE_WRITE_PACKET_SIZE] = { 0x07, 0x03, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00 };

View file

@ -7,12 +7,12 @@
| |
\*---------------------------------------------------------------------*/
#pragma once
#include <string>
#include <hidapi/hidapi.h>
#include "RGBController.h"
#pragma once
/*-----------------------------------------------------*\
| Mouse product IDs |
\*-----------------------------------------------------*/
@ -24,7 +24,7 @@
\*-----------------------------------------------------*/
#define BLOODY_MP_50RS_PID 0xFA60
#define HID_MAX_STR 255
#define HID_MAX_STR 255
#define BLOODYMOUSE_WRITE_PACKET_SIZE 64
#define BLOODYMOUSE_BRIGHTNESS_MIN 0
@ -54,6 +54,7 @@ public:
std::string GetLocation();
void SetLedsDirect(std::vector<RGBColor> colors);
private:
uint16_t pid;
std::string location;

View file

@ -8,6 +8,7 @@
\*---------------------------------------------------------------------*/
#pragma once
#include <vector>
#include "RGBController.h"
#include "BloodyMouseController.h"