Support for FL ESPORTS MK870 CMMK 87 Keys TKL Keyboard

Hello guys,

SignalRGB was automatically detecting my keyboard as a Fantech MAXFIT61 … so I went ahead and try modifing this plugin file and see if I could make it work with a TKL layout … it turned out that it worked perfect after some tunning and trial/error … anyways, here it is and I hope you’ll find it useful.

It would be super cool if this one could be included on the main application as an internal plugin. For now I’m putting it on my user plugins folder.

Enjoy!


export function Name() { return "Fantech MAXFIT61"; }
export function VendorId() { return 0x0416; }
export function ProductId() { return 0xc345; }
export function Publisher() { return "5hvled & WhirlwindFX"; }
export function Size() { return [17, 6]; }
export function DefaultPosition(){return [10, 100]; }
export function DefaultScale(){return 8.0;}
export function ControllableParameters() {
	return [
		{"property":"shutdownColor", "group":"lighting", "label":"Shutdown Color", "min":"0", "max":"360", "type":"color", "default":"009bde"},
		{"property":"LightingMode", "group":"lighting", "label":"Lighting Mode", "type":"combobox", "values":["Canvas", "Forced"], "default":"Canvas"},
		{"property":"forcedColor", "group":"lighting", "label":"Forced Color", "min":"0", "max":"360", "type":"color", "default":"009bde"},
	];
}
/* global
shutdownColor:readonly
LightingMode:readonly
forcedColor:readonly
*/

const vKeyNames = [
	"Esc",     "F1","F2","F3","F4",   "F5","F6","F7","F8",    "F9", "F10", "F11", "F12",  "Print Screen", "Scroll Lock", "Pause Break",   
	"`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-_", "=+", "Backspace", "Insert", "Home", "PgUp",
	"Tab", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", "\\", "Delete", " End", "PgDown",
	"CapsLock", "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "'",       "Enter",
	"Left Shift",      "Z", "X", "C", "V", "B", "N", "M", ",", ".", "/",     "Right Shift",    "Up Arrow",
	"Left Ctrl", "Left Win", "Left Alt",        "Space",      "Right Alt", "Menu", "Right Ctrl", "Fn",    "Left Arrow",  "Down Arrow", "Right Arrow"
];

const vKeys = [
	0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,	15, 16, 17,							
	22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,  36,    37, 38, 30,
	44,  45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 58,    59, 60, 61,
	66,   68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,    80,
	88,    90, 91, 92, 93, 94, 95, 96, 97, 98, 99,      102, 104,
	110, 111, 112,         116,          120, 121, 122, 123,    125, 126, 127
];

