It seems odd that it’s a middle button. I’m always trying to use it to click in menus and other places.
This works on the CM4 at least, not sure about the other options.
🙂 dsegel@uconsole:~ % xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ ClockworkPI uConsole Consumer Control id=7 [slave pointer (2)]
⎜ ↳ ClockworkPI uConsole Mouse id=9 [slave pointer (2)]
⎜ ↳ vc4 id=10 [slave pointer (2)]
⎜ ↳ vc4 id=11 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ axp20x-pek id=6 [slave keyboard (3)]
↳ ClockworkPI uConsole Keyboard id=8 [slave keyboard (3)]
↳ ClockworkPI uConsole Consumer Control id=12 [slave keyboard (3)]
↳ vc4 id=13 [slave keyboard (3)]
↳ vc4 id=14 [slave keyboard (3)]```
Get the name for the trackball. In this case, it’s “ClockworkPI uConsole Mouse”.
🙂 dsegel@uconsole:~ % xinput get-button-map "ClockworkPI uConsole Mouse" 1 2 3 4 5 6 7 8 9 10 11 12
The second number, 2, is the middle button on a mouse.
🙂 dsegel@uconsole:~ % xinput set-button-map "ClockworkPI uConsole Mouse" 1 1 3 4 5 6 7 8 9 10 11 12
Now it’s a left button.
Make it automatic by putting into your user cron:
🙂 dsegel@uconsole:~ % crontab -e
Add this line to your cron:
@reboot /usr/bin/xinput set-button-map "ClockworkPI uConsole Mouse" 1 1 3 4 5 6 7 8 9 10 11 12
Now it’ll run on every boot.
Cool hack! For what it’s worth, a click on a mouse wheel has always defaulted to a third (middle) mouse button in X. In Linux, you can also accomplish this with systemd’s hardware database management tool:
You can actually change it on source. Download Arduino IDE and the keypad code, compile it and flash it.
Yeah, I actually did that afterwards, along with making the trackball work as a scroll wheel with the Fn key, but some people may want a simpler approach.
Right, but using it depends on which window manager you’re using, and I didn’t think anybody was still doing that kind of thing.
I tried doing it with various other methods like you posted but it either didn’t work or wasn’t as simple as I would like. I ended up just modifying the firmware anyway, but this is still an easy way to switch it back and forth.
can you share the code changes you made for both left click and scroll with fn?
_MOUSE_MID, // Mouse.press(2) to become
_MOUSE_MID, // Mouse.press(1)
to fix the left click. but then fn to scroll, i’m not that good at reversing code, or writing… i can only do basic deduction
Sure, there are two changes.
- In trackball.ino:
const auto mode = dv->state->moveTrackball();
const auto mode = dv->Keyboard_state.fn_on == 0 ? TrackballMode::Mouse : TrackballMode::Wheel;
This is about line 70 in the current version.
- In keymaps.ino:
This is about line 433 in the current version.
Make both those changes, select Sketch->Export compiled Binary and you should get a .bin file in the same directory as the files. Copy that to the uConsole and run the flash utility (uconsole_keyboard_flash.tar.gz) with it. This is all using the code found under Code->uConsole Keyboard in the github repo.
Awesome! Thanks so much for the info! So often I keep using that ball to left click, and the fn scroll is a great idea.