Author Topic: QMK, Teensy 3.2, and a Thinkpad keyboard  (Read 7263 times)

0 Members and 1 Guest are viewing this topic.

Offline eyemyth

  • Thread Starter
  • Posts: 4
  • Location: Austin, TX
QMK, Teensy 3.2, and a Thinkpad keyboard
« on: Wed, 22 May 2019, 20:04:20 »
Hi all. This is my first post here.

I'm standing on the shoulders of giants, working on a project where I have a Thinkpad keyboard hooked up to a Teensy 3.2. Here's a pic: https://i.imgur.com/omK0TfY.jpg

I used the PCB designed for this: https://github.com/thedalles77/USB_Laptop_Keyboard_Controller/blob/master/Example_Keyboards/Lenovo_ThinkPad_T61/Teensy%203p2/Lenovo%20ThinkPad%20T61%20USB%20Keyboard.pdf

I was able to trace the matrix using an Arduino sketch made for that purpose. I can also build and flash Frank's firmware which provides basic functionality but no layers or macros. I have no background in C so I'm hoping somebody can help me. I've blundered through enough to get it to compile, but my keyboard doesn't work. Some keypresses will send seemingly random keys some of the time. Here's my code: https://github.com/eyemyth/qmk_firmware/tree/master/keyboards/lenovo_t420

Offline eyemyth

  • Thread Starter
  • Posts: 4
  • Location: Austin, TX
Re: QMK, Teensy 3.2, and a Thinkpad keyboard
« Reply #1 on: Thu, 23 May 2019, 03:41:10 »
Most of the keys don't type anything, the ones that do type intermittently and send the wrong output. I get the 'bounce' output in QMK Toolbox for every key except the keys wired to the column on pin 24 (F2, F3, F4, 3, C, D, E), and a few other seemingly random keys (F1, W, R, X, Tab).

I have the physical matrix described here, based on the output of the program that I used to trace the matrix: https://github.com/eyemyth/qmk_firmware/blob/master/keyboards/lenovo_t420/lenovo_t420.h#L65

So I'm pretty sure there's something wrong in my matrix.c file, but again I'm basically fumbling around in the dark here - I don't know C. But I'm pretty determined to get this thing working. I'd like to use QMK, but if it's going to be easier on some other firmware, that's fine too. As long as I can use some layers like QMK's MO() functionality, and also get at least the mouse buttons to work, I'll be happy. Super happy, actually. Ecstatic, probably.

Offline piit79

  • Posts: 382
Re: QMK, Teensy 3.2, and a Thinkpad keyboard
« Reply #2 on: Thu, 23 May 2019, 08:03:15 »
This is awesome! I'd like to do this too :-) I'd love to help but I'm a bit short of time atm :(

If you can do some debugging, I'd check if read_cols() from matrix.c returns the expected values - run unselect_rows(), then select_rows(1) and then print the output from read_cols() in a loop. You should be getting powers of 2 if you press a single key in that row.

I have a ThinkPad W520 - imagine connecting the internal keyboard to the Teensy board, fitting it somewhere inside and somehow connecting it to USB internally - QMK on the internal keyboard :)

Sent from my OnePlus 6T with a rubbish gimmicky bloody annoying unreliable in-display fingerprint reader using Tapatalk


Offline eyemyth

  • Thread Starter
  • Posts: 4
  • Location: Austin, TX
Re: QMK, Teensy 3.2, and a Thinkpad keyboard
« Reply #3 on: Thu, 23 May 2019, 11:48:05 »
So it seems to think that pins 26 and 16 are continually connected.

I'd assume that was a hardware/soldering problem, except that everything works fine with the Arduino sketch that I got from the guy who designed the PCB.

I added
Code: [Select]
        debug_hex(cols); debug("\n"); to the matrix_scan after read_cols() and this shows up in QMK Toolbox:

