Initial commit for AOC AGON AMM700 mousemat

This commit is contained in:
Adam Honse 2023-04-15 23:48:55 -05:00
parent 490e4df1fc
commit e8163043c5
6 changed files with 290 additions and 0 deletions

View file

@ -0,0 +1,94 @@
/*-----------------------------------------*\
| AOCMousematController.cpp |
| |
| Driver for AOC Mousemat lighting |
| controller |
| |
| Adam Honse (CalcProgrammer1) 4/15/2023 |
\*-----------------------------------------*/
#include "AOCMousematController.h"
#include <cstring>
AOCMousematController::AOCMousematController(hid_device* dev_handle, const char* path)
{
dev = dev_handle;
location = path;
}
AOCMousematController::~AOCMousematController()
{
hid_close(dev);
}
std::string AOCMousematController::GetDeviceLocation()
{
return("HID " + location);
}
std::string AOCMousematController::GetSerialString()
{
wchar_t serial_string[128];
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void AOCMousematController::SendDirect
(
RGBColor* color_data
)
{
unsigned char buf[32];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
/*-----------------------------------------------------*\
| Set up packet |
\*-----------------------------------------------------*/
buf[0x00] = 0x20;
buf[0x01] = 0x03;
buf[0x02] = 0x01;
buf[0x04] = 0x01;
buf[0x09] = 0xFF;
buf[0x0C] = 0xFF;
buf[0x0D] = 0x3F;
buf[0x0F] = 0xFF;
buf[0x10] = 0xFF;
buf[0x13] = 0xFF;
buf[0x17] = 0xFF;
buf[0x19] = 0xFF;
buf[0x1A] = 0xFF;
buf[0x1B] = 0xFF;
buf[0x1D] = 0xFF;
buf[0x1E] = 0x32;
buf[0x1F] = 0x32;
/*-----------------------------------------------------*\
| Copy in color |
\*-----------------------------------------------------*/
buf[0x06] = RGBGetRValue(color_data[0]);
buf[0x07] = RGBGetGValue(color_data[0]);
buf[0x08] = RGBGetBValue(color_data[0]);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 32);
}

View file

