Author Topic: Trackpoint module and teensy  (Read 19103 times)

0 Members and 1 Guest are viewing this topic.

Offline driekus

  • Thread Starter
  • Posts: 22
Trackpoint module and teensy
« on: Sun, 27 October 2013, 20:45:29 »
I am hoping that someone can help me. I salvaged an old trackpoint from a used thinkpad and plan to wire it up using a teensy. With assistance from Suka on Deskthority he gave me the wiring for the trackpoint.

To control the trackpoint I used a teensy and the tmk ps2 converter. I followed the guide from http://geekhack.org/index.php?topic=14618.0However when I go to make the file I get a strange error. Can anyone give me some pointers? I am not a coder so this is all new to me.


Linking: ps2_usb.elf
avr-gcc -mmcu=atmega32u4        -gdwarf-2 -DF_CPU=16000000UL -DPS2_USE_USART -DPROTOCOL_PJRC -DMOUSEKEY_ENABLE -DEXTRAKEY_ENABLE -DNO_PRINT -DNO_DEBUG -DNKRO_ENABLE -DMOUSE_ENABLE -DVERSION=unknown -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fno-inline-small-functions -fpack-struct -fshort-enums -fno-strict-aliasing -Wall -Wstrict-prototypes -Wa,-adhlns=ps2_usb.elf -I. -I../.. -I../../protocol/pjrc -I../../protocol -I../../common -std=gnu99 -include config.h -MMD -MP -MF .dep/ps2_usb.elf.d  obj_ps2_usb/keymap.o obj_ps2_usb/matrix.o obj_ps2_usb/led.o obj_ps2_usb/protocol/ps2_usart.o obj_ps2_usb/protocol/pjrc/main.o obj_ps2_usb/protocol/pjrc/pjrc.o obj_ps2_usb/protocol/pjrc/usb_keyboard.o obj_ps2_usb/protocol/pjrc/usb_debug.o obj_ps2_usb/protocol/pjrc/usb.o obj_ps2_usb/protocol/pjrc/usb_mouse.o obj_ps2_usb/protocol/pjrc/usb_extra.o obj_ps2_usb/common/host.o obj_ps2_usb/common/keyboard.o obj_ps2_usb/common/action.o obj_ps2_usb/common/action_tapping.o obj_ps2_usb/common/action_macro.o obj_ps2_usb/common/action_layer.o obj_ps2_usb/common/action_util.o obj_ps2_usb/common/keymap.o obj_ps2_usb/common/timer.o obj_ps2_usb/common/print.o obj_ps2_usb/common/bootloader.o obj_ps2_usb/common/suspend.o obj_ps2_usb/common/xprintf.o obj_ps2_usb/common/util.o obj_ps2_usb/common/mousekey.o --output ps2_usb.elf -Wl,-Map=ps2_usb.map,--cref -Wl,--gc-sections     -lm
obj_ps2_usb/common/keymap.o: In function `action_for_key':
/media/sf_Peter/Downloads/tmk_keyboard-master/tmk_keyboard-master/converter/ps2_usb/../../common/keymap.c:33: undefined reference to `keymap_key_to_keycode'
/media/sf_Peter/Downloads/tmk_keyboard-master/tmk_keyboard-master/converter/ps2_usb/../../common/keymap.c:36: undefined reference to `keymap_fn_to_action'
collect2: ld returned 1 exit status
make: *** [ps2_usb.elf] Error 1

Offline bcg

  • Posts: 112
Re: Trackpoint module and teensy
« Reply #1 on: Sun, 27 October 2013, 21:39:33 »
Those two functions should be at the bottom of your keymap.c file in the ps2_usb folder

Check to see if you commented them out or something like that by mistake
:wq!

Offline CarVac

  • Posts: 22
Re: Trackpoint module and teensy
« Reply #2 on: Sun, 27 October 2013, 21:43:59 »
Could you post what the wiring for the trackpoint is? Or did you also salvage the chip that interprets it?

I'm reviving an old Thinkpad keyboard, and I'm planning on getting the Trackpoint working too. It seems to be paired strain gauges, but I'll need some serious amplification to get much signal out of them.

Offline hasu

  • Posts: 3109
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Trackpoint module and teensy
« Reply #3 on: Sun, 27 October 2013, 21:47:44 »
I didn't test ps2_usb converter for long time and missed fix for new keymap API.

EDIT: ps2_usb still uses old keymap style,  which requires to define USE_LEGACY_KEYMAP in config.h.

Fixed now:
https://github.com/tmk/tmk_keyboard/commit/b9fe36f237635db8e37fc94413a7bb7c381070fc

Try latest source from the repository.
« Last Edit: Sun, 27 October 2013, 21:57:51 by hasu »
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline driekus

  • Thread Starter
  • Posts: 22
Re: Trackpoint module and teensy
« Reply #4 on: Sun, 27 October 2013, 22:05:23 »
Thanks Hasu, makes now without errors.

Will post here once I get it all put together.

CarVac, here is the work that I used to get the pinout.

http://deskthority.net/workshop-f7/my-diy-keyboard-collection-or-how-i-became-a-kb-geek-t2534-30.html#p47258

Offline CarVac

  • Posts: 22
Re: Trackpoint module and teensy
« Reply #5 on: Mon, 28 October 2013, 12:04:37 »
I see; that's completely different than my keyboard's trackpoint. Oh well.

Thanks.

Offline driekus

  • Thread Starter
  • Posts: 22
Re: Trackpoint module and teensy
« Reply #6 on: Mon, 28 October 2013, 22:26:03 »
Well wired everything up nicely, loaded the firmware and got no response. Will need to trace where I went wrong. Could be my awful soldering skills, or the trackpoint was fried beforehand.

 :D The joys of making a keyboard ;D

Offline driekus

  • Thread Starter
  • Posts: 22
Re: Trackpoint module and teensy
« Reply #7 on: Wed, 30 October 2013, 21:10:20 »
So really stumped as to what the problem is here. The firmware uploads no problem and I see a HID mouse show up in device manager. The problem is I dont get any mouse movement.
I tried connecting my second trackpoint and had the same issue. Can anyone give me some pointers on how to troubleshoot?

Offline hasu

  • Posts: 3109
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Trackpoint module and teensy
« Reply #8 on: Wed, 30 October 2013, 22:07:35 »
Sharing your code on github or similar service will be very helpful to others.
How did you connect your Trackpoint to Teensy? I can't see from the pic.
And are you sure about your pin confgure in config.h?

Unfortunately PS/2 mouse support is not documented and has been untouched for long time.
To be honest I don't know if PS/2 mouse works with ps2_usb converter. PS/2 is a bit complecated and resource eater I'm concerned whether my code can take care of two PS/2 line same time. And it doesn't seems to be configurable both PS/2 keyboard and PS/2 mouse connection same time.

Theoretically PS/2 mouse support can work with any other converter and keyboard projects.


EDIT: ummm, looks like PS/2 mouse support is broken now.
« Last Edit: Wed, 30 October 2013, 22:16:53 by hasu »
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline suka

  • Posts: 52
Re: Trackpoint module and teensy
« Reply #9 on: Thu, 31 October 2013, 05:25:22 »
... and I see a HID mouse show up in device manager. The problem is I dont get any mouse movement.
The HID mouse will show up as soon as the appropriate descriptor is compiled in - have you had a look at any values reported in the PS/2 part of your firmware? Before worrying about the complete mouse, I'd suggest to get communication with the trackpoint started to make sure your physical connection is ok. When the teensy can connect to the trackpoint the rest is trivial.

Offline driekus

  • Thread Starter
  • Posts: 22
Re: Trackpoint module and teensy
« Reply #10 on: Thu, 31 October 2013, 09:23:36 »
How do you go about checking this Suka?

Offline suka

  • Posts: 52
Re: Trackpoint module and teensy
« Reply #11 on: Thu, 31 October 2013, 10:06:57 »
Don't know about the way PS/2 is currently implemented in hasus firmware and I do not remember if I got my trackpoints to work with it at some point, but somewhere the connection to the trackpoint has to be initialized via a specific command sequence - that would be the first place to check.

You can see in ps_init_mouse() how I do it in my firmware, and have a look at the other setup calls in trackpoint.c once that works as expected. It may be necessary to reset the trackpoint before, but I am not sure - at least I have it in my firmware like that.

Hopefully this will provide some more information on where it goes wrong, but if the wiring is correct you should be able to figure it out.


Offline driekus

  • Thread Starter
  • Posts: 22
Re: Trackpoint module and teensy
« Reply #12 on: Thu, 31 October 2013, 21:01:45 »
Sharing your code on github or similar service will be very helpful to others.
How did you connect your Trackpoint to Teensy? I can't see from the pic.
And are you sure about your pin confgure in config.h?

Unfortunately PS/2 mouse support is not documented and has been untouched for long time.
To be honest I don't know if PS/2 mouse works with ps2_usb converter. PS/2 is a bit complecated and resource eater I'm concerned whether my code can take care of two PS/2 line same time. And it doesn't seems to be configurable both PS/2 keyboard and PS/2 mouse connection same time.

Theoretically PS/2 mouse support can work with any other converter and keyboard projects.


EDIT: ummm, looks like PS/2 mouse support is broken now.

Thanks for letting me know hasu, greatly appreciated

Offline driekus

  • Thread Starter
  • Posts: 22
Re: Trackpoint module and teensy
« Reply #13 on: Thu, 31 October 2013, 21:43:46 »
Don't know about the way PS/2 is currently implemented in hasus firmware and I do not remember if I got my trackpoints to work with it at some point, but somewhere the connection to the trackpoint has to be initialized via a specific command sequence - that would be the first place to check.

You can see in ps_init_mouse() how I do it in my firmware, and have a look at the other setup calls in trackpoint.c once that works as expected. It may be necessary to reset the trackpoint before, but I am not sure - at least I have it in my firmware like that.

Hopefully this will provide some more information on where it goes wrong, but if the wiring is correct you should be able to figure it out.

Based on Hasu's comment, the tmk firmware wont work for me.
I took a look at your firmware and got it to compile (yay). Still not having much luck but will look into this in detail tomorrow. I dont have a coding background so be gentle.
« Last Edit: Thu, 31 October 2013, 21:52:40 by driekus »

Offline mtl

  • Posts: 180
Re: Trackpoint module and teensy
« Reply #14 on: Fri, 01 November 2013, 06:19:17 »
It is working for me after some small changes to the firmware, however the pointer movement is still very choppy and I haven't had a chance to debug it further. But maybe looking at the changes could be helpful to you? The code is up on github.
MX13 SpaceSaver | Phantom | Tactoblack Filco -10 | Realforce 103U-UW | Variable Clicky Deck 82 | Deck Legend

Offline hasu

  • Posts: 3109
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Trackpoint module and teensy
« Reply #15 on: Wed, 20 November 2013, 22:15:23 »
I finally fixed PS/2 mouse problem of my tmk_keyboard. Try 'onekey' project latest code If you are still interested.
Connect data to PD2  and clock to PD5, you can configure pin assign but note that PD0 and PD1 are already used in matrix.c for one-switch keyboard.

I've been stuck full a few days due to unstable startup behaviour of TrackPoint. In the end I found the fact it needs external reset circuit in its datasheet. Without this TrackPoint might be initialise correctly or not. TIL: datasheet is my friend.
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline driekus

  • Thread Starter
  • Posts: 22
Re: Trackpoint module and teensy
« Reply #16 on: Thu, 21 November 2013, 11:48:52 »
Thanks for that, I didnt realize that the reset was a critical component. I have Suka's firmware so will compare the two and see how it works.

Offline hasu

  • Posts: 3109
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Trackpoint module and teensy
« Reply #17 on: Thu, 21 November 2013, 12:09:18 »
I think Suka's firmware controls reset pin of TrackPoint with AVR I/O instead of RC circuit, so you should connect the reset  to certain I/O pin of controller(PB3?).

https://github.com/frobiac/adnw/blob/master/src/trackpoint.c#L28
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline suka

  • Posts: 52
Re: Trackpoint module and teensy
« Reply #18 on: Thu, 21 November 2013, 13:52:17 »
Yes, I do indeed perform a reset via a dedicated trackpoint pin. But a short test yesterday did not show that call was necessary - then again 3 time replugging with few minutes of use is no real proof of that...
The biggest shortcoming in my firmware is the missing error checking in ps2 setup, which previously lead to hangs while booting when the pins were wrong. But once it works, there are no issues at all! And I use the trackpoint every day and sometimes don't reboot during the work week, so I guess even though the Code is messy stability trumps beauty here :P

Offline driekus

  • Thread Starter
  • Posts: 22
Re: Trackpoint module and teensy
« Reply #19 on: Sun, 24 November 2013, 21:09:57 »
I am just glad I finally got it to work :)
Was worried I would have to go to my backup trackpoints from other thinkpad keyboards.
Now I can think of other projects for these keyboards. :)
Ordered my aluminium frames and should have them in the week. I think it is going to be a Christmas project for me.

Offline suka

  • Posts: 52
Re: Trackpoint module and teensy
« Reply #20 on: Thu, 28 November 2013, 07:13:04 »
While preparing my firmware for driekus to test his trackpoint last week, I noticed what a mess my ps2 part really is and decided to give hasus latest fw a try today - what can I say? Can confirm it works flawlessly and seems really smooth, even though I could only test in busy-wait mode for now due to my wiring.

Too bad I just managed to get on-the-fly macro reprogramming to eeprom working for arbitrary modifier and key combinations on mine (single press Win logon from locked desktop, anyone ? :-) ), guess I either have to port that back to tmk_keyboard or look into the much cleaner ps2 implementation...

Offline driekus

  • Thread Starter
  • Posts: 22
Re: Trackpoint module and teensy
« Reply #21 on: Thu, 28 November 2013, 21:27:51 »
Thanks for letting me know your experience Suka. I am out of town for the next week but cant wait to get back and try this. Hopefully my cut pieces will also be done as well and delivered by then as well

Offline driekus

  • Thread Starter
  • Posts: 22
Re: Trackpoint module and teensy
« Reply #22 on: Tue, 24 December 2013, 21:36:43 »
I finally fixed PS/2 mouse problem of my tmk_keyboard. Try 'onekey' project latest code If you are still interested.
Connect data to PD2  and clock to PD5, you can configure pin assign but note that PD0 and PD1 are already used in matrix.c for one-switch keyboard.

I've been stuck full a few days due to unstable startup behaviour of TrackPoint. In the end I found the fact it needs external reset circuit in its datasheet. Without this TrackPoint might be initialise correctly or not. TIL: datasheet is my friend.

Hi Hasu, I tried searching for the onekey project in https://github.com/tmk/tmk_keyboard/tree/onekey?source=cbc. Is this the one you meant? I downloaded the whole package and looked at the keyboard/onekey directory?

Edit: The way GitHub is organized is a bit unfamiliar to me. I went into the tmk_keyboard and clicked the project branch and went to the onekey branch and downloaded it. Not sure if I want the /keyboard/onekey directory or the converter/ps2_usb directory. The /keyboard/onekey directory does not make so thinking I need the converter/ps2

« Last Edit: Tue, 24 December 2013, 22:50:04 by driekus »

Offline hasu

  • Posts: 3109
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Trackpoint module and teensy
« Reply #23 on: Tue, 24 December 2013, 23:03:51 »
Get master branch and look at keyboard/onekey. onekey branch is old, I'll remove it.
And I changed pin configuration or the project after that post.

1. Remove comment out marks of these lines in Makefile to enable PS/2 mouse support.
PS2_MOUSE_ENABLE = yes
PS2_USE_BUSYWAIT = yes

2. connect TrackPoint
PD1 for clock line
PD2 for data line

3. make
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline driekus

  • Thread Starter
  • Posts: 22
Re: Trackpoint module and teensy
« Reply #24 on: Thu, 26 December 2013, 17:00:25 »
Did you connect the reset pin from the trackpoint to the reset on the teensy?


Get master branch and look at keyboard/onekey. onekey branch is old, I'll remove it.
And I changed pin configuration or the project after that post.

1. Remove comment out marks of these lines in Makefile to enable PS/2 mouse support.
PS2_MOUSE_ENABLE = yes
PS2_USE_BUSYWAIT = yes

2. connect TrackPoint
PD1 for clock line
PD2 for data line

3. make

Offline hasu

  • Posts: 3109
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Trackpoint module and teensy
« Reply #25 on: Thu, 26 December 2013, 17:14:42 »
No, I made RC network on reset pin of TrackPoint, don't remember their values see schematic on its data sheet .
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline driekus

  • Thread Starter
  • Posts: 22
Re: Trackpoint module and teensy
« Reply #26 on: Thu, 26 December 2013, 21:49:40 »
Fantastic, thanks for your help.

I managed to get both my trackpoints working which was good. I will have to check my soldering and put the reset circuit in. I am guessing the reset circuit is the highlighted sector?

I have to prototype the mounting bracket and the buttons so that it fits on my keyboard that I just got laser cut. One of my trackpoints has an really nice metal mounting bracket that I will use. I plan to harvest mouse buttons from an old thinkpad keyboard.

Not sure if I will keep the aluminium or paint it with a firearm paint. Regardless ill probably have to sand the surface back and recreate
 the brushed aluminum look. I am going to steal some blue foam from my daughters play mat because the color matches the keycaps pretty well.

Been a long process (almost 6 months) but very much worth it to see the results. I still love the question most people ask, how much money I saved making my own keyboard. Lol, an expensive labor of love and considering I dont really drink it is probably the equivalent of a few big nights out and I dont get the hangover to go with it.

Offline hasu

  • Posts: 3109
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Trackpoint module and teensy
« Reply #27 on: Thu, 26 December 2013, 23:17:44 »
Right, those R and C are reset circuit.
Good luck with you project!
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline driekus

  • Thread Starter
  • Posts: 22
Re: Trackpoint module and teensy
« Reply #28 on: Sat, 28 December 2013, 13:33:35 »
My final challenge is putting the mouse buttons on. I have harvested the trackpoint buttons from a used keyboard and have a few minor questions.

My understanding of the trackpoint is that the three buttons are mapped to the trackpoint control module. I will probably need to use trial and error to identify which button corresponds to which pin on the control module.

My question is where the other wire from the switch would go. I am guessing to the VCC on my teensy but I could be wrong.

My second question is that I would rather leave the plastic base of the trackpoint buttons attached to the metal frame. I plan to use a Dremel to cut the aluminum to excise the buttons. To connect my electronics to the ribbon I will use a silver conductive glue.
Is this the best way to join to the ribbon cable?

Final question is unlike all other thinkpad keyboards there are 8 wires going to the trackpoint button area. Every other trackpoint keyboard I have seen only has four. Can anyone hypothesize why this is the case (Id rather not remove the plastic component as it is riveting in place and well suited for my project.
« Last Edit: Sat, 28 December 2013, 13:38:04 by driekus »

Offline mtl

  • Posts: 180
Re: Trackpoint module and teensy
« Reply #29 on: Sun, 29 December 2013, 08:15:28 »
My question is where the other wire from the switch would go. I am guessing to the VCC on my teensy but I could be wrong.

Do you mean the COM line from the right side of the schematic you posted? If so, it goes to ground.

Quote
Final question is unlike all other thinkpad keyboards there are 8 wires going to the trackpoint button area. Every other trackpoint keyboard I have seen only has four. Can anyone hypothesize why this is the case (Id rather not remove the plastic component as it is riveting in place and well suited for my project.

Not sure.  The SpaceSaver II keyboard also has rubber-dome mouse buttons, but only four lines run down to the buttons.  Have you tried using a multimeter to check which lines get connected when each mouse button is pressed?
MX13 SpaceSaver | Phantom | Tactoblack Filco -10 | Realforce 103U-UW | Variable Clicky Deck 82 | Deck Legend

Offline hasu

  • Posts: 3109
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Trackpoint module and teensy
« Reply #30 on: Sun, 29 December 2013, 20:08:53 »
My second question is that I would rather leave the plastic base of the trackpoint buttons attached to the metal frame. I plan to use a Dremel to cut the aluminum to excise the buttons. To connect my electronics to the ribbon I will use a silver conductive glue.
Is this the best way to join to the ribbon cable?
Copper tape? It can be soldered with cable and you can stick it to conductive line on membrane sheet.


And this post and thread also will help.
http://geekhack.org/index.php?topic=52481.msg1164174#msg1164174
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline driekus

  • Thread Starter
  • Posts: 22
Re: Trackpoint module and teensy
« Reply #31 on: Sun, 29 December 2013, 20:48:55 »
My second question is that I would rather leave the plastic base of the trackpoint buttons attached to the metal frame. I plan to use a Dremel to cut the aluminum to excise the buttons. To connect my electronics to the ribbon I will use a silver conductive glue.
Is this the best way to join to the ribbon cable?
Copper tape? It can be soldered with cable and you can stick it to conductive line on membrane sheet.
Show Image


And this post and thread also will help.
http://geekhack.org/index.php?topic=52481.msg1164174#msg1164174

Is this the stuff?

http://www.amazon.ca/SparkFun-Copper-Tape-5mm-50ft/dp/B0089SHBHK/ref=sr_1_1?s=electronics&ie=UTF8&qid=1388371646&sr=1-1&keywords=copper+tape

Offline driekus

  • Thread Starter
  • Posts: 22
Re: Trackpoint module and teensy
« Reply #32 on: Mon, 30 December 2013, 20:46:54 »
Would anyone know where I can get the 2.2uF 5V capacitor from? I have tried all the usual sources but not having any luck.


Offline hasu

  • Posts: 3109
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Trackpoint module and teensy
« Reply #33 on: Mon, 30 December 2013, 21:43:14 »
That tape will works, but I think 3M embossed copper tape works better for example 1245 or 2245. if you use not-embossed tape you will need 'needling' to get it conduct with membrane line. You  can see 'needling' in my picture.

Any 2.2uF will works. You can use other general voltage capacitor, 16V or 50V is OK.
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline driekus

  • Thread Starter
  • Posts: 22
Re: Trackpoint module and teensy
« Reply #34 on: Sun, 26 January 2014, 19:47:33 »
OK,
Got the capacitor,but cant find the polarity.
The only relevant marking is the arrow with a 0 in it.
My best guess is that the end marked in blue tape is -ve but I cant be too sure.

Anyone know the answer?

Offline hasu

  • Posts: 3109
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Trackpoint module and teensy
« Reply #35 on: Sun, 26 January 2014, 21:10:11 »
I never used axial capacitor and didn't know its polarity too. But google helped us!
Search 'axial capacitor polarity'. Your guess is right in the end.
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline doub

  • Posts: 45
Re: Trackpoint module and teensy
« Reply #36 on: Mon, 27 January 2014, 05:33:27 »
I believe it's not a 0 on the arrow, but rather a minus sign in a circle, the arrow indicating which side is the negative.

Offline plainbriny

  • Posts: 189
  • Location: Taiwan
Re: Trackpoint module and teensy
« Reply #37 on: Mon, 24 March 2014, 00:54:20 »
Get master branch and look at keyboard/onekey. onekey branch is old, I'll remove it.
And I changed pin configuration or the project after that post.

1. Remove comment out marks of these lines in Makefile to enable PS/2 mouse support.
PS2_MOUSE_ENABLE = yes
PS2_USE_BUSYWAIT = yes

2. connect TrackPoint
PD1 for clock line
PD2 for data line

3. make

Hi hasu,

I get a trackpoint module from a dead R61 and wired according to http://geekhack.org/index.php?topic=8971.msg775152#msg775152 and make the firmware.
But when I push the trackpoint, it sends mouse button event, i.e. button 4,5,6,7 and the cursor doesn't move. Is this the supposed behavior of the onekey program?
If not, I suspect I might short my trackpoint, because I can get button 1 and 3, but not button 2, and push trackpoint translated to mouse wheel events.

UPDATE: There is indeed a short in the trackpoint board. After I fixed that, everything is working wonderfully! Thanks for your great firmware!
« Last Edit: Mon, 24 March 2014, 01:02:19 by plainbriny »

Offline plainbriny

  • Posts: 189
  • Location: Taiwan
Re: Trackpoint module and teensy
« Reply #38 on: Wed, 26 March 2014, 05:22:40 »
I have another question today.

Since I haven't connect the buttons yet, I use mouse keys to function as mouse buttons. So I mapped two keys in the keyboard to act as btn1 and btn2.

However, some functions can not be achieved with trackpoint+mouse keys. For example, I can not make selection by holding button 1 and move trackpoint. This function is working in other combinations, like mouse keys for cursor movement+real mouse button, or mouse keys for button+real mouse moving cursors.

This sounds confusing, simply put, the mouse key function is not working fully with trackpoint. What might be the cause? Is this supposed to happen?

Offline suka

  • Posts: 52
Re: Trackpoint module and teensy
« Reply #39 on: Wed, 26 March 2014, 09:50:29 »
Maybe your firmware resets the button mask somewhere when trackpoint is active?

I manually OR both the keyboards mouse button keys with the actual wired buttons detected before sending the MouseReport out: https://github.com/frobiac/adnw/blob/master/src/ps2mouse.c#L392

Offline lowpoly

  • Posts: 1749
Re: Trackpoint module and teensy
« Reply #40 on: Wed, 26 March 2014, 13:11:35 »
Maybe your firmware resets the button mask somewhere when trackpoint is active?
This.

I manually OR both the keyboards mouse button keys with the actual wired buttons detected before sending the MouseReport out
In case of t.m.k. this will (probably) register the mouse button twice, once through MouseKeys and once through ps2_mouse.

For a quick and dirty solution the place in action.c would be here:
Code: [Select]
#ifdef MOUSEKEY_ENABLE
        /* Mouse key */
        case ACT_MOUSEKEY:
            if (event.pressed) {
mousekey_on(action.key.code);
mousekey_send();
            } else {
mousekey_off(action.key.code);
mousekey_send();
            }
            break;
#endif

and change it to

Code: [Select]
#ifdef MOUSEKEY_ENABLE
        /* Mouse key */
        case ACT_MOUSEKEY:
            if (event.pressed) {
switch (action.key.code)
{
case KC_MS_BTN1:
tp_buttons |= (1<<0);
break;
case KC_MS_BTN2:
tp_buttons |= (1<<1);
break;
case KC_MS_BTN3:
tp_buttons |= (1<<2);
break;
default:
mousekey_on(action.key.code);
mousekey_send();
}
            } else {
switch (action.key.code)
{
case KC_MS_BTN1:
tp_buttons &= ~(1<<0);
break;
case KC_MS_BTN2:
tp_buttons &= ~(1<<1);
break;
case KC_MS_BTN3:
tp_buttons &= ~(1<<2);
break;
default:
mousekey_off(action.key.code);
mousekey_send();
}
            }
            break;
#endif

Then use tp_buttons in ps2_mouse_task(). Not good using a global variable for this, btw. :-[ Also, be aware that this breaks MouseKeys as it won't work anymore without Trackpoint.



« Last Edit: Wed, 26 March 2014, 13:17:21 by lowpoly »

Miniguru thread at GH // The Apple M0110 Today

Offline plainbriny

  • Posts: 189
  • Location: Taiwan
Re: Trackpoint module and teensy
« Reply #41 on: Wed, 26 March 2014, 18:58:23 »
Thanks for the help!
Will try in the next couple days.

UPDATE:
Got it working!!!
I used a function to retrieve the static variable tp_buttons in ps2_mouse.c
takes sometime to recall my decade old C knowledge

Thanks suka and lowpoly!!!
« Last Edit: Thu, 27 March 2014, 09:44:54 by plainbriny »

Offline plainbriny

  • Posts: 189
  • Location: Taiwan
Re: Trackpoint module and teensy
« Reply #42 on: Sat, 29 March 2014, 03:17:05 »
Another question today... hope this won't be to too annoying

trackpoint comparing to ordinary ps/2 mouse, has many properties. For example, it is possible to set press-to-select, sensitivity, etc for trackpoint, and I have found that "TrackPoint System Engineering Specification" contains commands to set these properties. I think the ps2_host_send() function can be used to send these commands. Therefore it should be possible to set these properties when initializing the trackpoint.

However, in this way, these settings are hardwired in the firmware. Is there anyway to communication with trackpoint after initialization?

Offline plainbriny

  • Posts: 189
  • Location: Taiwan
Re: Trackpoint module and teensy
« Reply #43 on: Tue, 01 April 2014, 08:59:39 »
Maybe I am asking too many questions, but I would ask anyway

For my previous question, I still don't know how to change the trackpoint attributes on the fly, but I can change it in the firmware, and it is fine for now...
Code: [Select]
    // sensitivity
    rcx = ps2_host_send(0xE2);
    rcx = ps2_host_send(0x81);
    rcx = ps2_host_send(0x4A);
    rcx = ps2_host_send(0xFF);

    // speed (transfer function upper plateau speed)
    rcx = ps2_host_send(0xE2);
    rcx = ps2_host_send(0x81);
    rcx = ps2_host_send(0x60);
    rcx = ps2_host_send(0xFF);

#ifdef TP_PRESS_TO_SELECT
    // enable press-to-select
    rcx = ps2_host_send(0xE2);
    rcx = ps2_host_send(0x47);
    rcx = ps2_host_send(0x2C);
    rcx = ps2_host_send(0x01);
#endif

And my question today is that I would like to swap the x and y axes for trackpoint. Of course for a reason: rotate the trackpoint module 90 degree can make it fit better to the space available for a 1.5x key
And there are several ways to do it:
1. swap the physical pins of the trackpoint module, there are 4 pins connect to the controller, and they should be gnd, x, y, z, unfortunately I don't know which one is which
2. swap the axes in the firmware:
    2.1 swap with the trackpoint command: E2 81 2C 40
    2.2 modify the ps2_mouse.c code and swap x y
3. swap in the OS level, in my case, I can swap axes using evdev driver in X Windows

My question is that the swapxy command (2.1) in trackpoint doesn't work. In the engineering specification, one may invert x (E2 81 2C 08), y (E2 81 2C 10), z, and swapxy. I can successfully invert x and/or y, but I cannot swap x and y, they just stay unchanged. Anyone know what might be the cause?

I prefer the firmware based method but don't want to change the original code, because this would ruin the x, y readings for other ps2 mouse. I can successfully use the X Windows settings, but would rather not use it, because it would not be portable when I use another computer.

UPDATE:
I re-read the specification and found that actually the "swapxy" command is not there. That particular bit is left unused (per Appendix A). Thus it is not possible to swap the x y axes using trackpoint command. Pity.
« Last Edit: Tue, 01 April 2014, 09:21:24 by plainbriny »

Offline lowpoly

  • Posts: 1749
Re: Trackpoint module and teensy
« Reply #44 on: Tue, 01 April 2014, 10:00:00 »
I prefer the firmware based method but don't want to change the original code, because this would ruin the x, y readings for other ps2 mouse.
But using swapxy would change the firmware too? You could put a switch into the makefile and use #ifdef.


Miniguru thread at GH // The Apple M0110 Today

Offline plainbriny

  • Posts: 189
  • Location: Taiwan
Re: Trackpoint module and teensy
« Reply #45 on: Tue, 01 April 2014, 18:54:30 »
well this is true, and since I have modified the code for mousekey/tp buttons, it doesn't hurt to change more

The following changes have swapped the two axes, seems working

Code: [Select]
// checking the boundary of x and y?
#ifdef TP_SWAPXY
#define Y_IS_NEG  (mouse_report.buttons & (1<<PS2_MOUSE_X_SIGN))
#define X_IS_NEG  (mouse_report.buttons & (1<<PS2_MOUSE_Y_SIGN))
#define Y_IS_OVF  (mouse_report.buttons & (1<<PS2_MOUSE_X_OVFLW))
#define X_IS_OVF  (mouse_report.buttons & (1<<PS2_MOUSE_Y_OVFLW))
#else
#define X_IS_NEG  (mouse_report.buttons & (1<<PS2_MOUSE_X_SIGN))
#define Y_IS_NEG  (mouse_report.buttons & (1<<PS2_MOUSE_Y_SIGN))
#define X_IS_OVF  (mouse_report.buttons & (1<<PS2_MOUSE_X_OVFLW))
#define Y_IS_OVF  (mouse_report.buttons & (1<<PS2_MOUSE_Y_OVFLW))
#endif

reverse the order of receiving x and y from trackpoint
Code: [Select]
#ifdef TP_SWAPXY
        mouse_report.y = ps2_host_recv_response();
        mouse_report.x = ps2_host_recv_response();
#else
        mouse_report.x = ps2_host_recv_response();
        mouse_report.y = ps2_host_recv_response();
#endif

and I have to invert x, using trackpoint command here:
Code: [Select]
#ifdef TP_SWAPXY
    // invert x
    rcx = ps2_host_send(0xE2);
    rcx = ps2_host_send(0x81);
    rcx = ps2_host_send(0x2C);
    rcx = ps2_host_send(0x08);
#endif

Offline zarquon

  • Posts: 17
  • Location: Hungary
Re: Trackpoint module and teensy
« Reply #46 on: Mon, 12 December 2016, 09:25:26 »
Sorry about the necrobump, but this thread contains invaluable information about enabling mouse dragging in tmk with a trackpoint.
I followed lowpoly's advice, but "use tp_buttons in ps2_mouse_task()" was way too cryptic for me for a while.

If you don't understand C, as i do, then this is what you have to do:
in protocol/ps2_mouse.c change this:
Code: [Select]
void ps2_mouse_task(void)
{                 
     enum { SCROLL_NONE, SCROLL_BTN, SCROLL_SENT };
     static uint8_t scroll_state = SCROLL_NONE;
     static uint8_t buttons_prev = 0;
           
     /* receives packet from mouse */
     uint8_t rcv;
     rcv = ps2_host_send(PS2_MOUSE_READ_DATA);
     if (rcv == PS2_ACK) {
         mouse_report.buttons = ps2_host_recv_response();
         mouse_report.x = ps2_host_recv_response();
         mouse_report.y = ps2_host_recv_response();
     } else {             
         if (debug_mouse) print("ps2_mouse: fail to get mouse packet\n");
         return;                   
     }
to this:
Code: [Select]
void ps2_mouse_task(void)
{                 
     enum { SCROLL_NONE, SCROLL_BTN, SCROLL_SENT };
     static uint8_t scroll_state = SCROLL_NONE;
     static uint8_t buttons_prev = 0;
     extern tp_buttons;
           
     /* receives packet from mouse */
     uint8_t rcv;
     rcv = ps2_host_send(PS2_MOUSE_READ_DATA);
     if (rcv == PS2_ACK) {
         mouse_report.buttons = ps2_host_recv_response() | tp_buttons;
         mouse_report.x = ps2_host_recv_response();
         mouse_report.y = ps2_host_recv_response();
     } else {             
         if (debug_mouse) print("ps2_mouse: fail to get mouse packet\n");
         return;                   
     }

also you have to declare tp_buttons in common/action.c in this fashion:
Code: [Select]
int tp_buttons;

As I said, i don't really understand C, so this probably is not how it should be done, but it seems to be work.
Hope somebody will find this useful.

Offline pfoff

  • Posts: 4
Re: Trackpoint module and teensy
« Reply #47 on: Fri, 17 March 2017, 22:08:16 »
And another necrobump, sorry. But that thread is to worthy to let it die!;-)
I run a bunch of tmk adb/ps2 converters for my old keyboards, it realy rocks. THNX @hasu. Really great work!
Now, I decided to transplant a trackpoint into one of my Cherry G80s. I would like to achieve this by converting the ps2 signal from the keyboard with my atmega32u4 and the trackpoint also(Now I use a teensy for testing).
I built the reset circuit as hasu described and connected it to my ports 2 and 5. Trackpoint works great in Busywait mode.
The keyboards data and clk lines are connected to pins 0 and 1. I did run the keyboard converter in interrupt mode.
Now my questions(I know it was asked here before, but couldn't find an answer):
Can I run Interrupt and busywait mode together?
Will the trackpoint also work in int mode?
How to build a ps2 converter for my keyboard together with the trackpoint?
« Last Edit: Fri, 17 March 2017, 22:09:51 by pfoff »