public DeviceSettings(DEVICE_INDEX device) { SelectedDevice = device; ColorMatrix = new COLOR_MATRIX(); KeyColorAll = new KEY_COLOR(); SelectedEffect = EFF_INDEX.EFF_FULL_ON; // Default to Full On int maxLEDRow = SDK.MAX_LED_ROW; int maxLEDColumn = SDK.MAX_LED_COLUMN; KEY_COLOR[][] keyColors = new KEY_COLOR[maxLEDRow][]; for (int i = 0; i < keyColors.Length; i++) { keyColors[i] = new KEY_COLOR[maxLEDColumn]; } for (int i = 0; i < keyColors.Length; i++) { for (int j = 0; j < keyColors[i].Length; j++) { keyColors[i][j] = new KEY_COLOR(0, 0, 0); } } ColorMatrix.KeyColor = keyColors; }
public override void DrawBitmap(Bitmap bitmap) { // Resize the bitmap using (var b = ImageUtilities.ResizeImage(bitmap, Width, Height)) { // Create an empty matrix var matrix = new COLOR_MATRIX {KeyColor = new KEY_COLOR[6, 22]}; // Map the bytes to the matix for (var x = 0; x < Width; x++) { for (var y = 0; y < Height; y++) { var c = b.GetPixel(x, y); if (c.R != 0) Console.WriteLine(); matrix.KeyColor[y, x] = new KEY_COLOR(c.R, c.G, c.B); } } // Send the matrix to the keyboard CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MKeys_L); CmSdk.SetAllLedColor(matrix); } }
public override void UpdateDevice(Bitmap bitmap) { // Create an empty matrix var matrix = new COLOR_MATRIX { KeyColor = new KEY_COLOR[6, 22] }; // Get colors from the bitmap's center X and on 1/3rd and 2/3rd Y var x = bitmap.Width / 2; var y = bitmap.Width / 3; var led1Color = bitmap.GetPixel(x, y); var led2Color = bitmap.GetPixel(x, y * 2); matrix.KeyColor[0, 0] = new KEY_COLOR(led1Color.R, led1Color.G, led1Color.B); matrix.KeyColor[0, 1] = new KEY_COLOR(led2Color.R, led2Color.G, led2Color.B); // Send the matrix to the mouse CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MMouse_S); CmSdk.SetAllLedColor(matrix); }
public static extern bool SetAllLedColor(COLOR_MATRIX colorMatrix, DEVICE_INDEX devIndex = DEVICE_INDEX.DEV_DEFAULT);
public static extern bool SetAllLedColor(COLOR_MATRIX colorMatrix);