Author Topic: TMK keyboard firmware  (Read 819947 times)

0 Members and 1 Guest are viewing this topic.

Offline clickclack123

  • Posts: 357
  • Location: Australia, Mate!
Re: TMK keyboard firmware
« Reply #350 on: Thu, 03 April 2014, 17:40:50 »
Thanks guys!  Starting with your links I eventually found this:

https://en.wikipedia.org/wiki/Bit_manipulation
It has a pretty clear explanation of |= and &= in the last section.

And sorry about the big question dump.  It just felt like the questions all flowed together...I'll try a few things and post back here if I still have questions.

I just edited my previous answer with an explanation of how I understand the LED code works.

I assume that an expert will correct me if I've made any mistakes.

Offline sean4star

  • Posts: 59
  • Location: Arlington, TX
Re: TMK keyboard firmware
« Reply #351 on: Fri, 04 April 2014, 00:12:51 »
Thanks!  I also found this:
http://www.pjrc.com/teensy/pins.html

I was able to get the LED's for CAPS and NUM Lock to work.  For some reason Scroll Lock is being stubborn and won't work even though I'm setting it up the same as the others...

Backlight is also working now too!  It helps knowing that my config file needed BACKLIGHT_ENABLE.  The template file I used didn't have this in it to start with so I didn't know it was an option...Once I added that it finally started to work.


I created my own ACTION_FUNCTION_TAP key to hijack the backlight.  Now, when I toggle on my Fn layer it also toggles on the backlight LED, so it's acting like an indicator!  I love this firmware.  You can make it do just about anything!

Offline Melvang

  • Exquisite Lord of Bumfluff
  • * Maker
  • Posts: 4398
  • Location: Waterloo, IA
  • Melvang's Desktop Customs
Re: TMK keyboard firmware
« Reply #352 on: Fri, 04 April 2014, 00:30:33 »
Now if I could get mine to work.  Don't want to muddle this thread up with tons of newbie questions and such so I will post a link to my thread.

http://geekhack.org/index.php?topic=56751.0
OG Kishsaver, Razer Orbweaver clears and reds with blue LEDs, and Razer Naga Epic.   "Great minds crawl in the same sewer"  Uncle Rich

Offline zeroni13

  • Posts: 97
  • Location: Oslo, Norway
Re: TMK keyboard firmware
« Reply #353 on: Fri, 04 April 2014, 01:49:21 »
When i found out that I only had 6KRO I figured out that I could just do
Code: [Select]
bool keyboard_nkro = true; in "host.c" and it worked, but i see now that I can enable it with Magic + N. What key is the Magic key? Is it something that is predefined or is it something that you define yourself? How do i use this Magic key?

Edit:

So i found this:
Code: [Select]
/* key combination for command */
#define IS_COMMAND() ( \
    keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)

#endif

That means that I have to press LSHIFT and RSHIFT at the same time to activate the magic key?
So if I want to enable NKRO I have to press LSHIFT + RSHIFT + N is that right?
« Last Edit: Fri, 04 April 2014, 02:56:37 by zeroni13 »
Phantom with Silver Vortex Case   Keychron Q6 Pro ISO Knob
                               

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #354 on: Fri, 04 April 2014, 04:31:12 »

Offline zeroni13

  • Posts: 97
  • Location: Oslo, Norway
Re: TMK keyboard firmware
« Reply #355 on: Fri, 04 April 2014, 05:10:29 »
So if I change it to be:

Code: [Select]
keyboard_report->mods == (MOD_BIT(KC_HOME) | MOD_BIT(KC_PGUP)) \
It would allow me to use HOME + PGUP as Magic?

Edit:
Magic works with LSHIFT and RSHIFT, When i change it to HOME + PGUP it doesn't work.
Maybe I should wait until i actually mount my keyswitches so I can properly puch the buttons.
« Last Edit: Fri, 04 April 2014, 14:30:07 by zeroni13 »
Phantom with Silver Vortex Case   Keychron Q6 Pro ISO Knob
                               

Offline wuqe

  • Posts: 105
  • Location: WA, USA
Re: TMK keyboard firmware
« Reply #356 on: Fri, 04 April 2014, 16:10:20 »
The mods in that code snippet need to actually be mods, i.e. Ctrl, Alt, Shift, or Gui keys. Pick any combination. :)

Offline zeroni13

  • Posts: 97
  • Location: Oslo, Norway
Re: TMK keyboard firmware
« Reply #357 on: Sat, 05 April 2014, 05:43:29 »
The mods in that code snippet need to actually be mods, i.e. Ctrl, Alt, Shift, or Gui keys. Pick any combination. :)
Wow, that actually makes much more sense now.
It works now, thanks!

Any way to use other keys?
« Last Edit: Sat, 05 April 2014, 05:54:56 by zeroni13 »
Phantom with Silver Vortex Case   Keychron Q6 Pro ISO Knob
                               

Offline plainbriny

  • Posts: 192
  • Location: Taiwan
