private void SetOneKey(Logitech_keyboardBitmapKeys key, Color color) { bitmap[(int)key] = color.B; bitmap[(int)key + 1] = color.G; bitmap[(int)key + 2] = color.R; bitmap[(int)key + 3] = color.A; }
public bool UpdateDevice(Dictionary <DeviceKeys, Color> keyColors, bool forced = false) { try { foreach (KeyValuePair <DeviceKeys, Color> key in keyColors) { Logitech_keyboardBitmapKeys localKey = ToLogitechBitmap(key.Key); if (localKey == Logitech_keyboardBitmapKeys.UNKNOWN && key.Key == DeviceKeys.Peripheral) { SendColorToPeripheral(key.Value, forced); } else if (localKey != Logitech_keyboardBitmapKeys.UNKNOWN) { SetOneKey(localKey, key.Value); } } SendColorsToKeyboard(forced); return(true); } catch (Exception e) { Console.WriteLine(e); return(false); } }
private void SetOneKey(Logitech_keyboardBitmapKeys key, Color color) { if (Global.Configuration.logitech_enhance_brightness) { float boost_amount = 0.0f; boost_amount += 3.0f - (color.R / 30.0f); boost_amount += 3.0f - (color.G / 30.0f); boost_amount += 3.0f - (color.B / 30.0f); boost_amount /= 3.0f; boost_amount = boost_amount <= 1.0f ? 1.0f : boost_amount; color = Utils.ColorUtils.MultiplyColorByScalar(color, boost_amount); } bitmap[(int)key] = color.B; bitmap[(int)key + 1] = color.G; bitmap[(int)key + 2] = color.R; bitmap[(int)key + 3] = color.A; }
public bool UpdateDevice(Dictionary <DeviceKeys, Color> keyColors, bool forced = false) { try { foreach (KeyValuePair <DeviceKeys, Color> key in keyColors) { Logitech_keyboardBitmapKeys localKey = ToLogitechBitmap(key.Key); if (localKey == Logitech_keyboardBitmapKeys.UNKNOWN && key.Key == DeviceKeys.Peripheral) { SendColorToPeripheral((Color)key.Value, forced); } if (localKey == Logitech_keyboardBitmapKeys.UNKNOWN && key.Key == DeviceKeys.OEM8) { double alpha_amt = (key.Value.A / 255.0); int red_amt = (int)(((key.Value.R * alpha_amt) / 255.0) * 100.0); int green_amt = (int)(((key.Value.G * alpha_amt) / 255.0) * 100.0); int blue_amt = (int)(((key.Value.B * alpha_amt) / 255.0) * 100.0); LogitechGSDK.LogiLedSetLightingForKeyWithHidCode(220, red_amt, green_amt, blue_amt); } else if (localKey != Logitech_keyboardBitmapKeys.UNKNOWN) { SetOneKey(localKey, (Color)key.Value); } } SendColorsToKeyboard(forced); return(true); } catch (Exception e) { Global.logger.LogLine(e.ToString(), Logging_Level.Error); return(false); } }
public bool UpdateDevice(Dictionary <DeviceKeys, Color> keyColors, bool forced = false) { try { foreach (KeyValuePair <DeviceKeys, Color> key in keyColors) { Logitech_keyboardBitmapKeys localKey = ToLogitechBitmap(key.Key); if (localKey == Logitech_keyboardBitmapKeys.UNKNOWN && (key.Key == DeviceKeys.Peripheral_Logo || key.Key == DeviceKeys.Peripheral)) { if (!Global.Configuration.devices_disable_mouse || !Global.Configuration.devices_disable_headset) { SendColorToPeripheral((Color)key.Value, forced || !peripheral_updated); } } else if (localKey == Logitech_keyboardBitmapKeys.UNKNOWN) { double alpha_amt = (key.Value.A / 255.0); int red_amt = (int)(((key.Value.R * alpha_amt) / 255.0) * 100.0); int green_amt = (int)(((key.Value.G * alpha_amt) / 255.0) * 100.0); int blue_amt = (int)(((key.Value.B * alpha_amt) / 255.0) * 100.0); if (!Global.Configuration.devices_disable_keyboard) { LogitechGSDK.LogiLedSetTargetDevice(LogitechGSDK.LOGI_DEVICETYPE_PERKEY_RGB); switch (key.Key) { case DeviceKeys.OEM8: LogitechGSDK.LogiLedSetLightingForKeyWithHidCode(220, red_amt, green_amt, blue_amt); break; case DeviceKeys.G1: LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyboardNames.G_1, red_amt, green_amt, blue_amt); break; case DeviceKeys.G2: LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyboardNames.G_2, red_amt, green_amt, blue_amt); break; case DeviceKeys.G3: LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyboardNames.G_3, red_amt, green_amt, blue_amt); break; case DeviceKeys.G4: LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyboardNames.G_4, red_amt, green_amt, blue_amt); break; case DeviceKeys.G5: LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyboardNames.G_5, red_amt, green_amt, blue_amt); break; case DeviceKeys.G6: LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyboardNames.G_6, red_amt, green_amt, blue_amt); break; case DeviceKeys.G7: LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyboardNames.G_7, red_amt, green_amt, blue_amt); break; case DeviceKeys.G8: LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyboardNames.G_8, red_amt, green_amt, blue_amt); break; case DeviceKeys.G9: LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyboardNames.G_9, red_amt, green_amt, blue_amt); break; case DeviceKeys.LOGO: LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyboardNames.G_LOGO, red_amt, green_amt, blue_amt); break; case DeviceKeys.LOGO2: LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyboardNames.G_BADGE, red_amt, green_amt, blue_amt); break; } } } else if (localKey != Logitech_keyboardBitmapKeys.UNKNOWN) { if (!Global.Configuration.devices_disable_keyboard) { LogitechGSDK.LogiLedSetTargetDevice(LogitechGSDK.LOGI_DEVICETYPE_PERKEY_RGB); SetOneKey(localKey, (Color)key.Value); } } } if (!Global.Configuration.devices_disable_keyboard) { SendColorsToKeyboard(forced || !keyboard_updated); } return(true); } catch (Exception e) { Global.logger.LogLine(e.ToString(), Logging_Level.Error); return(false); } }