💾 Archived View for tanelorn.city › ~bouncepaw › gemlog › gemini-keeb-protocol.gemini captured on 2020-09-24 at 01:46:32. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

Using gemini for keyboards

Posted at 2020-07-18

Some of you may know that I'm somewhat obsessed with keyboards. No, I'm not one of those keeb flexboys that buy these identical 60% keyboards and 100$ keycap sets produced by GMK. Imagine buying that.

No, I'm a real keyboard enthusiast! I create my keyboards from foamboard and the cheapest components I can find and consider myself elite. Works great tho. You may read my old article about my old keyboard Sequira:

The article. It's in English and is outdated

I have created Sagaris since then. I haven't written any article about it. The most info is in my Telegram channel. You can also check out our Russian DIY keyboard community if you happen to have Telegram. Most of us speak English afaik.

My channel

The community

Ok, enough self-ad. Let's jump to gemini.

Why use a network protocol for keyboards?!

All keyboards today use the same outdated HID protocol. It's a bad fit for keyboards despite the fact it was created with keyboards in mind. I won't describe the protocol here.

OSdev wiki has an article about HID

Modern keyboards are much more complicated than their ancestors. We have layers, unicode and other benefits of civilization. Keyboard creators have to rely on complicated spaghetti plates of keyboard firmware protocols (QMK, for example), computer-side tricky things (Karabiner elements, AHK, xkb...) and program-side workarounds (vimers like to exit insert mode by typing jj).

It's all a mess! Computers are already complicated, why do I have to bear all that pain? Let's create yet another element to this tangle.

Why gemini exactly?

The idea of using something other than HID has been floating in the minds for several years. HTTP was the most popular candidate for communication. Well, what else did we have? HTTPS? Well, there is some sense in encrypting your keyboard input indeed...

Now that we have gemini, we can stick to a simpler protocol because HTTP is objectively bad for keyboard operations. Imagine caching keyboard input. Also, creating an HTTP software is quite hard and keyboards usually have limited resources.

Gemini protocol has just enough features to implement a comfortable keeb-to-pc communication! The only con is, I guess, the lack of keep-connection. While it's not needed for serving text/gemini, it'd be handy for keyboards. Well, whatever.

Features

This is just a list of features I could think of two hours before the sun rises. It is incomplete. Oh, I think I haven't stated it yet. There's no implementation! It's just an idea!

I will present URLs without encoding for legibility.

Connecting to a pc

It introduces a keyboard named MegaKeeb3000 (third version) manufactured by Kine co. The computer will tell if it's ok in the response. If it's ok, it'll remember keyboard's TLS certificate (oh boy, it sounds so fun and funny) and use it later to identify the keyboard and vice versa.

You can connect to several PCs! Why? There may be cases when it's useful.

Disconnecting

Profiles

A user may have configured their computer to add a profile on connection.

Keyboard layouts are not actually used by keyboards. They are used by computers but it's a good idea to save the layout in the keyboard to have access to it from any PC.

It is possible to delete a profile! It is mandatory for keyboards to maintain at least one safe profile that cannot be deleted.

You can also read the profile in a serialized form (JSON, for example).

[
	{
		"kc": 1,
		"on press": [
			{
				"action": "type",
				"text": "trust in yourself"
			}
		],
		"on double press": [
			{
				"action": "type", 
				"text": "not this much"
			}
		]
	}, 
	{
		"kc": 2, 
		"on press": [
			{
				"action": "type", 
				"text": "q"
			}
		]
	}, 
	{
		"kc": 3, 
		"on hold": [
			{
				"layer put": "lower"
			}
		], 
		"on release": [
			{
				"layer pop": "lower"
			}
		]
	}, 
	...
]

You get the idea. Of course, using JSON for that is a horrible idea. A better serialization format would be good. Actually, I've been designing one some time ago (it was called keyrunes and was really cool!). Perhaps I'll write about it someday.

Manipulating keys

Typing text

Typing text is a handful shortcut.

Keyboard multiplexing

It's normal for computers to have several keyboards connected to them. I currently have two (Sagaris and Baïonnete (it has useful binds for a graphical editor)). Computers have to multiplex them. To do this, they follow simple rules:

By the way, keyboards can access each other! Computers shall provide information about all keyboards if needed.

Remote keyboards

As you have noticed, everything has an URL! Imagine if you could access my keyboard from a different side of globe and learn what keyboard layout I use! This idea of transparency just drives me crazy. The world truly is connected. Of course, you can block damaging requests from outside-world in your firewall or whatever.

You can also easily sync all your keyboard-related configurations between computers easily. All they need is to have access to the net.

How is it good for keyboards?

All my homies have complicated logic in their keyboards just to handle sane basic use cases. It's not a thing keyboards shall do. They shall:

Everything else is up to computers. What do modern keyboards and computers do? Keyboards do this:

Computers do this:

Insanity! Craziness!

Closing thoughts

This is just a concept but I do find this idea quite beautful. Perhaps I'll make a keyboard like that one day. Of course, the protocol design will be redesigned heavily.

I really look forward to your reaction. Does it make you disgusted (sending a kilobyte just to type a word is insane! It's Electron of keyboard world), does it make you amazed (finelly! No need for AHK)? Please tell me.