/** * Write device file "mode_breath" */ static ssize_t razer_attr_write_mode_breath(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev->parent); struct usb_device *usb_dev = interface_to_usbdev(intf); const char *alt_buf[6] = { 0 }; if(count == 3) { // Single colour mode razer_set_breath_mode(usb_dev, 0x01, (struct razer_rgb*)&buf[0], (struct razer_rgb*)&alt_buf[3]); } else if(count == 6) { // Dual colour mode razer_set_breath_mode(usb_dev, 0x02, (struct razer_rgb*)&buf[0], (struct razer_rgb*)&buf[3]); } else { // "Random" colour mode razer_set_breath_mode(usb_dev, 0x03, (struct razer_rgb*)&alt_buf[0], (struct razer_rgb*)&alt_buf[3]); } return count; }
static ssize_t razer_attr_write_mode_breath(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev->parent); //struct razer_kbd_device *widow = usb_get_intfdata(intf); struct usb_device *usb_dev = interface_to_usbdev(intf); unsigned char num_cols; if(count) num_cols = (unsigned char)buf[0]; if(count==((num_cols*3)+1)) { razer_set_breath_mode(usb_dev,(struct razer_rgb*)&buf[1],num_cols); } return count; }
static ssize_t razer_attr_write_mode_breath(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_interface *intf = to_usb_interface(dev->parent); //struct razer_kbd_device *widow = usb_get_intfdata(intf); struct usb_device *usb_dev = interface_to_usbdev(intf); struct razer_rgb first_color,second_color; if(count==6) { first_color.r = buf[0]; first_color.g = buf[1]; first_color.b = buf[2]; second_color.r = buf[3]; second_color.g = buf[4]; second_color.b = buf[5]; razer_set_breath_mode(usb_dev,&first_color,&second_color); } return count; }