c# - Logitech's LED Illumination SDK is not working with my G502 -
i'm trying logitech's own led sdk working g502, can't. i'm using sdk version 8.82.7, is, of now, recent version. couldn't find on or rest of internet, i'm asking here.
here's logitechgsdk.cs:
using system; using system.collections; using system.runtime.interopservices; namespace logirgb { public enum keyboardnames { esc = 0x01, f1 = 0x3b, f2 = 0x3c, f3 = 0x3d, f4 = 0x3e, f5 = 0x3f, f6 = 0x40, f7 = 0x41, f8 = 0x42, f9 = 0x43, f10 = 0x44, f11 = 0x57, f12 = 0x58, print_screen = 0x137, scroll_lock = 0x46, pause_break = 0x45, tilde = 0x29, 1 = 0x02, 2 = 0x03, 3 = 0x04, 4 = 0x05, 5 = 0x06, 6 = 0x07, 7 = 0x08, 8 = 0x09, 9 = 0x0a, 0 = 0x0b, minus = 0x0c, equals = 0x0d, backspace = 0x0e, insert = 0x152, home = 0x147, page_up = 0x149, num_lock = 0x145, num_slash = 0x135, num_asterisk = 0x37, num_minus = 0x4a, tab = 0x0f, q = 0x10, w = 0x11, e = 0x12, r = 0x13, t = 0x14, y = 0x15, u = 0x16, = 0x17, o = 0x18, p = 0x19, open_bracket = 0x1a, close_bracket = 0x1b, backslash = 0x2b, keyboard_delete = 0x153, end = 0x14f, page_down = 0x151, num_seven = 0x47, num_eight = 0x48, num_nine = 0x49, num_plus = 0x4e, caps_lock = 0x3a, = 0x1e, s = 0x1f, d = 0x20, f = 0x21, g = 0x22, h = 0x23, j = 0x24, k = 0x25, l = 0x26, semicolon = 0x27, apostrophe = 0x28, enter = 0x1c, num_four = 0x4b, num_five = 0x4c, num_six = 0x4d, left_shift = 0x2a, z = 0x2c, x = 0x2d, c = 0x2e, v = 0x2f, b = 0x30, n = 0x31, m = 0x32, comma = 0x33, period = 0x34, forward_slash = 0x35, right_shift = 0x36, arrow_up = 0x148, num_one = 0x4f, num_two = 0x50, num_three = 0x51, num_enter = 0x11c, left_control = 0x1d, left_windows = 0x15b, left_alt = 0x38, space = 0x39, right_alt = 0x138, right_windows = 0x15c, application_select = 0x15d, right_control = 0x11d, arrow_left = 0x14b, arrow_down = 0x150, arrow_right = 0x14d, num_zero = 0x52, num_period = 0x53, }; public static class logitechgsdk { //led sdk private const int logi_devicetype_monochrome_ord = 0; private const int logi_devicetype_rgb_ord = 1; private const int logi_devicetype_perkey_rgb_ord = 2; public const int logi_devicetype_monochrome = (1 << logi_devicetype_monochrome_ord); public const int logi_devicetype_rgb = (1 << logi_devicetype_rgb_ord); public const int logi_devicetype_perkey_rgb = (1 << logi_devicetype_perkey_rgb_ord); public const int logi_devicetype_all = (logi_devicetype_monochrome | logi_devicetype_rgb | logi_devicetype_perkey_rgb); public const int logi_led_bitmap_width = 21; public const int logi_led_bitmap_height = 6; public const int logi_led_bitmap_bytes_per_key = 4; public const int logi_led_bitmap_size = logi_led_bitmap_width * logi_led_bitmap_height * logi_led_bitmap_bytes_per_key; public const int logi_led_duration_infinite = 0; [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledinit(); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledsettargetdevice(int targetdevice); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledgetsdkversion(ref int majornum, ref int minornum, ref int buildnum); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledsavecurrentlighting(); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledsetlighting(int redpercentage, int greenpercentage, int bluepercentage); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledrestorelighting(); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledflashlighting(int redpercentage, int greenpercentage, int bluepercentage, int millisecondsduration, int millisecondsinterval); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledpulselighting(int redpercentage, int greenpercentage, int bluepercentage, int millisecondsduration, int millisecondsinterval); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledstopeffects(); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledsetlightingfrombitmap(byte[] bitmap); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledsetlightingforkeywithscancode(int keycode, int redpercentage, int greenpercentage, int bluepercentage); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledsetlightingforkeywithhidcode(int keycode, int redpercentage, int greenpercentage, int bluepercentage); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledsetlightingforkeywithquartzcode(int keycode, int redpercentage, int greenpercentage, int bluepercentage); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledsetlightingforkeywithkeyname(keyboardnames keycode, int redpercentage, int greenpercentage, int bluepercentage); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledsavelightingforkey(keyboardnames keyname); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledrestorelightingforkey(keyboardnames keyname); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledflashsinglekey(keyboardnames keyname, int redpercentage, int greenpercentage, int bluepercentage, int msduration, int msinterval); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledpulsesinglekey(keyboardnames keyname, int startredpercentage, int startgreenpercentage, int startbluepercentage, int finishredpercentage, int finishgreenpercentage, int finishbluepercentage, int msduration, bool isinfinite); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern bool logiledstopeffectsonkey(keyboardnames keyname); [dllimport("logitechledengineswrapper ", callingconvention = callingconvention.cdecl)] public static extern void logiledshutdown(); } }
my color changing code amounts to
logitechgsdk.logiledinit(); logitechgsdk.logiledsettargetdevice(logitechgsdk.logi_devicetype_all); logitechgsdk.logiledsetlighting(255, 127, 0);
which should set mouse's leds nice orange, in reality nothing. it's worth noting logitech's own samples, included in sdk .zip, not work. can set led color logitech's gaming software, that's not want.
is logitech's sdk broken? if not, can working?
edit: should mention own rgb version of g502.
in code arguments of logitechgsdk.logiledsetlighting(255, 127, 0);
incorrect exceed value limitation.
they supposed percentages not rgb values.
enter number between 0 , 100 work.
also replace code:
logitechgsdk.logiledsettargetdevice(logitechgsdk.logi_devicetype_all);
with:
logitechgsdk.logiledsettargetdevice(logitechgsdk.logi_devicetype_rgb);
or remove together.
here example of orange:
logitechgsdk.logiledsetlighting(100, 30, 0);
remember give enough time code initialize.