Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 #ifndef __HID_ROCCAT_KONE_H
0003 #define __HID_ROCCAT_KONE_H
0004 
0005 /*
0006  * Copyright (c) 2010 Stefan Achatz <erazor_de@users.sourceforge.net>
0007  */
0008 
0009 /*
0010  */
0011 
0012 #include <linux/types.h>
0013 
0014 struct kone_keystroke {
0015     uint8_t key;
0016     uint8_t action;
0017     uint16_t period; /* in milliseconds */
0018 } __attribute__ ((__packed__));
0019 
0020 enum kone_keystroke_buttons {
0021     kone_keystroke_button_1 = 0xf0, /* left mouse button */
0022     kone_keystroke_button_2 = 0xf1, /* right mouse button */
0023     kone_keystroke_button_3 = 0xf2, /* wheel */
0024     kone_keystroke_button_9 = 0xf3, /* side button up */
0025     kone_keystroke_button_8 = 0xf4 /* side button down */
0026 };
0027 
0028 enum kone_keystroke_actions {
0029     kone_keystroke_action_press = 0,
0030     kone_keystroke_action_release = 1
0031 };
0032 
0033 struct kone_button_info {
0034     uint8_t number; /* range 1-8 */
0035     uint8_t type;
0036     uint8_t macro_type; /* 0 = short, 1 = overlong */
0037     uint8_t macro_set_name[16]; /* can be max 15 chars long */
0038     uint8_t macro_name[16]; /* can be max 15 chars long */
0039     uint8_t count;
0040     struct kone_keystroke keystrokes[20];
0041 } __attribute__ ((__packed__));
0042 
0043 enum kone_button_info_types {
0044     /* valid button types until firmware 1.32 */
0045     kone_button_info_type_button_1 = 0x1, /* click (left mouse button) */
0046     kone_button_info_type_button_2 = 0x2, /* menu (right mouse button)*/
0047     kone_button_info_type_button_3 = 0x3, /* scroll (wheel) */
0048     kone_button_info_type_double_click = 0x4,
0049     kone_button_info_type_key = 0x5,
0050     kone_button_info_type_macro = 0x6,
0051     kone_button_info_type_off = 0x7,
0052     /* TODO clarify function and rename */
0053     kone_button_info_type_osd_xy_prescaling = 0x8,
0054     kone_button_info_type_osd_dpi = 0x9,
0055     kone_button_info_type_osd_profile = 0xa,
0056     kone_button_info_type_button_9 = 0xb, /* ie forward */
0057     kone_button_info_type_button_8 = 0xc, /* ie backward */
0058     kone_button_info_type_dpi_up = 0xd, /* internal */
0059     kone_button_info_type_dpi_down = 0xe, /* internal */
0060     kone_button_info_type_button_7 = 0xf, /* tilt left */
0061     kone_button_info_type_button_6 = 0x10, /* tilt right */
0062     kone_button_info_type_profile_up = 0x11, /* internal */
0063     kone_button_info_type_profile_down = 0x12, /* internal */
0064     /* additional valid button types since firmware 1.38 */
0065     kone_button_info_type_multimedia_open_player = 0x20,
0066     kone_button_info_type_multimedia_next_track = 0x21,
0067     kone_button_info_type_multimedia_prev_track = 0x22,
0068     kone_button_info_type_multimedia_play_pause = 0x23,
0069     kone_button_info_type_multimedia_stop = 0x24,
0070     kone_button_info_type_multimedia_mute = 0x25,
0071     kone_button_info_type_multimedia_volume_up = 0x26,
0072     kone_button_info_type_multimedia_volume_down = 0x27
0073 };
0074 
0075 enum kone_button_info_numbers {
0076     kone_button_top = 1,
0077     kone_button_wheel_tilt_left = 2,
0078     kone_button_wheel_tilt_right = 3,
0079     kone_button_forward = 4,
0080     kone_button_backward = 5,
0081     kone_button_middle = 6,
0082     kone_button_plus = 7,
0083     kone_button_minus = 8,
0084 };
0085 
0086 struct kone_light_info {
0087     uint8_t number; /* number of light 1-5 */
0088     uint8_t mod;   /* 1 = on, 2 = off */
0089     uint8_t red;   /* range 0x00-0xff */
0090     uint8_t green; /* range 0x00-0xff */
0091     uint8_t blue;  /* range 0x00-0xff */
0092 } __attribute__ ((__packed__));
0093 
0094 struct kone_profile {
0095     uint16_t size; /* always 975 */
0096     uint16_t unused; /* always 0 */
0097 
0098     /*
0099      * range 1-5
0100      * This number does not need to correspond with location where profile
0101      * saved
0102      */
0103     uint8_t profile; /* range 1-5 */
0104 
0105     uint16_t main_sensitivity; /* range 100-1000 */
0106     uint8_t xy_sensitivity_enabled; /* 1 = on, 2 = off */
0107     uint16_t x_sensitivity; /* range 100-1000 */
0108     uint16_t y_sensitivity; /* range 100-1000 */
0109     uint8_t dpi_rate; /* bit 1 = 800, ... */
0110     uint8_t startup_dpi; /* range 1-6 */
0111     uint8_t polling_rate; /* 1 = 125Hz, 2 = 500Hz, 3 = 1000Hz */
0112     /* kone has no dcu
0113      * value is always 2 in firmwares <= 1.32 and
0114      * 1 in firmwares > 1.32
0115      */
0116     uint8_t dcu_flag;
0117     uint8_t light_effect_1; /* range 1-3 */
0118     uint8_t light_effect_2; /* range 1-5 */
0119     uint8_t light_effect_3; /* range 1-4 */
0120     uint8_t light_effect_speed; /* range 0-255 */
0121 
0122     struct kone_light_info light_infos[5];
0123     /* offset is kone_button_info_numbers - 1 */
0124     struct kone_button_info button_infos[8];
0125 
0126     uint16_t checksum; /* \brief holds checksum of struct */
0127 } __attribute__ ((__packed__));
0128 
0129 enum kone_polling_rates {
0130     kone_polling_rate_125 = 1,
0131     kone_polling_rate_500 = 2,
0132     kone_polling_rate_1000 = 3
0133 };
0134 
0135 struct kone_settings {
0136     uint16_t size; /* always 36 */
0137     uint8_t  startup_profile; /* 1-5 */
0138     uint8_t  unknown1;
0139     uint8_t  tcu; /* 0 = off, 1 = on */
0140     uint8_t  unknown2[23];
0141     uint8_t  calibration_data[4];
0142     uint8_t  unknown3[2];
0143     uint16_t checksum;
0144 } __attribute__ ((__packed__));
0145 
0146 /*
0147  * 12 byte mouse event read by interrupt_read
0148  */
0149 struct kone_mouse_event {
0150     uint8_t report_number; /* always 1 */
0151     uint8_t button;
0152     uint16_t x;
0153     uint16_t y;
0154     uint8_t wheel; /* up = 1, down = -1 */
0155     struct_group(wipe,
0156         uint8_t tilt; /* right = 1, left = -1 */
0157         uint8_t unknown;
0158         uint8_t event;
0159         uint8_t value; /* press = 0, release = 1 */
0160         uint8_t macro_key; /* 0 to 8 */
0161     );
0162 } __attribute__ ((__packed__));
0163 
0164 enum kone_mouse_events {
0165     /* osd events are thought to be display on screen */
0166     kone_mouse_event_osd_dpi = 0xa0,
0167     kone_mouse_event_osd_profile = 0xb0,
0168     /* TODO clarify meaning and occurence of kone_mouse_event_calibration */
0169     kone_mouse_event_calibration = 0xc0,
0170     kone_mouse_event_call_overlong_macro = 0xe0,
0171     kone_mouse_event_multimedia = 0xe1,
0172     /* switch events notify if user changed values with mousebutton click */
0173     kone_mouse_event_switch_dpi = 0xf0,
0174     kone_mouse_event_switch_profile = 0xf1
0175 };
0176 
0177 enum kone_commands {
0178     kone_command_profile = 0x5a,
0179     kone_command_settings = 0x15a,
0180     kone_command_firmware_version = 0x25a,
0181     kone_command_weight = 0x45a,
0182     kone_command_calibrate = 0x55a,
0183     kone_command_confirm_write = 0x65a,
0184     kone_command_firmware = 0xe5a
0185 };
0186 
0187 struct kone_roccat_report {
0188     uint8_t event;
0189     uint8_t value; /* holds dpi or profile value */
0190     uint8_t key; /* macro key on overlong macro execution */
0191 } __attribute__ ((__packed__));
0192 
0193 struct kone_device {
0194     /*
0195      * Storing actual values when we get informed about changes since there
0196      * is no way of getting this information from the device on demand
0197      */
0198     int actual_profile, actual_dpi;
0199     /* Used for neutralizing abnormal button behaviour */
0200     struct kone_mouse_event last_mouse_event;
0201 
0202     /*
0203      * It's unlikely that multiple sysfs attributes are accessed at a time,
0204      * so only one mutex is used to secure hardware access and profiles and
0205      * settings of this struct.
0206      */
0207     struct mutex kone_lock;
0208 
0209     /*
0210      * Storing the data here reduces IO and ensures that data is available
0211      * when its needed (E.g. interrupt handler).
0212      */
0213     struct kone_profile profiles[5];
0214     struct kone_settings settings;
0215 
0216     /*
0217      * firmware doesn't change unless firmware update is implemented,
0218      * so it's read only once
0219      */
0220     int firmware_version;
0221 
0222     int roccat_claimed;
0223     int chrdev_minor;
0224 };
0225 
0226 #endif