11/* ---------------------------------------------------------*\
2- | ZETEdgeAirProController .cpp |
2+ | AresonController .cpp |
33| |
4- | Driver for ZET Edge Air Pro |
4+ | Driver for Areson mice |
55| |
66| Morgan Guimard (morg) 29 Jan 2022 |
77| |
1111
1212#include < string.h>
1313#include " StringUtils.h"
14- #include " ZETEdgeAirProController .h"
14+ #include " AresonController .h"
1515
16- ZETEdgeAirProController::ZETEdgeAirProController (hid_device* dev_handle, const hid_device_info& info, std::string dev_name)
16+ AresonController::AresonController (hid_device* dev_handle, const hid_device_info& info, std::string dev_name)
1717{
1818 dev = dev_handle;
1919 location = info.path ;
2020 name = dev_name;
2121}
2222
23- ZETEdgeAirProController ::~ZETEdgeAirProController ()
23+ AresonController ::~AresonController ()
2424{
2525 hid_close (dev);
2626}
2727
28- std::string ZETEdgeAirProController ::GetDeviceLocation ()
28+ std::string AresonController ::GetDeviceLocation ()
2929{
3030 return (" HID: " + location);
3131}
3232
33- std::string ZETEdgeAirProController ::GetNameString ()
33+ std::string AresonController ::GetNameString ()
3434{
3535 return (name);
3636}
3737
38- std::string ZETEdgeAirProController ::GetSerialString ()
38+ std::string AresonController ::GetSerialString ()
3939{
4040 wchar_t serial_string[128 ];
4141 int ret = hid_get_serial_number_string (dev, serial_string, 128 );
@@ -48,19 +48,47 @@ std::string ZETEdgeAirProController::GetSerialString()
4848 return (StringUtils::wstring_to_string (serial_string));
4949}
5050
51- void ZETEdgeAirProController::SetMode (RGBColor color, unsigned char brightness, unsigned char speed, unsigned char mode_value)
51+ unsigned char AresonController::GetSpeedValue (unsigned char speed, unsigned char mode_value)
52+ {
53+ unsigned char speed_values_lookup_high[ARESON_SPEED_MAX] =
54+ {
55+ 0xFF , 0xE6 , 0xD2 , 0xBe , 0xAA , 0x96 , 0x82 , 0x6E , 0x46 , 0x28
56+ };
57+
58+ unsigned char speed_values_lookup_low[ARESON_SPEED_MAX] =
59+ {
60+ 0x2D , 0x28 , 0x23 , 0x1E , 0x19 , 0x13 , 0x0F , 0x0A , 0x05 , 0x03
61+ };
62+
63+ switch (mode_value)
64+ {
65+ case BREATHING_MODE_VALUE:
66+ case SPECRTUM_CYCLE_MODE_VALUE:
67+ case SINGLE_COLOR_WAVE_MODE_VALUE:
68+ case BREATHING_COLORFUL_MODE_VALUE:
69+ return speed_values_lookup_high[speed -1 ];
70+
71+ case RAINBOW_WAVE_MODE_VALUE:
72+ return speed_values_lookup_low[speed -1 ];
73+
74+ default :
75+ return 0 ;
76+ }
77+ }
78+
79+ void AresonController::SetMode (RGBColor color, unsigned char brightness, unsigned char speed, unsigned char mode_value)
5280{
5381 /* ---------------------------------------------------------*\
5482 | Init the packet buffer |
5583 \*---------------------------------------------------------*/
56- unsigned char usb_buf[ZET_EDGE_AIR_PRO_PACKET_SIZE ];
84+ unsigned char usb_buf[ARESON_PACKET_SIZE ];
5785
5886 memset (usb_buf, 0x00 , sizeof (usb_buf));
5987
6088 /* ---------------------------------------------------------*\œ
6189 | Constant data |
6290 \*---------------------------------------------------------*/
63- usb_buf[0x00 ] = ZET_EDGE_AIR_PRO_REPORT_ID ;
91+ usb_buf[0x00 ] = ARESON_REPORT_ID ;
6492 usb_buf[0x01 ] = 0x07 ;
6593 usb_buf[0x04 ] = 0xA0 ;
6694 usb_buf[0x05 ] = 0x07 ;
@@ -80,30 +108,14 @@ void ZETEdgeAirProController::SetMode(RGBColor color, unsigned char brightness,
80108 /* ---------------------------------------------------------*\
81109 | Set speed if needed |
82110 \*---------------------------------------------------------*/
83- if (mode_value == BREATHING_MODE_VALUE)
84- {
85- unsigned char speed_values[ZET_EDGE_AIR_PRO_SPEED_MAX] =
86- {
87- 0xFF , 0xE6 , 0xD2 , 0xBe , 0xAA , 0x96 , 0x82 , 0x6E , 0x46 , 0x28
88- };
89-
90- usb_buf[0x0A ] = speed_values[speed - 1 ];
91- }
92- else if (mode_value == RAINBOW_MODE_VALUE)
93- {
94- unsigned char speed_values[ZET_EDGE_AIR_PRO_SPEED_MAX] =
95- {
96- 0x2D , 0x28 , 0x23 , 0x1E , 0x19 , 0x13 , 0x0F , 0x0A , 0x05 , 0x03
97- };
111+ usb_buf[0x0A ] = GetSpeedValue (speed, mode_value);
98112
99- usb_buf[0x0A ] = speed_values[speed - 1 ];
100- }
101113 /* ---------------------------------------------------------*\
102114 | Set brightness if needed |
103115 \*---------------------------------------------------------*/
104116 if (mode_value != OFF_MODE_VALUE)
105117 {
106- unsigned char brightness_values[ZET_EDGE_AIR_PRO_BRIGHTNESS_MAX ] =
118+ unsigned char brightness_values[ARESON_BRIGHTNESS_MAX ] =
107119 {
108120 0x19 , 0x32 , 0x4B , 0x64 , 0x7D , 0x96 , 0xAF , 0xC8 , 0xE1 , 0xFF
109121 };
@@ -119,10 +131,10 @@ void ZETEdgeAirProController::SetMode(RGBColor color, unsigned char brightness,
119131 /* ---------------------------------------------------------*\
120132 | Constant data |
121133 \*---------------------------------------------------------*/
122- usb_buf[0x10 ] = ZET_EDGE_AIR_PRO_PACKET_END ;
134+ usb_buf[0x10 ] = ARESON_PACKET_END ;
123135
124136 /* ---------------------------------------------------------*\
125137 | Send the report |
126138 \*---------------------------------------------------------*/
127- hid_send_feature_report (dev, usb_buf, ZET_EDGE_AIR_PRO_PACKET_SIZE );
139+ hid_send_feature_report (dev, usb_buf, ARESON_PACKET_SIZE );
128140}
0 commit comments