const  vKeyPositions = [
	[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0], [11, 0], [12, 0],   [13, 0],	[14, 0], [15, 0], [16, 0],
	[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1],   [13, 1],	[14, 1], [15, 1], [16, 1],
	[0, 2],  [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2], [11, 2], [12, 2],  [13, 2],	[14, 2], [15, 2], [16, 2],
	[0, 3],   [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [8, 3], [9, 3], [10, 3], [11, 3],          [13, 3],
	[0, 4],        [2, 4], [3, 4], [4, 4], [5, 4], [6, 4], [7, 4], [8, 4], [9, 4], [10, 4], [11, 4],             [13, 4],	[15, 4],
	[0, 5], [1, 5], [2, 5],                         [6, 5],                            [10, 5], [11, 5], [12, 5], [13, 5],	[14, 5], [15, 5], [16, 5]
];

export function LedNames() {
	return vKeyNames;
}

export function LedPositions() {
	return vKeyPositions;
}

export function Initialize() {
	device.write([0x01, 0x0D], 64);
	device.write([0x01, 0x15], 64);
	device.write([0x01, 0x0A], 64);
	device.write([0x01, 0x02], 64);
	device.write([0x01, 0x07, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x04, 0x03, 0xFF], 64);
	device.write([0x01, 0x17, 0x00, 0x00, 0x00, 0x01, 0x01], 64);
	device.write([0x01, 0x08, 0x00, 0x00, 0x00, 0x0D, 0x02, 0x03, 0x03, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01], 64);
}

export function Render() {
	sendColors();
}

export function Shutdown() {

}

function sendColors(shutdown = false) {
  	let mxPxColor;
	const RGBData = new Array(432);

	for(let iIdx = 0; iIdx < vKeyPositions.length; iIdx++) {
		const iPxX = vKeyPositions[iIdx][0];
		const iPxY = vKeyPositions[iIdx][1];

		if(shutdown) {
			mxPxColor = hexToRgb(shutdownColor);
		}else if (LightingMode === "Forced") {
			mxPxColor = hexToRgb(forcedColor);
		}else {
			mxPxColor = device.color(iPxX, iPxY);
		}

		RGBData[(vKeys[iIdx]*3)] = mxPxColor[0];
		RGBData[(vKeys[iIdx]*3)+1] = mxPxColor[1];
		RGBData[(vKeys[iIdx]*3)+2] = mxPxColor[2];
	}

	for(let row = 0; row <= 7; row++) {
		let packet = [];
		packet[0] = 0x01;
		packet[1] = 0x0F;
		packet[2] = 0x00;
		packet[3] = 0x00;
		packet[4] = row;
		packet[5] = row === 7 ? 0x12 : 0x36;
		packet = packet.concat(RGBData.splice(0, 54));
		device.write(packet, 64);
	}

	device.write([0x01, 0x0F, 0x01, 0x00, 0x00, 0x36], 64);
	device.write([0x01, 0x0F, 0x01, 0x00, 0x01, 0x2D], 64);
}

function hexToRgb(hex) {
	const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
	const colors = [];
	colors[0] = parseInt(result[1], 16);
	colors[1] = parseInt(result[2], 16);
	colors[2] = parseInt(result[3], 16);

	return colors;
}

export function Validate(endpoint) {
	return endpoint.interface === 2 && endpoint.usage === 0x0091 && endpoint.usage_page === 0xff1b && endpoint.collection === 0x0000;
}

export function Image() {
	return "";
}

Hey, arunasmazeika

Thank you for reporting this, we should probably make some modifications, it seems this keyboard board is used on more devices, some type of “white label” board. We will make sure to include it!

I have merged both boards, can you try the attached file? I would like to have a screenshot from the device console.

Fantech_board_Keyboard.js (651.9 KB)

Hello there!, this is awesome … I’ll try this out later during the day and I’ll let you know how it goes!

Many thanks!

I’ll provide the console capture also as requested, I can provide logs also if you need them.

Hi @HarDBR,

I’ve tried the plugin you’ve provided and its kind of working but not 100% … only the upper part (function keys) are being added on top of the ones of the 61 layout keyboard … also the plugin is very unstable and Signal RGB keeps crashing constantly after a few seconds … I’ve recorded a video to show you how is that this is currently working, also took care of displaying the console as you’ve requested.

Video link here => http://drops.arunasmazeika.com/IMG_4486.MOV

Signal RGB crashed just after I’ve click on stop to finish the video recording … to bad I didn’t get it on camera but this is easily reproducible … please let me know if you need anything else, more tests, etc. Happy to help!

Arunas

Here’s how the keyboard looks with the plugin I’ve modified … all LEDs are being used:

=> http://drops.arunasmazeika.com/IMG_4487.heic

and here’s the console view with this precise plugin (mine):

=> http://drops.arunasmazeika.com/IMG_4488.HEIC

I hope this helps.

Hello, @arunasmazeika

For some reason, I cant access those links, are you able to upload the file direct here?

On your tests, have you changed the device layout on the cog icon?

Hi @HarDBR,

That’s very strange, the links are public so they should work … Here’s a GDrive link with a zip file containing the screenshots and the video I’ve published above => keyboard.zip - Google Drive … the video shows how is that the keyboard behaves with the plugin you’ve provided … the two screenshots are from my changes. I hope you’ll be able to get the files this time.

On my tests, yes, I’ve changed the layout to TKL on the plugin UI … I did have the function keys lighten up but all the additional right side was not being lit and the plugin also kept crashing.

Please let me know if you want me to perform additional tests, happy to help.

Cheers.

Fantech_board_Keyboard.js (652.0 KB)
Hi, @arunasmazeika

Can you try the plugin attached? I have also identified you had a extra key on the array by ID 13, so I removed it, let me know how this works.

Hello! @HarDBR,

I’m sorry I’ve took this long to get back to you … I’ve made some changes to the last plugin you’ve provided. Stability wise it’s good … the crashes I was having are now fixed.

I’ve made some additional changes to the layout and also added a size function that properly returns the size of each board (this was missing) … everything seems to work perfect now!

The new plugin file may be found here => Microsoft OneDrive - Access files anywhere. Create docs with free Office Online.

If you need anything else, logs, etc. please let me know.

Arunas

One thing though … each time I start the computer … I need to go back to the device and switch to my layout on the plugin UI … maybe this is perhaps I’m using it as a user plugin? … just wanted to let you know :slight_smile:

Following up to my previous comment … the layout is already selected when I restart the PC … but somehow it’s like the layout is not really enabled, the keyboard is not lit, all leds are turned off … each time I restart I need to go to SignalRGB, select the device and click again on the TKL layout, then all works. It’s like the layout is not set/saved by default on each restart.

1 Like

Plugin have a wrong order for vKeys cuz F11 and F12 was always off and there was mismatch of keys when you used LED Painting cuz if u used it for example on F1 it colored F2, F2 was F3 etc, so I fixed that.

Here’s link cuz I can’t upload as new user.

Maybe it’s not so big change but still, now it works for me perfectly :slight_smile:

1 Like

Fantech_board_Keyboard.js (652.2 KB)
Hi, guys

The attached file should be the final version and I have added the board properties on Initialization, this way, it should set the saved model on a restart.

Let me know if that works correctly!

Hi @HarDBR … I think we have a winner here … @rey384 I didn’t think on the painting method for verifying the layout … very useful indeed! I can confirm that now everything is perfectly in place … the initialisation issue is also fixed, the plugin now remembers my layout and everything works perfectly after a reboot.

I think we have a release candidate here! … thank you very much everyone for your help … now let’s enjoy this plugin :slight_smile:

Cheers.

1 Like