Re: TMK keyboard firmware
« Reply #358 on: Sat, 05 April 2014, 06:08:20 »
Don't know whether this would work, but maybe you can try
Code: [Select]
ACTION_MODS_TAP_KEY(MOD_RSFT, KC_GRV);
This will make the grave key (`) work as right shift.

I think it may be even possible to use something like this:
Code: [Select]
ACTION_MODS_TAP_KEY(MOD_RSFT | MOD_LSFT, KC_HOME);
To send both right and left shift when you hold HOME.

However, I didn't try these myself, don't know whether they will work as expected.

https://github.com/tmk/tmk_keyboard/blob/master/doc/keymap.md

Offline abjr

  • Posts: 171
  • Location: Connecticut
    • abjr.org
Re: TMK keyboard firmware
« Reply #359 on: Mon, 07 April 2014, 13:04:32 »
I've wired up a really tiny keyboard on a breadboard and am trying to see if I can have 4 layers with only 2 function keys. I'm not sure if I missed it in the documentation somewhere, but is it possible to do something like this?

none         -> layer 0 (default)
Fn0           -> layer 1
Fn1           -> layer 2
Fn0 & Fn1 -> layer 3

Thanks.
CM QFR | magicforce 68 (Gateron) | magicforce 68 (Outemu) | Acros 6311-K

Offline zeroni13

  • Posts: 97
  • Location: Oslo, Norway
Re: TMK keyboard firmware
« Reply #360 on: Mon, 07 April 2014, 14:50:02 »
I'm having some troubles here, my FN2 button is not activating the layer. FN2 activates layer 3 right?

So if I have 4 layers (0-3) and I want to activate the media keys in layer 3 I need to use FN2 right?

Here is my keymap_iso.h : https://drive.google.com/file/d/0B0Hi55n4CaCKdjMydWdwcFlmcXc

Edit: Got it working using FN0, but I'm kinda confused now, why does this work? o.o
« Last Edit: Mon, 07 April 2014, 14:54:28 by zeroni13 »
Phantom with Silver Vortex Case   Keychron Q6 Pro ISO Knob
                               

Offline wuqe

  • Posts: 105
  • Location: WA, USA
Re: TMK keyboard firmware
« Reply #361 on: Mon, 07 April 2014, 15:09:52 »
So, in this code...

static const uint16_t PROGMEM fn_actions[] = {
    ACTION_LAYER_MOMENTARY(3),               // FN2
};


fn_actions[] is really just an array, and the first item is number zero. Even though you have a comment saying FN2, that first item is still FN0: the compiler doesn't even read that comment. If you move the actions around in the list, you need to update the comments accordingly, for your own sanity!

Offline DamienG

  • Posts: 315
  • Location: Redmond, WA
    • DamienG
Re: TMK keyboard firmware
« Reply #362 on: Mon, 07 April 2014, 15:11:57 »
Here's my TMK that I branched to add a few new features:
  • ISO layout with extra TKL keys and moved arrows.
  • FN-held layer for secondary media key functions and right menu context
  • FN-toggle layer for numeric keypad out of TKL area
  • FN-toggle layer for disabling ` key (stops you hitting it in BF3/4 by mistake)
https://github.com/damieng/tmk_keyboard/commits/master

[)amien

Offline zeroni13

  • Posts: 97
  • Location: Oslo, Norway
Re: TMK keyboard firmware
« Reply #363 on: Mon, 07 April 2014, 15:34:03 »
So, in this code...

static const uint16_t PROGMEM fn_actions[] = {
    ACTION_LAYER_MOMENTARY(3),               // FN2
};


fn_actions[] is really just an array, and the first item is number zero. Even though you have a comment saying FN2, that first item is still FN0: the compiler doesn't even read that comment. If you move the actions around in the list, you need to update the comments accordingly, for your own sanity!
Yeah, yeah, I know the comment's doesn't do anything. My first guess on how it worked was actually what you said, I just wanted to confirm it.
And thank you for reminding me of that comment, totally forgot to change that, haha.
Phantom with Silver Vortex Case   Keychron Q6 Pro ISO Knob
                               

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #364 on: Mon, 07 April 2014, 20:32:52 »
I've wired up a really tiny keyboard on a breadboard and am trying to see if I can have 4 layers with only 2 function keys. I'm not sure if I missed it in the documentation somewhere, but is it possible to do something like this?

none         -> layer 0 (default)
Fn0           -> layer 1
Fn1           -> layer 2
Fn0 & Fn1 -> layer 3

Thanks.



abjr, yes it is possible.

In fact you can define five layers.
none: layer0
KeyA: layer1
KeyB: layer2
KeyA+B: layer3
KeyB+A: layer4



In tmk layer action is essentially a bit operation of 'layer_state' variable. Each layer has own bit in the variable and it indicates current state of the layer. For example:

Code: [Select]
Layer   Layer bit
---------------------------------
L0      000x   (default layer)
L1      001x
L2      01xx
L3      1xxx
0: off, 1: on, x: dont' care

See action_layer.c, action_code.h and action.c in common directory if documentation is not enough.

Apparently key has down and up event but note that these evnents do not necessarily occur in same layer. In particular 'layer switcing' key will have down and up envent on different layers.


You can define your keymap in following four ways at least. Each way has a bit different behavior, so you may want to select and combinate them.

1) you can define like this:
Code: [Select]
       |KeyA                |KeyB
Layer  |Down    Up          |Down   Up
-------+--------------------+--------------------
L0     |L1_on   N/A         |L2_on  N/A
L1     |N/A     L1_off      |L3_on  N/A
L2     |L4_on   N/A         |N/A    L2_off
L3     |N/A     L1_off      |N/A    L3_off
L4     |N/A     L4_off      |N/A    L2_off

Fn      Press   Relese      Action
---------------------------------------------------------------
FN0     L1_on   ---         ACTION_LAYER_ON(1, ON_PRESS)
FN1     L2_on   ---         ACTION_LAYER_ON(2, ON_PRESS)
FN2     L3_on   ---         ACTION_LAYER_ON(3, ON_PRESS)
FN3     L4_on   ---         ACTION_LAYER_ON(4, ON_PRESS)
FN4     ---     L1_off      ACTION_LAYER_OFF(1, ON_RELESE)
FN5     ---     L2_off      ACTION_LAYER_OFF(2, ON_RELESE)
FN6     ---     L3_off      ACTION_LAYER_OFF(3, ON_RELESE)
FN7     ---     L4_off      ACTION_LAYER_OFF(4, ON_RELESE)

Keymap          KeyA    KeyB
----------------------------
KEYMAP_L0:      FN0     FN1
KEYMAP_L1:      FN4     FN2
KEYMAP_L2:      FN3     FN5
KEYMAP_L3:      FN4     FN6
KEYMAP_L4:      FN7     FN5



2) Using ACTION_LAYER_ON_OFF you will be able to omit some Fn keys.
Code: [Select]
Fn      Press   Relese      Action
---------------------------------------------------------------
FN0     L1_on   L1_off      ACTION_LAYER_ON_OFF(1)
FN1     L2_on   L2_off      ACTION_LAYER_ON_OFF(2)
FN2     L3_on   L3_off      ACTION_LAYER_ON_OFF(3)
FN3     L4_on   L4_off      ACTION_LAYER_ON_OFF(4)

Keymap          KeyA    KeyB
----------------------------
KEYMAP_L0:      FN0     FN1
KEYMAP_L1:      FN0     FN2
KEYMAP_L2:      FN3     FN1
KEYMAP_L3:      FN0     FN2
KEYMAP_L4:      FN3     FN1


3) Or using ACTION_LAYER_SET you can define layer transition table instead of bit operation.
Code: [Select]
       |KeyA                |KeyB
Layer  |Down    Up          |Down   Up
-------+--------------------+--------------------
L0     |to_L1   N/A         |to_L2  N/A
L1     |N/A     to_L0       |to_L3  N/A
L2     |to_L3   N/A         |N/A    to_L0
L3     |N/A     to_L2       |N/A    to_L1


Fn      Press   Relese      Action
---------------------------------------------------------------
FN0     to_L1               ACTION_LAYER_SET(1, ON_PRESS)
FN1     to_L2               ACTION_LAYER_SET(2, ON_PRESS)
FN2     to_L3               ACTION_LAYER_SET(3, ON_PRESS)
FN3     ---     to_L0       ACTION_LAYER_SET(0, ON_RELESE)
FN4     ---     to_L1       ACTION_LAYER_SET(1, ON_RELESE)
FN5     ---     to_L2       ACTION_LAYER_SET(2, ON_RELESE)

Keymap          KeyA    KeyB
----------------------------
KEYMAP_L0:      FN0     FN1
KEYMAP_L1:      FN3     FN2
KEYMAP_L2:      FN2     FN3
KEYMAP_L3:      FN5     FN4

4) Also you can use ACTION_LAYER_SET_CLEAR
Code: [Select]
       |KeyA                |KeyB
Layer  |Down    Up          |Down   Up
-------+--------------------+--------------------
L0     |to_L1   N/A         |to_L2  N/A 
L1     |N/A     to_L0       |to_L3  N/A 
L2     |to_L3   N/A         |N/A    to_L0
L3     |N/A     to_L0       |N/A    to_L0


Fn      Press   Relese      Action
---------------------------------------------------------------
FN0     to_L1   to_L0       ACTION_LAYER_SET_CLEAR(1)
FN1     to_L2   to_L0       ACTION_LAYER_SET_CLEAR(2)
FN2     to_L3   to_L0       ACTION_LAYER_SET_CLEAR(3)


Keymap          KeyA    KeyB
----------------------------
KEYMAP_L0:      FN0     FN1
KEYMAP_L1:      FN0     FN2
KEYMAP_L2:      FN2     FN1
KEYMAP_L3:      FN2     FN2

Not tested but it should work.

Offline wuqe

  • Posts: 105
  • Location: WA, USA
Re: TMK keyboard firmware
« Reply #365 on: Mon, 07 April 2014, 21:20:52 »
Gee hasu, thanks! That there is a gold mine of layer-tinkering info. I did my similar functionality with ACTION_FUNCTION() and code behind it. The plus of doing it in code is that you can get by with just the one FNx action. The negative to it is complexity, and you have to mess with the layer_on() methods, which feels a little dangerous.  :aiee:

My relevant commit:

https://github.com/shayneholmes/tmk_keyboard/commit/5eaff58a11052bd6446825d59e195ae07efa5723

Offline clickclack123

  • Posts: 357
  • Location: Australia, Mate!
Re: TMK keyboard firmware
« Reply #366 on: Tue, 08 April 2014, 01:15:35 »
Wow! Talk about flexible (and complicated)!

That's five different ways to achieve the same layer-switching result!

Thanks hasu and wuqe.

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #367 on: Tue, 08 April 2014, 02:54:33 »
Haha, yes it is complicated and confusing but flexible.
This is really trade-off and we need good compromise :D



Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #368 on: Tue, 08 April 2014, 03:09:05 »
So, in this code...

static const uint16_t PROGMEM fn_actions[] = {
    ACTION_LAYER_MOMENTARY(3),               // FN2
};


fn_actions[] is really just an array, and the first item is number zero. Even though you have a comment saying FN2, that first item is still FN0: the compiler doesn't even read that comment. If you move the actions around in the list, you need to update the comments accordingly, for your own sanity!

Exactly.

Luckily we are using great GCC, so with taking advantage of its C language extenstion we can write like this instead of keeping comment updated.

static const uint16_t PROGMEM fn_actions[] = {
    [2] = ACTION_LAYER_MOMENTARY(3),
};


MAY GCC BE WITH YOU

Offline wuqe

  • Posts: 105
  • Location: WA, USA
Re: TMK keyboard firmware
« Reply #369 on: Tue, 08 April 2014, 09:39:15 »
So, in this code...

static const uint16_t PROGMEM fn_actions[] = {
    ACTION_LAYER_MOMENTARY(3),               // FN2
};


fn_actions[] is really just an array, and the first item is number zero. Even though you have a comment saying FN2, that first item is still FN0: the compiler doesn't even read that comment. If you move the actions around in the list, you need to update the comments accordingly, for your own sanity!

Exactly.

Luckily we are using great GCC, so with taking advantage of its C language extenstion we can write like this instead of keeping comment updated.

static const uint16_t PROGMEM fn_actions[] = {
    [2] = ACTION_LAYER_MOMENTARY(3),
};


MAY GCC BE WITH YOU

:jawdrop: Noice!

Offline abjr

  • Posts: 171
  • Location: Connecticut
    • abjr.org
Re: TMK keyboard firmware
« Reply #370 on: Tue, 08 April 2014, 10:01:59 »
abjr, yes it is possible.

Wow. Thank you for such a detailed explanation and such great firmware! Let's hope I can figure out how to implement at least one of those options :)

-abjr
CM QFR | magicforce 68 (Gateron) | magicforce 68 (Outemu) | Acros 6311-K

Offline Melvang

  • Exquisite Lord of Bumfluff
  • * Maker
  • Posts: 4398
  • Location: Waterloo, IA
  • Melvang's Desktop Customs
Re: TMK keyboard firmware
« Reply #371 on: Tue, 08 April 2014, 10:10:23 »
Any suggestions for getting this to compile on Windows 8.1?  Winavr seems to be broke on it.  I keep getting application failed to load error but when I compiled on the wifes computer with windows 7 it came out just fine.
OG Kishsaver, Razer Orbweaver clears and reds with blue LEDs, and Razer Naga Epic.   "Great minds crawl in the same sewer"  Uncle Rich

Offline wuqe

  • Posts: 105
  • Location: WA, USA
Re: TMK keyboard firmware
« Reply #372 on: Tue, 08 April 2014, 11:47:37 »
I have it running on Windows 8.1, using WinAVR-20100110; can't say for sure exactly how I got it that way, since I set it up almost a year ago. Nonetheless, it can work! :)

Without a specific error message, it's hard to guess, but my first instinct is .NET dependencies, since those don't always get installed out of the box.

Offline Melvang

  • Exquisite Lord of Bumfluff
  • * Maker
  • Posts: 4398
  • Location: Waterloo, IA
  • Melvang's Desktop Customs
Re: TMK keyboard firmware
« Reply #373 on: Tue, 08 April 2014, 11:55:39 »
When I go to the command prompt to make I get an error message that is a standard windows pop up error with number 0xc0000142 and something about the application failed to load.  I get the same issue with running cmd as admin.
OG Kishsaver, Razer Orbweaver clears and reds with blue LEDs, and Razer Naga Epic.   "Great minds crawl in the same sewer"  Uncle Rich

Offline wuqe

  • Posts: 105
  • Location: WA, USA
Re: TMK keyboard firmware
« Reply #374 on: Tue, 08 April 2014, 12:46:49 »
Hmm, the error code sounds familiar... :looking:

Aha!

http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=1113986

Links to http://www.madwizard.org/download/electronics/msys-1.0-vista64.zip, where you can get an updated msys.bin file. Copy it to C:\WinAVR-20100110\utils\bin, and presto!

I think this has to do with 64 bit Windows not playing nicely by default.
« Last Edit: Tue, 08 April 2014, 12:48:29 by wuqe »

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: TMK keyboard firmware
« Reply #375 on: Sun, 13 April 2014, 13:15:13 »
Hey Hasu, hopefully you can help me with this little issue.

I started with the normal keymap_hhkb.c and have been adding various features. I tried adding the parentheses dual role to the shift keys, so I copied code from your keymap_hasu.c file. After I compile the new code pressing the shift keys does make a "(" or ")" correctly, but I cannot write any shifted characters. Ex: Shift+a does nothing when it should make a capital "A".

I changed the shift keys to FN3 and FN4. Here is the relevant code:
http://ix.io/bEu

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #376 on: Sun, 13 April 2014, 13:44:41 »
Those macro and action_function implement same feature in two different methods for reference. So you need only either one of the two,  you can remove another.

That action_function has accidentaly temporary test code. This patch will fix your problem.
Code: [Select]
@@ -225,8 +253,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
             // NOTE: cant use register_code to avoid conflicting with magic key bind
             if (event.pressed) {
                 if (tap.count == 0 || tap.interrupted) {
-                    //add_mods(MOD_BIT(KC_LSHIFT));
-                    layer_on(1);
+                    add_mods(MOD_BIT(KC_LSHIFT));
                 } else {
                     add_mods(MOD_BIT(KC_LSHIFT));
                     add_key(KC_9);
@@ -237,8 +264,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
                 }
             } else {
                 if (tap.count == 0 || tap.interrupted) {
-                    //del_mods(MOD_BIT(KC_LSHIFT));
-                    layer_off(1);
+                    del_mods(MOD_BIT(KC_LSHIFT));
                 }
             }
             break;

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: TMK keyboard firmware
« Reply #377 on: Sun, 13 April 2014, 14:04:04 »
Thanks. That fixed it :)

Perhaps that should be fixed online?

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: TMK keyboard firmware
« Reply #378 on: Fri, 18 April 2014, 09:43:36 »
Thanks. That fixed it :)

Perhaps that should be fixed online?

After using this for a few days I noticed some strange things happening. Luckily I was able to figure out the cause.

I opened up a linux terminal and ran "xkbwatch". If I hold shift and then press a letter then the shift modifier remains on even after releasing the shift key. This causes lots of little annoyances like preventing me from scrolling in chromium or causing mouse clicks to select text. Once I tap the shift any key again then the modifier is cleared and everything works correctly. I'm sure this is due to some error in my implementation of the dual role shift keys you were helping me with earlier.

Edit: I'm not sure if this is the intended behavior but when holding down the shift key the shift modifier is not set until I press another key. After reading the SpaceFN guide I would think that after some time (ex: 500ms) it should be safe to say the key was not tapped and should instead do its held function.
« Last Edit: Fri, 18 April 2014, 18:31:30 by Smasher816 »

Offline eviltobz

  • Posts: 95
Re: TMK keyboard firmware
« Reply #379 on: Tue, 22 April 2014, 11:10:54 »
I've been trying the TMK firmware on my ErgoDox (with thanks to cub-uanic for his initial porting work) and have found an odd problem. With the keyboard (and a mouse) plugged into a simple usb hub then into one of the usb3 ports on my Macbook pro running Mavericks, it seems to be working pretty correctly with fancy things like the keyboard being able to wake the mac from sleeping and whatnot. However, when the usb hub is instead plugged into a usb3(ish) port on my belkin thunderbolt hub and into the mac, the keyboard will work fine until the mac sleeps, but then won't work at all until it is unplugged/replugged. The mouse on the same usb hub is fine, and being a laptop I can obviously wake the pooter with the built-in keyboard, but the dox is as dead as a dodo. With ic07's firmware the keyboard remains usable throughout multiple sleep cycles, but of course loses the TMK features that I was after like the ability to wake the mac itself, full media keys, NKRO etc.

Anyone else seen anything similar? Any ideas about what might be causing the problem or how to fix it?


Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #380 on: Tue, 22 April 2014, 13:39:59 »
what is "the pooter"?

Pull fixes of issue #114 and #115 from my repository at github and report the result.

Offline AKmalamute

  • HHKB Scrub
  • Posts: 837
  • Location: Western WA, USA
Re: TMK keyboard firmware
« Reply #381 on: Tue, 22 April 2014, 13:45:30 »
I'm afraid I can't help you directly, eviltobz, but I can say that it doesn't surprise me. The thunderbolt protocol is different than the USB, so what's going on it TMK's exact usage of the USB protocol is getting lost in the shuffle somehow. But IC07's code (or included libraries? Are you using LUFA or something else that's different between the two?) is doing something different about being a USB device, and the translating hub is better able to keep track of things attached.

 It might be a limitation of the hub, too. I have a USB hub that only works on first detection -- so if I add a keyboard or USB stick to it, it won't show up until I un, re -plug the hub itself regardless of how many times I re-plug my device into the hub.
</shrug>

HTH and good luck.

hasu: 'the pooter' is a phoenetic contraction of "the computer" -- he's typing what he's saying, and you (the reader) are supposed to guess correctly by saying it out loud and realizing "oh! that's what he said."
« Last Edit: Tue, 22 April 2014, 13:47:47 by AKmalamute »

HHKB-lite2, Dvorak user

Offline metalliqaz

  • * Maker
  • Posts: 4951
  • Location: the Making Stuff subforum
  • Leopold fanboy
Re: TMK keyboard firmware
« Reply #382 on: Tue, 22 April 2014, 13:50:45 »
I have run into strange stuff with my own work.  There seems to be a lot of variety in the USB support of various peripherals.  Who knows what assumptions were made, but exotic keyboards tend to confuse them.

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #383 on: Tue, 22 April 2014, 21:54:28 »
Smasher816,

That behaviour is intended but the result is not intended :D I'm not a user of that 'Shift/parenthesis' key so that code was almost untested in real typing.

Try this codelet. I think this is nearly what you want. Except for delay(TAPPIG_TERM) before registering Shift.(But I think it is not so problem for normal typing due to a 'trick') This is a limitation of current tmk's dual role key implementation.

Dual role key can be two variants, one whose main role is 'key' and sub role is 'modifier' and vice versa. Tmk's dual role key implementation is optimized for the former and my personal typing habits so that I can place the function on Space, Semicolon and Slash key. Meanwhile you want the latter, unfortunately tmk deosn't offer enough configuration option for you at this time.

Code: [Select]
        case LSHIFT_LPAREN:
            // LShft + tap '('
            if (event.pressed) {
                dprint("P: ");
                if (record->tap.count > 0) {
                    if (record->tap.interrupted) {
                        dprint("tap interrupted\n");
                        record->tap.count = 0;  // ad hoc: cancel tap
                        register_mods(MOD_BIT(KC_LSHIFT));
                    } else {
                        dprint("tap\n");
                        add_weak_mods(MOD_BIT(KC_LSHIFT));
                        send_keyboard_report();
                        register_code(KC_9);
                    }
                } else {
                    dprint("no tap\n");
                    register_mods(MOD_BIT(KC_LSHIFT));
                }   
            } else {
                dprint("R: ");
                if (record->tap.count > 0) {
                    dprint("tap\n");
                    del_weak_mods(MOD_BIT(KC_LSHIFT));
                    send_keyboard_report();
                    unregister_code(KC_9);
                } else {
                    dprint("no tap\n");
                    unregister_mods(MOD_BIT(KC_LSHIFT));
                }   
            }       
            break;
« Last Edit: Tue, 22 April 2014, 21:58:01 by hasu »

Offline eviltobz

  • Posts: 95
Re: TMK keyboard firmware
« Reply #384 on: Wed, 23 April 2014, 04:29:38 »
thanks hasu & AK, and apologies for confusing you with my abuse of language :)

@hasu - i'll give those fixes a go and see what happens.

@AK - and yup, ic07's firmware is based on PJRC, but hasu has said that LUFA is the preferred stack for TMK now. hmmm, mebe I should try compiling it back on the PJRC code as well and see if that has any effect too.

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: TMK keyboard firmware
« Reply #385 on: Wed, 23 April 2014, 17:28:54 »
Hasu,

That "codelet" works well. Tapping the shift key produces a parentheses and holding sets shift. Writing capital letters works fine and the shift modifier is removed correctly. The only issue I found is - if I tap shift a few times then hold it I will get (((((((((, but that's not too big of a deal and I don't think it will happen in actual use. Thanks for the help :)

Dual role key can be two variants, one whose main role is 'key' and sub role is 'modifier' and vice versa. Tmk's dual role key implementation is optimized for the former and my personal typing habits so that I can place the function on Space, Semicolon and Slash key. Meanwhile you want the latter, unfortunately tmk deosn't offer enough configuration option for you at this time.

Maybe I am confused but I don't see the big difference between the "two variants". Both produce a 'key' when tapped and a 'modifier' when held. Can the "Shift" key not be thought of as a main role "(" key that acts as "LSHIFT" when held? (Similar to the slash key producing a mod when held). Perhaps I don't understand how the main/sub role works and why shift cannot be thought of with a main role key, and sub role modifier.

Hopefully what I said makes some sense.

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #386 on: Wed, 23 April 2014, 19:00:49 »
Hasu,

That "codelet" works well. Tapping the shift key produces a parentheses and holding sets shift. Writing capital letters works fine and the shift modifier is removed correctly. The only issue I found is - if I tap shift a few times then hold it I will get (((((((((, but that's not too big of a deal and I don't think it will happen in actual use. Thanks for the help :)

It is what i call "tap and hold repeat" trick. Dual role key essentially can't have normal key repeat function. I usually need that trick and it is useful to me, but may not to others.
Fortunately you can remove this trick with changing the codelet.

And I found it yields unexpected '9' occasionally after repeat like '((((((((9'. You may need this fix; changes keyboard report order.
Code: [Select]
                dprint("R: ");
                if (record->tap.count > 0) {
                    dprint("tap\n");
*                   unregister_code(KC_9);
*                   del_weak_mods(MOD_BIT(KC_LSHIFT));
*                   send_keyboard_report();
                } else {


Quote
Dual role key can be two variants, one whose main role is 'key' and sub role is 'modifier' and vice versa. Tmk's dual role key implementation is optimized for the former and my personal typing habits so that I can place the function on Space, Semicolon and Slash key. Meanwhile you want the latter, unfortunately tmk deosn't offer enough configuration option for you at this time.

Maybe I am confused but I don't see the big difference between the "two variants". Both produce a 'key' when tapped and a 'modifier' when held. Can the "Shift" key not be thought of as a main role "(" key that acts as "LSHIFT" when held? (Similar to the slash key producing a mod when held). Perhaps I don't understand how the main/sub role works and why shift cannot be thought of with a main role key, and sub role modifier.

Hopefully what I said makes some sense.
You are right about general idea of  dual role key. But its implementation and optimization can be varied greately. This codelet is optimzed for mod(main)/key(sub) and you'll be frustrated if it is place on alpha key area. You'll ofetn get 'mod' instead of 'key' despite your intention.

Try to get '(z' *quickly*(like normal typing speed) with your LShift key, you'll get 'Z'. With your custom LShift key you have to press z key *after* releasing LShift key, while in normal typing people press 'z' key *before* releasing 'LShift' key. This is annoyning if you assume your LShift is key'(' intead of mod 'Shift'.

Dual role key is all of compromize and trade-off between 'key' and 'mod'. The two never be consistent with each other at the same time. Optimization is important and it depends on your typing habits.

Offline technomancy

  • Posts: 134
Re: TMK keyboard firmware
« Reply #387 on: Thu, 24 April 2014, 13:06:25 »
My apologies if this has been covered elsewhere (it's a long thread), but I wonder if you could explain the reasoning behind using three different ports for inputs along the columns. It also seems strange that you don't read from consecutive pins. Is there some rationale behind the pin layout used? It seems to jump around randomly.

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #388 on: Thu, 24 April 2014, 14:07:58 »
Not sure which keyobard you are talking about but the reason is probably the chip or teensy's pinout. See following pictures. Unfortunately pins are not completely consective.
Yes, consective pin usage is easier for programming if possible.


Offline eviltobz

  • Posts: 95
Re: TMK keyboard firmware
« Reply #389 on: Sun, 27 April 2014, 05:05:08 »
... TMK firmware ... ErgoDox ... thunderbolt hub ... sleep/wake ... dead keyboard ...

... Are you using LUFA or something else that's different between the two?...

Well, I've been able to stick the PJRC build of TMK on and whilst the keyboard still won't wake my mac from sleep mode, the keyboard will continue to work once it has been woken, so it's an improvement :)

I've not had a chance to try pulling hasu's suggested fixes yet to see if that makes a difference to either stack, but it is certainly far more usable now so I'm in less of a rush.

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #390 on: Mon, 28 April 2014, 03:05:59 »
eviltobz, if you are using PJRC stack, try this fix.
https://github.com/tmk/tmk_keyboard/issues/121

With this fix I can wake PC several times in a row. Not tested thouroughly but this fix may work for you.

Offline eviltobz

  • Posts: 95
Re: TMK keyboard firmware
« Reply #391 on: Mon, 28 April 2014, 03:31:10 »
Thanks hasu :) I'll try to crack open the code soon and see how those fixes all add up.

Offline eviltobz

  • Posts: 95
Re: TMK keyboard firmware
« Reply #392 on: Tue, 29 April 2014, 02:54:33 »
Well, I had a go with fix 121, and it did wake the mac back up :) but then the keyboard was completely dead for further typing. and moving my mouse (that's on the same hub) around made weird things happen too :(

I noticed that there are other things that have changed between the version of that file that I have and the current state of it when your fix was applied, so I'll have to spend a bit of time sorting out getting all your fixes & changes merged in so I can test it all properly.

Offline admiralvorian

  • Posts: 324
  • Location: United States
  • DIY
Re: TMK keyboard firmware
« Reply #393 on: Fri, 16 May 2014, 12:03:15 »
Hasu,

That "codelet" works well. Tapping the shift key produces a parentheses and holding sets shift. Writing capital letters works fine and the shift modifier is removed correctly. The only issue I found is - if I tap shift a few times then hold it I will get (((((((((, but that's not too big of a deal and I don't think it will happen in actual use. Thanks for the help :)

Dual role key can be two variants, one whose main role is 'key' and sub role is 'modifier' and vice versa. Tmk's dual role key implementation is optimized for the former and my personal typing habits so that I can place the function on Space, Semicolon and Slash key. Meanwhile you want the latter, unfortunately tmk deosn't offer enough configuration option for you at this time.

Maybe I am confused but I don't see the big difference between the "two variants". Both produce a 'key' when tapped and a 'modifier' when held. Can the "Shift" key not be thought of as a main role "(" key that acts as "LSHIFT" when held? (Similar to the slash key producing a mod when held). Perhaps I don't understand how the main/sub role works and why shift cannot be thought of with a main role key, and sub role modifier.

Hopefully what I said makes some sense.


How can I remove the tap-shift-( functionality completely and set the shift key to a standard LShift?
Darude Status:
☐ Not Sandstorm
☑ Sandstorm                                               wts wtt wtb

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: TMK keyboard firmware
« Reply #394 on: Fri, 16 May 2014, 13:27:04 »
How can I remove the tap-shift-( functionality completely and set the shift key to a standard LShift?

The stock HHKB layout does not have it. However, it's pretty easy to modify the layout.

Replace "FN5" to the left of the Z key with "LSFT". If the right shift is also modded then replace whatever "FN*" it is with "RSFT"

Offline admiralvorian

  • Posts: 324
  • Location: United States
  • DIY
Re: TMK keyboard firmware
« Reply #395 on: Fri, 16 May 2014, 16:38:47 »
I had to modify keymap_hasu.c making changes to keymap_hhkb didn't help, nor did making my own keymap
Darude Status:
☐ Not Sandstorm
☑ Sandstorm                                               wts wtt wtb

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #396 on: Fri, 16 May 2014, 18:36:38 »
You'll need 'make clean'  when you change 'KEYMAP' option.
Doing 'make clean` before build firmware is always a good habit if you are not sure about 'make' command and TMK build system.

https://github.com/tmk/tmk_keyboard/wiki/FAQ#do-make-clean-before-make

Offline Slavfot

  • Posts: 53
  • Location: Sweden
Re: TMK keyboard firmware
« Reply #397 on: Sun, 18 May 2014, 15:49:55 »
Hi, i have a phantom keyboard with tmk_firmware.
Is it possible to make the scroll lock led shine when i have layer 2 active?

Offline skebitz

  • Posts: 2
  • Location: Sweden
Re: TMK keyboard firmware
« Reply #398 on: Tue, 27 May 2014, 03:02:05 »
Hi Hasu! :)

First, thanks a bunch for the TMK firmware! I've been using it on my custom keyboard project. Once you get to know it a bit it's pretty easy peasy, and the documentation is really nice!

I've been using the mouse keys alot, which I really like. Been tweaking the settings some in common/mousekey.h, but it takes time to build and reflash for every tweak. Is it possible to bind keys to be able to tweak these parameters on the fly?

(I've tried ACL0, ACL1 and ACL3 but they don't seem to make any difference)

Offline hasu

  • Thread Starter
  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #399 on: Tue, 27 May 2014, 07:02:21 »
Hi,

I wrote some code for tweak mousekey parameters on the fly but it was not completed. Its interface is very primitive and parameters are not stored in eeprom.

If you built firmware with command and console feature, you can try this in  'hid_listen'.

To get help press magic+'h'. First enter console mode with magic+'c', then push 'm' to mousekey parameter tweak mode.  Select a parameter with number keys and change value with up, down, page up and down. EDIT: to quit the mode push 'q' or ESC twice.

Try changing parameter values and see cursor speed.

Code: [Select]
----- Command Help -----
c:      enter console mode
d:      toggle debug enable
x:      toggle matrix debug
k:      toggle keyboard debug
m:      toggle mouse debug
v:      print device version & info
t:      print timer count
s:      print status
e:      print eeprom config
n:      toggle NKRO
0/F10:  switch to Layer0
1/F1:   switch to Layer1
2/F2:   switch to Layer2
3/F3:   switch to Layer3
4/F4:   switch to Layer4
PScr:   power down/remote wake-up
Caps:   Lock Keyboard(Child Proof)
Paus:   jump to bootloader
                 
                 
----- Console Help -----
ESC/q:  quit     
m:      mousekey
                 
Enter Console Mode
C>               
                 
----- Mousekey Parameters Help -----
ESC/q:  quit     
1:      select mk_delay(*10ms)
2:      select mk_interval(ms)
3:      select mk_max_speed
4:      select mk_time_to_max
5:      select mk_wheel_max_speed
6:      select mk_wheel_time_to_max
p:      print prameters
d:      set default values
up:     increase prameters(+1)
down:   decrease prameters(-1)
pgup:   increase prameters(+10)
pgdown: decrease prameters(-10)
                 
speed = delta * max_speed * (repeat / time_to_max)
where delta: cursor=5, wheel=1
See http://en.wikipedia.org/wiki/Mouse_keys
                 
Enter Mousekey Console
M0>             
                 
----- Mousekey Parameters -----
1: mk_delay(*10ms): 30
2: mk_interval(ms): 50
3: mk_max_speed: 10
4: mk_time_to_max: 20
5: mk_wheel_max_speed: 8
6: mk_wheel_time_to_max: 40
M0> ????         
Quit Mousekey Console
C>               
Quit Console Mode

(While you hold ACL* key mouse cursor move with constant speed.)