Code: [Select]
*** Halfkay device disconnected
*** Lenovo - lenovo_t420 connected -- 0xFEED:0x0
  > Keyboard start.
    400
    bounce!: 05
  > 400
    bounce!: 05
    400
    bounce!: 05
  > 400
    bounce!: 05
    400
    bounce!: 05
  > 400
    bounce!: 05
    400
    bounce!: 05
  > 400
    bounce!: 05
  > 400
    400
    400
    400
    400
    400
    400
    400
  > 400
    400
    400
    400
    400
  > 400
    400
    400
  > 400
    400
    400
    400
    400
    400
    400
    400
  > 400
    400
    400
    400
    400
    400
    400
    400
  >
    r/c 0123456789ABCDEF
    00:
    01:
  > 02:
    03:
    04:
    05:
    06:
    07:
   
    ---- action_exec: start -----
    EVENT: 000Ad(5213)
    KL: kc: 0, col: 10, row: 0, pressed: 1
    ACTION: ACT_LMODS[0:00] layer_state: 00000000(0) default_layer_state: 00000000(0)
    processed: 000Ad(5213):0
   
  > 400
    400
    400
    400
    400
    400
    400
    400
  >
    r/c 0123456789ABCDEF
    00:
    01:
  > 02:
    03:
    04:
    05:
    06:
    07:
   
    ---- action_exec: start -----
    EVENT: 010Ad(5327)
    KL: kc: 63, col: 10, row: 1, pressed: 1
    ACTION: ACT_LMODS[0:3F] layer_state: 00000000(0) default_layer_state: 00000000(0)
    keyboard_report: 00 00 3F 00 00 00 00 00
    processed: 010Ad(5327):0
   
  > 400
    400
    400
    400
    400
    400
    400
    400
  >
    r/c 0123456789ABCDEF
    00:
    01:
  > 02:
    03:
    04:
    05:
    06:
    07:
   
    ---- action_exec: start -----
    EVENT: 020Ad(5443)
    KL: kc: 34, col: 10, row: 2, pressed: 1
    ACTION: ACT_LMODS[0:22] layer_state: 00000000(0) default_layer_state: 00000000(0)
    keyboard_report: 00 00 3F 22 00 00 00 00
    processed: 020Ad(5443):0
   
  > 400
    400
    400
    400
    400
    400
    400
    400
  >
    r/c 0123456789ABCDEF
    00:
    01:
  > 02:
    03:
    04:
    05:
    06:
    07:
   
    ---- action_exec: start -----
    EVENT: 030Ad(5559)
    KL: kc: 21, col: 10, row: 3, pressed: 1
    ACTION: ACT_LMODS[0:15] layer_state: 00000000(0) default_layer_state: 00000000(0)
    keyboard_report: 00 00 3F 22 15 00 00 00
    processed: 030Ad(5559):0
   
  > 400
    400
    400
    400
    400
    400
    400
    400
  >
    r/c 0123456789ABCDEF
    00:
    01:
  > 02:
    03:
    04:
    05:
    06:
    07:
   
    ---- action_exec: start -----
    EVENT: 040Ad(5675)
    KL: kc: 48, col: 10, row: 4, pressed: 1
    ACTION: ACT_LMODS[0:30] layer_state: 00000000(0) default_layer_state: 00000000(0)
    keyboard_report: 00 00 3F 22 15 30 00 00
    processed: 040Ad(5675):0
   
  > 400
    400
    400
    400
    400
    400
    400
    400
  >
    r/c 0123456789ABCDEF
    00:
    01:
  > 02:
    03:
    04:
    05:
    06:
    07:
   
    ---- action_exec: start -----
    EVENT: 050Ad(5791)
    KL: kc: 14, col: 10, row: 5, pressed: 1
    ACTION: ACT_LMODS[0:0E] layer_state: 00000000(0) default_layer_state: 00000000(0)
    keyboard_report: 00 00 3F 22 15 30 0E 00
    processed: 050Ad(5791):0
   
  > 400
    400
    400
    400
    400
    400
    400
    400
  >
    r/c 0123456789ABCDEF
    00:
    01:
  > 02:
    03:
    04:
    05:
    06:
    07:
   
    ---- action_exec: start -----
    EVENT: 060Ad(5907)
    KL: kc: 6, col: 10, row: 6, pressed: 1
    ACTION: ACT_LMODS[0:06] layer_state: 00000000(0) default_layer_state: 00000000(0)
  > keyboard_report: 00 00 3F 22 15 30 0E 06
    processed: 060Ad(5907):0
   
  > 400
    400
    400
    400
    400
    400
    400
    400
  >
    r/c 0123456789ABCDEF
    00:
    01:
  > 02:
    03:
    04:
    05:
    06:
    07:
   
    ---- action_exec: start -----
    EVENT: 070Ad(6025)
    KL: kc: 4, col: 10, row: 7, pressed: 1
    ACTION: ACT_LMODS[0:04] layer_state: 00000000(0) default_layer_state: 00000000(0)
    keyboard_report: 00 00 3F 22 15 30 0E 06
    processed: 070Ad(6025):0
   
  > 400
    400
    400
    400
    400
    400
    400
    400
  > 400
    400
    400
    400
    400
    400
    400
    400
  > 400
    400
    400
    400
    400
    400
    400
    400
  > 400
    400
    400

It continues to print 400 until I unplug or reprogram it.

Offline eyemyth

  • Thread Starter
  • Posts: 4
  • Location: Austin, TX
Re: QMK, Teensy 3.2, and a Thinkpad keyboard
« Reply #4 on: Fri, 24 May 2019, 19:16:39 »

So, I figured out where that random input was coming from: the mouse/ps2 pins. I took out all of the mouse code and got the keyboard working 100%, so that's exciting.


But, for this thing to replace my ****ty Lenovo USB Keyboard w/ trackpoint, I'm going to need the trackpoint to work. I at least need the buttons to work, since I usually use a trackpad to move the mouse with my right hand, and click with my left.


This issue on QMK explores support for a trackpad using a Proton C, which is also ARM based but I don't think it uses ChibiOS. I tried using the fork there anyway, but as I said that's where the weird output came in.


Are there any QMK/ARM/ChibiOS pointing devices out there at all?