Easy way to make the trackball click be a left mouse button

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.

Anyway:

🙂 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.

4 Likes

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:

1 Like

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.

1 Like

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.

1 Like

can you share the code changes you made for both left click and scroll with fn?

edit –

I guess _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.

  1. In trackball.ino:
    OLD:
    const auto mode = dv->state->moveTrackball();
    NEW:
    const auto mode = dv->Keyboard_state.fn_on == 0 ? TrackballMode::Mouse : TrackballMode::Wheel;

This is about line 70 in the current version.

  1. In keymaps.ino:
    OLD:
 case _TRACKBALL_BTN:
   dv->Mouse->release(MOUSE_MIDDLE);
   break;

NEW:

 case _TRACKBALL_BTN:
   dv->Mouse->release(MOUSE_LEFT);
   break;

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.

1 Like

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.

Thanks again!

Hi! could you share please your pre-build FW? was unable to build it by myself( wanna make my trackball click as left mouse

I think it’s this:

Try that and if it doesn’t work how you want, let me know.

already did. trackball press there acting as a middle button. I figured out why my build did not flashed. I had to use exact board lib version as listed in sources, not the last one. Updated code and set both press and release events as left button - and now it works

1 Like