the-via / keyboards

GNU General Public License v3.0
605 stars 1.01k forks source link

Handling rotary encoder keycodes in VIA #91

Closed Pimentoso closed 2 years ago

Pimentoso commented 4 years ago

Hi, I'm making a keypad with a single rotary encoder and I want to configure the keycodes triggered by CW/CCW rotation from inside VIA.

I saw that the satisfaction75 keyboard did something like this, I looked at the via.c and satisfaction75.c, but mainly my problem is that raw_hid_receive_kb never gets called because I have no idea how to send an unhandled command, so that raw_hid_receive yields to my custom method. I have seen that the satisfaction75 has some custom menu .tsx files in this repo, and that's probably where the custom command gets sent. What's the correct way to implement some custom components/menus and test them locally?

Or is there a simpler way to achieve this? I tried adding two mock buttons to the keymap, and I can assign keycodes to them in VIA, and I could wire the encoder_update_kb method to read the correct eeprom location and get their keycodes, but I haven't found a way to do that.

wilba commented 4 years ago

Sorry for the late reply.

We are adding support for custom UI to VIA right now, which will allow people to add their own custom menus to VIA, to contol such things as rotary encoders, lighting, etc.

Basically this is refactoring how Satisfaction 75's custom menus work, so that you will be able to do what you want.

We'll reply to this issue when it's ready.

Pimentoso commented 4 years ago

That's great news.

rtitmuss commented 3 years ago

I'd really like to support configurable rotary encoders on my keyboard. I was wondering how this change was progressing, is there anything I can do to help?

Pimentoso commented 3 years ago

The last release was 6 months ago, I doubt this project is still maintained.

kb-elmo commented 3 years ago

Any news on this? @Wilba6582

Is VIA even developed actively anymore? Since Olivia is pretty much inactive it seems?

nathan-teoh commented 3 years ago

I believe the only way to get rotary encoder right now is to port what they have for the satisfaction75. I took a quick look at it and I think it's pretty doable. I'm currently trying it out but haven't had anything successfully show up yet, but I'll report back if I have any progress

kaz3304 commented 3 years ago

I believe the only way to get rotary encoder right now is to port what they have for the satisfaction75. I took a quick look at it and I think it's pretty doable. I'm currently trying it out but haven't had anything successfully show up yet, but I'll report back if I have any progress

Have you made any progress? I've tried another piece of software that handles knobs pretty well, but I hadn't considered there might be some things to reverse engineer within via.

bryan065 commented 2 years ago

I was helping another user with a bm60ec keyboard and the way that one handles encoders is pretty neat. You can remap the encoder in via like a regular key. Even works with layers. Everything works with the existing framework.

I have a kb67 soldered and modified with an encoder and I can remap it freely in via.

image The two keys sticking out are for the encoder.

Right now I have the via .JSON modified and have to load it each time. I don't know how Via deals with one-off or handwired keyboards. Will any pull requests for one-off keyboards be accepted?

How I got it to work on my kbd67 soldered:

-Copy your keyboard.h file into your keymap folder. (in my case, mkii_soldered.h). -Edit the file to add the extra keys in the matrix. You then have to map it to any empty spot: image

-Update your keymap.c file with the new layout: image

-Add the encoder functions: image Where each command corresponds to the row and column of the empty matrix spot you used earlier. In my case K406 and K408. (Row 4, columns 6 * 8). Command is dynamic_keymap_get_keycode( LAYER, ROW, COLUMN)

Finally, download the via .JSON for your keyboard

and add the extra keys so you see it in via. image I added two keys to the end of the first row corresponding to the matrix positions (row 4, columns 6/8).

yiancar commented 2 years ago

The above solution is the best solution I have found as well. You can take a look at: https://github.com/qmk/qmk_firmware/compare/master...yiancar:qmk_firmware:P01 especially the p01.c file:)