Created
October 21, 2023 15:42
-
-
Save bluemner/5728f5fca4b5b580262db958c27055aa to your computer and use it in GitHub Desktop.
Sample Logic for Linux to print out hid section of G600 Mouse.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <errno.h> | |
#include <fcntl.h> | |
#include <poll.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <sys/ioctl.h> | |
#include <stdbool.h> | |
#include <libudev.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <linux/hidraw.h> | |
#include <linux/types.h> | |
#include <linux/input.h> | |
#include <unistd.h> | |
#define LOGITECH_G600_CURRENT_STATE 0xE0 | |
#define LOGITECH_G600_REPORT_ID_ACTIVE_PROFILE 0xF0 | |
#define LOGITECH_G600_REPORT_ID_ACTIVE_LED 0xF1 | |
#define LOGITECH_G600_REPORT_ID_ACTIVE_DPI 0xF2 | |
#define LOGITECH_G600_REPORT_ID_PROFILE_0 0xF3 | |
#define LOGITECH_G600_REPORT_ID_PROFILE_1 0xF4 | |
#define LOGITECH_G600_REPORT_ID_PROFILE_2 0xF5 | |
#define LOGITECH_G600_LED_SOLID 0x00 | |
#define LOGITECH_G600_LED_BREATHE 0x01 | |
#define LOGITECH_G600_LED_CYCLE 0x02 | |
// u_int32_t LOGITECH_G600_BUTTON_CLEAR = 0x00 << 0 | 0x00 << 8 | 0x00 << 16 | 0x00 << 24 ; // clear | |
// u_int32_t LOGITECH_G600_BUTTON_LEFT_MOUSE_CLICK = 0x01 << 0 | 0x00 << 8 | 0x00 << 16 | 0x00 << 24 ; // left mouse click | |
// u_int32_t LOGITECH_G600_BUTTON_RIGHT_MOUSE_CLICK = 0x02 << 0 | 0x00 << 8 | 0x00 << 16 | 0x00 << 24 ; // right mouse click | |
// u_int32_t LOGITECH_G600_BUTTON_MIDDLE_MOUSE_CLICK = 0x04 << 0 | 0x00 << 8 | 0x00 << 16 | 0x00 << 24 ; // middle mouse click | |
// u_int32_t LOGITECH_G600_BUTTON_LEFT_SCROLL_CLICK = 0x08 << 0 | 0x00 << 8 | 0x00 << 16 | 0x00 << 24 ; // left scroll click | |
// u_int32_t LOGITECH_G600_BUTTON_RIGHT_SCROLL_CLICK = 0x10 << 0 | 0x00 << 8 | 0x00 << 16 | 0x00 << 24 ; // right scroll click | |
// u_int32_t LOGITECH_G600_BUTTON_RIGHT_PINKY = 0x20 << 0 | 0x00 << 8 | 0x00 << 16 | 0x00 << 24 ; // right pinky | |
// u_int32_t LOGITECH_G600_BUTTON_G07 = 0x40 << 0 | 0x00 << 8 | 0x00 << 16 | 0x00 << 24 ; // G07 | |
// u_int32_t LOGITECH_G600_BUTTON_G08 = 0x80 << 0 | 0x00 << 8 | 0x00 << 16 | 0x00 << 24 ; // G08 | |
// u_int32_t LOGITECH_G600_BUTTON_G09 = 0x00 << 0 | 0x01 << 8 | 0x00 << 16 | 0x00 << 24 ; // G09 | |
// u_int32_t LOGITECH_G600_BUTTON_G10 = 0x00 << 0 | 0x02 << 8 | 0x00 << 16 | 0x00 << 24 ; // G10 | |
// u_int32_t LOGITECH_G600_BUTTON_G11 = 0x00 << 0 | 0x04 << 8 | 0x00 << 16 | 0x00 << 24 ; // G11 | |
// u_int32_t LOGITECH_G600_BUTTON_G12 = 0x00 << 0 | 0x08 << 8 | 0x00 << 16 | 0x00 << 24 ; // G12 | |
// u_int32_t LOGITECH_G600_BUTTON_G13 = 0x00 << 0 | 0x10 << 8 | 0x00 << 16 | 0x00 << 24 ; // G13 | |
// u_int32_t LOGITECH_G600_BUTTON_G14 = 0x00 << 0 | 0x20 << 8 | 0x00 << 16 | 0x00 << 24 ; // G14 | |
// u_int32_t LOGITECH_G600_BUTTON_G15 = 0x00 << 0 | 0x40 << 8 | 0x00 << 16 | 0x00 << 24 ; // G15 | |
// u_int32_t LOGITECH_G600_BUTTON_G16 = 0x00 << 0 | 0x80 << 8 | 0x00 << 16 | 0x00 << 24 ; // G16 | |
// u_int32_t LOGITECH_G600_BUTTON_G17 = 0x00 << 0 | 0x00 << 8 | 0x01 << 16 | 0x00 << 24 ; // G17 | |
// u_int32_t LOGITECH_G600_BUTTON_G18 = 0x00 << 0 | 0x00 << 8 | 0x02 << 16 | 0x00 << 24 ; // G18 | |
// u_int32_t LOGITECH_G600_BUTTON_G19 = 0x00 << 0 | 0x00 << 8 | 0x04 << 16 | 0x00 << 24 ; // G19 | |
// u_int32_t LOGITECH_G600_BUTTON_G20 = 0x00 << 0 | 0x00 << 8 | 0x08 << 16 | 0x00 << 24 ; // G20 | |
uint32_t LOGITECH_G600_BUTTON_CLEAR = 0x00 ; // clear | |
uint32_t LOGITECH_G600_BUTTON_LEFT_MOUSE_CLICK = 0x01; // left mouse click | |
uint32_t LOGITECH_G600_BUTTON_RIGHT_MOUSE_CLICK = 0x02; // right mouse click | |
uint32_t LOGITECH_G600_BUTTON_MIDDLE_MOUSE_CLICK = 0x04 ; // middle mouse click | |
uint32_t LOGITECH_G600_BUTTON_LEFT_SCROLL_CLICK = 0x08 ; // left scroll click | |
uint32_t LOGITECH_G600_BUTTON_RIGHT_SCROLL_CLICK = 0x10 ; // right scroll click | |
uint32_t LOGITECH_G600_BUTTON_RIGHT_PINKY = 0x20; // right pinky | |
uint32_t LOGITECH_G600_BUTTON_G07 = 0x40; // G07 | |
uint32_t LOGITECH_G600_BUTTON_G08 = 0x80; // G08 | |
uint32_t LOGITECH_G600_BUTTON_G09 = 0x100; // G09 | |
uint32_t LOGITECH_G600_BUTTON_G10 = 0x200 ; // G10 | |
uint32_t LOGITECH_G600_BUTTON_G11 = 0x400 ; // G11 | |
uint32_t LOGITECH_G600_BUTTON_G12 = 0x800 ; // G12 | |
uint32_t LOGITECH_G600_BUTTON_G13 = 0x1000 ; // G13 | |
uint32_t LOGITECH_G600_BUTTON_G14 = 0x2000 ; // G14 | |
uint32_t LOGITECH_G600_BUTTON_G15 = 0x4000; // G15 | |
uint32_t LOGITECH_G600_BUTTON_G16 = 0x8000; // G16 | |
uint32_t LOGITECH_G600_BUTTON_G17 = 0x1000; // G17 | |
uint32_t LOGITECH_G600_BUTTON_G18 = 0x2000 ; // G18 | |
uint32_t LOGITECH_G600_BUTTON_G19 = 0x4000 ; // G19 | |
uint32_t LOGITECH_G600_BUTTON_G20 = 0x8000 ; // G20 | |
void print_buffer(uint8_t *buf, size_t len, uint8_t reg, int result){ | |
int i; | |
printf("buffer result 0x%02hx %d\n\t", reg, result ); | |
for(i=0; i< len; i++) | |
printf("0x%02X ", buf[i]); | |
puts("\n"); | |
} | |
/** | |
* read device feature information | |
* @param [out] fd | |
* @param [in] len | |
* @param [out] buf | |
* @param [in] reportnum | |
**/ | |
int read_device_feature(int fd, const size_t len, uint8_t *buf, const unsigned char reportnum ){ | |
uint8_t tmp_buf[4096]; | |
int result; | |
memset(tmp_buf, 0, len); | |
tmp_buf[0] = reportnum; | |
result = ioctl(fd, HIDIOCGFEATURE(len), tmp_buf); | |
if (result < 0) | |
return -errno; | |
memcpy(buf, tmp_buf, result); | |
return result; | |
} | |
int read_device_input(int fd, const size_t len, uint8_t *buf, const unsigned char reportnum ){ | |
uint8_t tmp_buf[4096]; | |
int result; | |
memset(tmp_buf, 0, len); | |
tmp_buf[0] = reportnum; | |
result = ioctl(fd, HIDIOCGINPUT(len), tmp_buf); | |
if (result < 0) | |
return -errno; | |
memcpy(buf, tmp_buf, result); | |
return result; | |
} | |
/** | |
* read device feature information | |
* @param [out] fd | |
* @param [in] len | |
* @param [out] buf | |
* @param [in] reportnum | |
**/ | |
int read_device(int fd, const size_t len, uint8_t *buf, const unsigned char reportnum ){ | |
uint8_t tmp_buf[4096]; | |
int result; | |
memset(tmp_buf, 0, len); | |
tmp_buf[0] = reportnum; | |
result = read(fd,tmp_buf,sizeof(tmp_buf)); | |
if (result < 0) | |
return -errno; | |
memcpy(buf, tmp_buf, result); | |
return result; | |
} | |
int open_device( const char* path, int flags){ | |
return open(path,flags); | |
} | |
struct logitech_g600_profile_active_led{ // Active LED? | |
uint8_t id; // 241 ; 241 ; 241 ; | |
uint8_t led_red; // 255 ; 000 ; 000 ; // RED | |
uint8_t led_green; // 255 ; 000 ; 255 ; // Green | |
uint8_t led_blue; // 000 ; 255 ; 000 ; // Blue | |
uint8_t led_effect; // 000 ; 000 ; 000 ; | |
uint8_t led_duration; // 004 ; 004 ; 004 ; | |
uint8_t reserved1; // 000 ; 000 ; 000 ; | |
uint8_t reserved2; // 000 ; 000 ; 000 ; | |
} __attribute__((packed)); | |
struct logitech_g600_profile_dpi{ // Active DPI? | |
uint8_t id; // 242 ; 242 ; 242 | |
uint8_t item2; // 000 ; 000 ; 000 ; | |
uint8_t frequency:4; // 000 ; 000 ; 000 ; | |
uint8_t unknown1:4; // 000 ; 000 ; 000 ; | |
uint8_t dpi; // 103 ; 064 ; 016 ; // | |
uint8_t item5; // 000 ; 000 ; 000 ; | |
} __attribute__((packed)); | |
struct logitech_g600_button { | |
uint8_t code; | |
uint8_t modifier; | |
uint8_t key; | |
} __attribute__((packed)); | |
struct logitech_g600_profile_report { | |
uint8_t id; | |
uint8_t led_red; | |
uint8_t led_green; | |
uint8_t led_blue; | |
uint8_t led_effect; | |
uint8_t led_duration; | |
uint8_t unknown1[5]; | |
uint8_t frequency; /* frequency = 1000 / (value + 1) */ | |
uint8_t dpi_shift; /* value is a linear range between 200->0x04, 8200->0xa4, so value * 50, 0x00 is disabled */ | |
uint8_t dpi_default; /* between 1 and 4*/ | |
uint8_t dpi[4]; /* value is a linear range between 200->0x04, 8200->0xa4, so value * 50, 0x00 is disabled */ | |
uint8_t unknown2[4]; | |
uint8_t unknown3[4]; | |
uint8_t unknown5[5]; | |
struct logitech_g600_button buttons[20]; | |
uint8_t g_shift_color[3]; /* can't assign it in LGS, but the 3rd profile has one that shows the feature :) */ | |
struct logitech_g600_button g_shift_buttons[20]; | |
} __attribute__((packed)); | |
struct logitech_g600_active_profile_report { | |
uint8_t id; | |
uint8_t unknown1 :1; // 0; 0; 0; | |
uint8_t resolution :2; // 2; 0; 0; | |
uint8_t enabled :1; // 1; 1; 1; | |
uint8_t profile :4; // 0; 1; 2; | |
uint8_t unknown3; // 0; 0; 0; | |
uint8_t unknown4; // 0; 0; 0; | |
} __attribute__((packed)); | |
struct logitech_g600_active_state { | |
uint8_t type; | |
uint32_t button; | |
uint8_t profile; | |
uint8_t unknown2; | |
uint8_t unknown3; | |
} __attribute__((packed)); | |
void print_logitech_state(const struct logitech_g600_active_state *state){ | |
uint32_t button = state->button; //(state->button[3]<<24) | (state->button[2]<<16) | (state->button[1]<<8) | (state->button[0]); | |
if ( button == LOGITECH_G600_BUTTON_CLEAR) { | |
printf("Pressed: LOGITECH_G600_BUTTON_CLEAR\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_LEFT_MOUSE_CLICK) == LOGITECH_G600_BUTTON_LEFT_MOUSE_CLICK) { | |
printf("Pressed: LOGITECH_G600_BUTTON_LEFT_MOUSE_CLICK\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_RIGHT_MOUSE_CLICK) == LOGITECH_G600_BUTTON_RIGHT_MOUSE_CLICK) { | |
printf("Pressed: LOGITECH_G600_BUTTON_RIGHT_MOUSE_CLICK\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_MIDDLE_MOUSE_CLICK) == LOGITECH_G600_BUTTON_MIDDLE_MOUSE_CLICK) { | |
printf("Pressed: LOGITECH_G600_BUTTON_MIDDLE_MOUSE_CLICK\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_LEFT_SCROLL_CLICK) == LOGITECH_G600_BUTTON_LEFT_SCROLL_CLICK) { | |
printf("Pressed: LOGITECH_G600_BUTTON_LEFT_SCROLL_CLICK\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_RIGHT_SCROLL_CLICK) == LOGITECH_G600_BUTTON_RIGHT_SCROLL_CLICK) { | |
printf("Pressed: LOGITECH_G600_BUTTON_RIGHT_SCROLL_CLICK\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_RIGHT_PINKY) == LOGITECH_G600_BUTTON_RIGHT_PINKY) { | |
printf("Pressed: LOGITECH_G600_BUTTON_RIGHT_PINKY\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_G07) == LOGITECH_G600_BUTTON_G07) { | |
printf("Pressed: LOGITECH_G600_BUTTON_G07\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_G08) == LOGITECH_G600_BUTTON_G08) { | |
printf("Pressed: LOGITECH_G600_BUTTON_G08\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_G09) == LOGITECH_G600_BUTTON_G09) { | |
printf("Pressed: LOGITECH_G600_BUTTON_G09\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_G10) == LOGITECH_G600_BUTTON_G10) { | |
printf("Pressed: LOGITECH_G600_BUTTON_G10\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_G11) == LOGITECH_G600_BUTTON_G11) { | |
printf("Pressed: LOGITECH_G600_BUTTON_G11\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_G12) == LOGITECH_G600_BUTTON_G12) { | |
printf("Pressed: LOGITECH_G600_BUTTON_G12\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_G13) == LOGITECH_G600_BUTTON_G13) { | |
printf("Pressed: LOGITECH_G600_BUTTON_G13\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_G14) == LOGITECH_G600_BUTTON_G14) { | |
printf("Pressed: LOGITECH_G600_BUTTON_G14\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_G15) == LOGITECH_G600_BUTTON_G15) { | |
printf("Pressed: LOGITECH_G600_BUTTON_G15\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_G16) == LOGITECH_G600_BUTTON_G16) { | |
printf("Pressed: LOGITECH_G600_BUTTON_G16\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_G17) == LOGITECH_G600_BUTTON_G17) { | |
printf("Pressed: LOGITECH_G600_BUTTON_G17\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_G18) == LOGITECH_G600_BUTTON_G18) { | |
printf("Pressed: LOGITECH_G600_BUTTON_G18\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_G19) == LOGITECH_G600_BUTTON_G19) { | |
printf("Pressed: LOGITECH_G600_BUTTON_G19\n"); | |
} | |
if ( (button & LOGITECH_G600_BUTTON_G20) == LOGITECH_G600_BUTTON_G20) { | |
printf("Pressed: LOGITECH_G600_BUTTON_G20\n"); | |
} | |
} | |
struct test_buttons { | |
struct logitech_g600_button buttons[40]; | |
} __attribute__((packed)); | |
struct temp | |
{ | |
uint8_t report_id; | |
uint8_t data[30]; | |
} __attribute__((packed)); | |
const char* bustype_string(int bustype){ | |
switch (bustype) | |
{ | |
case BUS_USB: | |
return "USB"; | |
case BUS_PCI: | |
return "PCI"; | |
case BUS_BLUETOOTH: | |
return "Bluetooth"; | |
case BUS_VIRTUAL: | |
return "Virtual"; | |
default: | |
return "Other"; | |
} | |
} | |
// cat /sys/class/hidraw/hidraw5/device/uevent | |
// /dev/hidraw5 | |
int main(int argc, char** argv){ | |
const char* path = "/dev/hidraw9"; // TODO: CHANGE ME | |
int fd = open(path, O_RDONLY, 0); | |
int result, i, j, size =0; | |
if (fd < 0){ | |
printf("error"); | |
return -1; | |
} | |
struct hidraw_report_descriptor descriptor; | |
struct hidraw_devinfo info; | |
memset(&descriptor, 0x0, sizeof(descriptor)); | |
memset(&descriptor, 0x0, sizeof(descriptor)); | |
result = ioctl(fd, HIDIOCGRDESCSIZE, &size); | |
descriptor.size = size; | |
result = ioctl(fd, HIDIOCGRDESC, &descriptor); | |
if (result < 0) { | |
printf("descriptor %d\n", result ); | |
} else { | |
printf("Report Descriptor:\n"); | |
for (i = 0; i < descriptor.size; i++) | |
printf("%02hhx ", descriptor.value[i] ); | |
puts("\n"); | |
printf("Please go to http://eleccelerator.com/usbdescreqparser/ to view report \n"); | |
} | |
result = ioctl(fd, HIDIOCGRAWINFO, &info); | |
if (result < 0) { | |
printf("descriptor %d\n", result ); | |
}else{ | |
printf("Raw Info:\n"); | |
printf("\tbustype: %d - %s\n", info.bustype, bustype_string(info.bustype)); | |
printf("\tvendor: 0x%04hx\n", info.vendor); | |
printf("\tproduct: 0x%04hx\n", info.product); | |
} | |
struct logitech_g600_active_profile_report active_profile; | |
result = read_device_feature(fd, sizeof(active_profile), (uint8_t*)&active_profile, LOGITECH_G600_REPORT_ID_ACTIVE_PROFILE); | |
printf("id 0x%02hx result %d\n", LOGITECH_G600_REPORT_ID_ACTIVE_PROFILE, result ); | |
//print_buffer((uint8_t*) &buf,sizeof(buf) ); | |
printf("id %u\n", active_profile.id ); | |
printf("id %u\n", active_profile.profile ); | |
struct logitech_g600_profile_report profile0; | |
result = read_device_feature(fd, sizeof(profile0), (uint8_t*)&profile0, LOGITECH_G600_REPORT_ID_PROFILE_0); | |
printf("id 0x%02hx result %d\n", LOGITECH_G600_REPORT_ID_PROFILE_0, result ); | |
printf("profile id %u\n", profile0.id ); | |
struct logitech_g600_profile_report profile1; | |
result = read_device_feature(fd, sizeof(profile1), (uint8_t*)&profile1, LOGITECH_G600_REPORT_ID_PROFILE_1); | |
printf("id 0x%02hx result %d\n", LOGITECH_G600_REPORT_ID_PROFILE_1, result ); | |
struct logitech_g600_profile_report profile2; | |
result = read_device_feature(fd, sizeof(profile2), (uint8_t*)&profile2, LOGITECH_G600_REPORT_ID_PROFILE_2); | |
printf("id 0x%02hx result %d\n", LOGITECH_G600_REPORT_ID_PROFILE_2, result ); | |
struct logitech_g600_profile_active_led led; | |
result = read_device_feature(fd, sizeof(led),(uint8_t*)&led, LOGITECH_G600_REPORT_ID_ACTIVE_LED); | |
printf("unknown1 0x%02hx result %d\n", LOGITECH_G600_REPORT_ID_ACTIVE_LED, result ); | |
struct logitech_g600_profile_dpi unknown2 ; | |
result = read_device_feature(fd, sizeof(unknown2 ),(uint8_t*)&unknown2 , LOGITECH_G600_REPORT_ID_ACTIVE_DPI); | |
printf("unknown2 0x%02hx result %d\n", LOGITECH_G600_REPORT_ID_ACTIVE_DPI, result ); | |
//struct test_buttons buttons; | |
//struct temp buffer; | |
// result = read_device_input(fd, sizeof(buffer), (uint8_t*)&buffer, 0xF7); | |
//read(fd, buffer, len(buffer) ); | |
//memset(buffer, 0, sizeof(buffer)); | |
uint8_t buffer[7]; | |
memset(buffer, 0, sizeof(buffer)); | |
buffer[0] = 0x01; | |
result = ioctl(fd,HIDIOCGINPUT(sizeof(buffer)), buffer); | |
printf("buffer result %d\n", result ); | |
uint8_t buffer2[7]; | |
for (i =0x01; i< 0xFF; ++i){ | |
memset(buffer2, 0, sizeof(buffer2)); | |
buffer2[0] = i; | |
result = ioctl(fd,HIDIOCGINPUT(sizeof(buffer2)), buffer2); | |
if (result <0) | |
continue; | |
printf("buffer result 0x%02hx %d\n", i, result ); | |
for(j = 0; j < result; j++){ | |
printf("\t%d\n", buffer[j] ); | |
} | |
} | |
uint8_t buffer3[8]; | |
memset(buffer3, 0, sizeof(buffer3)); | |
buffer3[0] = 0x80; | |
result = ioctl(fd,HIDIOCGRAWUNIQ(sizeof(buffer3)), buffer3); | |
print_buffer(buffer3, sizeof(buffer3), 0x80, result); | |
uint8_t buffer4[31]; | |
memset(buffer4, 0, sizeof(buffer4)); | |
buffer4[0] = 0xF7; | |
result = ioctl(fd,HIDIOCGRAWUNIQ(sizeof(buffer4)), buffer4); | |
print_buffer(buffer4, sizeof(buffer4), 0xF7, result); | |
// i=0; | |
// do{ | |
// memset(buffer4, 0, sizeof(buffer4)); | |
// buffer4[0] = 0xF7; | |
// result = read(fd,buffer4,sizeof(buffer4)); | |
// print_buffer(buffer4, sizeof(buffer4), 0xF7, result); | |
// ++i; | |
// }while(i < 6); | |
uint8_t buffer5[8]; | |
memset(buffer5, 0, sizeof(buffer5)); | |
buffer5[0] = 0xF6; | |
result = ioctl(fd,HIDIOCGFEATURE(sizeof(buffer5)), buffer5); | |
print_buffer(buffer5, sizeof(buffer5), 0xF6, result); | |
// i=0; | |
// do{ | |
// uint8_t fullbuffer[8]; | |
// memset(fullbuffer, 0, sizeof(fullbuffer)); | |
// buffer5[0] = 0xF6; | |
// result = read(fd,fullbuffer,sizeof(fullbuffer)); | |
// print_buffer(fullbuffer, sizeof(fullbuffer), 0xF6, result); | |
// ++i; | |
// }while(i < 6); | |
// i=0; | |
// do{ | |
// uint8_t EO_BUFFER[8]; | |
// | |
// uint8_t BUFFER = 0xE0; | |
// memset(EO_BUFFER, 0, sizeof(EO_BUFFER)); | |
// buffer5[0] = BUFFER; | |
// result = read(fd,EO_BUFFER,sizeof(EO_BUFFER)); | |
// | |
// if (result == 7){ | |
// continue; | |
// //print_buffer(EO_BUFFER, sizeof(EO_BUFFER), BUFFER, result); | |
// printf("buffer result 0x%02hx %d\n", BUFFER, result ); | |
// printf("\tType 0x%02X\n", EO_BUFFER[0]); | |
// printf("\ttModifer 0x%02X\n", EO_BUFFER[1]); | |
// printf("\tButton 0x%02X 0x%02X\n", EO_BUFFER[3] , EO_BUFFER[2]); | |
// printf("\t?????? 0x%02X\n", EO_BUFFER[4]); | |
// printf("\tProfile 0x%02X\n", EO_BUFFER[5]); | |
// printf("\t?????? 0x%02X\n", EO_BUFFER[6]); | |
// printf("\t?????? 0x%02X\n", EO_BUFFER[7]); | |
// } | |
// if (result == 6){ | |
// //print_buffer(EO_BUFFER, sizeof(EO_BUFFER), BUFFER, result); | |
// printf("buffer result 0x%02hx %d\n", BUFFER, result ); | |
// printf("\tType 0x%02X\n", EO_BUFFER[0]); | |
// printf("\ttModifer 0x%02X\n", EO_BUFFER[1]); | |
// printf("\tButton 0x%02X 0x%02X\n", EO_BUFFER[3] , EO_BUFFER[2]); | |
// printf("\t?????? 0x%02X\n", EO_BUFFER[4]); | |
// printf("\tProfile 0x%02X\n", EO_BUFFER[5]); | |
// printf("\t?????? 0x%02X\n", EO_BUFFER[6]); | |
// printf("\t?????? 0x%02X\n", EO_BUFFER[7]); | |
// } | |
// printf("0x%02X ", EO_BUFFER[0]); | |
// printf("0x%02X ", EO_BUFFER[0]); | |
// printf("0x%02X ", EO_BUFFER[0]); | |
// printf("0x%02X ", EO_BUFFER[0]); | |
// puts("\n"); | |
// // | |
// ++i; | |
// }while(true); | |
do { | |
struct logitech_g600_active_state current_state; | |
result = read_device(fd, sizeof(current_state), (uint8_t*)¤t_state, LOGITECH_G600_CURRENT_STATE); | |
if (result == 6){ | |
print_logitech_state(¤t_state); | |
//printf("Button #: %d", button); | |
//printf("buffer result 0x%02hx %d\n", EO_BUFFER, result ); | |
printf("\tType 0x%02X\n", current_state.type); | |
//printf("\tButtons 0x%02X 0x%02X 0x%02X\n", current_state.button[0], current_state.button[1] ,current_state.button[2]); | |
printf("\tButtons: 0x%02X\n", current_state.button); | |
// printf("\tunknown1 0x%02X\n", current_state.unknown1); | |
printf("\tProfile 0x%02X\n", current_state.profile); | |
printf("\tunknown2 0x%02X\n", current_state.unknown2); | |
printf("\tunknown3 0x%02X\n", current_state.unknown3); | |
puts("\n"); | |
} | |
}while (true); | |
close(fd); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
make command