@ -0,0 +1,33 @@
/*-----------------------------------------*\
| AOCMousematController.h |
| |
| Definitions and types for AOC mousemat |
| lighting controller |
| |
| Adam Honse (CalcProgrammer1) 4/15/2023 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <hidapi/hidapi.h>
#include <string>
#pragma once
class AOCMousematController
{
public:
AOCMousematController(hid_device* dev_handle, const char* path);
~AOCMousematController();
std::string GetDeviceLocation();
std::string GetSerialString();
void SendDirect
(
RGBColor* color_data
);
private:
hid_device* dev;
std::string location;
};

View file

@ -0,0 +1,34 @@
#include "Detector.h"
#include "AOCMousematController.h"
#include "RGBController.h"
#include "RGBController_AOCMousemat.h"
/*-----------------------------------------------------*\
| AOC Mousemat IDs |
\*-----------------------------------------------------*/
#define AOC_VID 0x3938
#define AOC_AMM700_PID 0x1162
/******************************************************************************************\
* *
* DetectAOCMousematControllers *
* *
* Tests the USB address to see if an AOC Mousemat controller exists there. *
* *
\******************************************************************************************/
void DetectAOCMousematControllers(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
AOCMousematController* controller = new AOCMousematController(dev, info->path);
RGBController_AOCMousemat* rgb_controller = new RGBController_AOCMousemat(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
REGISTER_HID_DETECTOR_IPU("AOC AGON AMM700", DetectAOCMousematControllers, AOC_VID, AOC_AMM700_PID, 1, 0xFF19, 0xFF19);

View file

@ -0,0 +1,91 @@
/*-----------------------------------------*\
| RGBController_AOCMousemat.cpp |
| |
| Generic RGB Interface for AOC mousemat |
| |
| Adam Honse (CalcProgrammer1) 4/15/2023 |
\*-----------------------------------------*/
#include "RGBController_AOCMousemat.h"
/**------------------------------------------------------------------*\
@name AOC Mousemat
@category Mousemat
@type USB
@save :x:
@direct :white_check_mark:
@effects :x:
@detectors DetectAOCMousematControllers
@comment
\*-------------------------------------------------------------------*/
RGBController_AOCMousemat::RGBController_AOCMousemat(AOCMousematController* controller_ptr)
{
controller = controller_ptr;
name = "AOC Mousemat Device";
vendor = "AOC";
type = DEVICE_TYPE_MOUSEMAT;
description = "AOC Mousemat Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
mode Direct;
Direct.name = "Direct";
Direct.value = 0xFFFF;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
SetupZones();
};
RGBController_AOCMousemat::~RGBController_AOCMousemat()
{
delete controller;
}
void RGBController_AOCMousemat::SetupZones()
{
zone mousemat_zone;
mousemat_zone.name = "Mousemat";
mousemat_zone.type = ZONE_TYPE_SINGLE;
mousemat_zone.leds_min = 1;
mousemat_zone.leds_max = 1;
mousemat_zone.leds_count = 1;
mousemat_zone.matrix_map = NULL;
zones.push_back(mousemat_zone);
led mousemat_led;
mousemat_led.name = "Mousemat";
leds.push_back(mousemat_led);
SetupColors();
}
void RGBController_AOCMousemat::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_AOCMousemat::DeviceUpdateLEDs()
{
controller->SendDirect(&colors[0]);
}
void RGBController_AOCMousemat::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_AOCMousemat::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_AOCMousemat::DeviceUpdateMode()
{
DeviceUpdateLEDs();
}

View file

@ -0,0 +1,32 @@
/*-----------------------------------------*\
| RGBController_AOCMousemat.h |
| |
| Generic RGB Interface for AOC mousemat |
| |
| Adam Honse (CalcProgrammer1) 4/15/2023 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AOCMousematController.h"
class RGBController_AOCMousemat : public RGBController
{
public:
RGBController_AOCMousemat(AOCMousematController* controller_ptr);
~RGBController_AOCMousemat();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
AOCMousematController* controller;
};

View file

@ -83,6 +83,7 @@ INCLUDEPATH +=
Controllers/AlienwareController/ \
Controllers/AlienwareKeyboardController/ \
Controllers/AMDWraithPrismController/ \
Controllers/AOCMousematController/ \
Controllers/ASRockPolychromeUSBController/ \
Controllers/ASRockSMBusController/ \
Controllers/AsusAuraCoreController/ \
@ -271,6 +272,8 @@ HEADERS +=
Controllers/AMDWraithPrismController/RGBController_AMDWraithPrism.h \
Controllers/AnnePro2Controller/AnnePro2Controller.h \
Controllers/AnnePro2Controller/RGBController_AnnePro2.h \
Controllers/AOCMousematController/AOCMousematController.h \
Controllers/AOCMousematController/RGBController_AOCMousemat.h \
Controllers/ASRockPolychromeUSBController/ASRockPolychromeUSBController.h \
Controllers/ASRockPolychromeUSBController/RGBController_ASRockPolychromeUSB.h \
Controllers/ASRockSMBusController/ASRockASRRGBSMBusController.h \
@ -821,6 +824,9 @@ SOURCES +=
Controllers/AnnePro2Controller/AnnePro2Controller.cpp \
Controllers/AnnePro2Controller/AnnePro2ControllerDetect.cpp \
Controllers/AnnePro2Controller/RGBController_AnnePro2.cpp \
Controllers/AOCMousematController/AOCMousematController.cpp \
Controllers/AOCMousematController/AOCMousematControllerDetect.cpp \
Controllers/AOCMousematController/RGBController_AOCMousemat.cpp \
Controllers/ASRockPolychromeUSBController/ASRockPolychromeUSBController.cpp \
Controllers/ASRockPolychromeUSBController/ASRockPolychromeUSBControllerDetect.cpp \
Controllers/ASRockPolychromeUSBController/RGBController_ASRockPolychromeUSB.cpp \