revert to hidraw leds setting
This commit is contained in:
parent
6873e50f00
commit
57ca777219
1 changed files with 85 additions and 13 deletions
96
rog_ally.c
96
rog_ally.c
|
|
@ -1230,6 +1230,84 @@ static input_dev_t in_xbox_dev = {
|
|||
}
|
||||
};
|
||||
|
||||
static int rc71l_hidraw_map(const dev_in_settings_t *const conf, int hidraw_fd, in_message_t *const messages, size_t messages_len, void* user_data) {
|
||||
uint8_t data[256];
|
||||
const int read_res = read(hidraw_fd, data, sizeof(data));
|
||||
|
||||
if (read_res < 0) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
//printf("Got %d bytes from Asus MCU\n", read_res); // either 6 or 32
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rc71l_hidraw_rumble(const dev_in_settings_t *const conf, int hidraw_fd, uint8_t left_motor, uint8_t right_motor, void* user_data) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rc71l_hidraw_set_leds(const dev_in_settings_t *const conf, int hidraw_fd, uint8_t r, uint8_t g, uint8_t b, void* user_data) {
|
||||
const uint8_t brightness_buf[] = {
|
||||
0x5A, 0xBA, 0xC5, 0xC4, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const uint8_t colors_buf[] = {
|
||||
0x5A, 0xB3, 0x00, ROG_ALLY_MODE_STATIC, r, g, b, 0x00, ROG_ALLY_DIRECTION_RIGHT, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
if (write(hidraw_fd, brightness_buf, sizeof(brightness_buf)) != 64) {
|
||||
fprintf(stderr, "Unable to send LEDs brightness (1) command change: %d\n", errno);
|
||||
goto rc71l_hidraw_set_leds_err;
|
||||
}
|
||||
|
||||
if (write(hidraw_fd, colors_buf, sizeof(colors_buf)) != 64) {
|
||||
fprintf(stderr, "Unable to send LEDs color command change (1)\n");
|
||||
goto rc71l_hidraw_set_leds_err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
rc71l_hidraw_set_leds_err:
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static void rc71l_hidraw_timer(
|
||||
const dev_in_settings_t *const conf,
|
||||
int fd,
|
||||
const char* const timer_name,
|
||||
uint64_t expired,
|
||||
void* user_data
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
static input_dev_t nkey_dev = {
|
||||
.dev_type = input_dev_type_hidraw,
|
||||
.filters = {
|
||||
.hidraw = {
|
||||
.pid = 0x1abe,
|
||||
.vid = 0x0b05,
|
||||
.rdesc_size = 167, // 48 83 167
|
||||
}
|
||||
},
|
||||
.user_data = NULL,
|
||||
.map = {
|
||||
.hidraw_callbacks = {
|
||||
.leds_callback = rc71l_hidraw_set_leds,
|
||||
.rumble_callback = rc71l_hidraw_rumble,
|
||||
.map_callback = rc71l_hidraw_map,
|
||||
.timeout_callback = rc71l_hidraw_timer,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static int rc71l_platform_init(const dev_in_settings_t *const conf, void** platform_data) {
|
||||
int res = -EINVAL;
|
||||
|
||||
|
|
@ -1268,18 +1346,8 @@ static void rc71l_platform_deinit(const dev_in_settings_t *const conf, void** pl
|
|||
static int rc71l_platform_leds(const dev_in_settings_t *const conf, uint8_t r, uint8_t g, uint8_t b, void* platform_data) {
|
||||
rc71l_platform_t *const platform = (rc71l_platform_t*)platform_data;
|
||||
|
||||
if (platform_data == NULL) {
|
||||
// hidraw is used for now
|
||||
return 0;
|
||||
}
|
||||
|
||||
platform->static_led_color.r = r;
|
||||
platform->static_led_color.g = g;
|
||||
platform->static_led_color.b = b;
|
||||
|
||||
char command_str[64] = "\0";
|
||||
sprintf(command_str, "asusctl led-mode static -c %02X%02X%02X", r ,g ,b);
|
||||
|
||||
return system(command_str);
|
||||
}
|
||||
|
||||
int rc71l_timer_map(const dev_in_settings_t *const conf, int timer_fd, uint64_t expirations, in_message_t *const messages, size_t messages_len, void* user_data) {
|
||||
|
|
@ -1290,6 +1358,9 @@ int rc71l_timer_map(const dev_in_settings_t *const conf, int timer_fd, uint64_t
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1316,10 +1387,11 @@ input_dev_composite_t rc71l_composite = {
|
|||
&in_asus_kb_1_dev,
|
||||
&in_asus_kb_2_dev,
|
||||
&in_asus_kb_3_dev,
|
||||
&nkey_dev,
|
||||
&timer_dev,
|
||||
&in_touchscreen_dev,
|
||||
},
|
||||
.dev_count = 7,
|
||||
.dev_count = 8,
|
||||
.init_fn = rc71l_platform_init,
|
||||
.deinit_fn = rc71l_platform_deinit,
|
||||
.leds_fn = rc71l_platform_leds,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue