Author Topic: TMK keyboard firmware  (Read 586320 times)

0 Members and 1 Guest are viewing this topic.

Offline Alectardy98

  • Posts: 16
  • Location: United States
  • Pre Dental
Re: TMK keyboard firmware
« Reply #2000 on: Tue, 05 January 2021, 17:30:31 »
I was able to make it work, but it might not be the cleanest. I am new to coding

Code: [Select]
bool my_led_status = 1;

hook_layer_change(uint32_t layer_state)
{
    if (my_led_status);

        if (layer_state & (1L<<1)) {
            // LED is off, so let's turn it on
            led_set(host_keyboard_leds() | (1<<USB_LED_NUM_LOCK));
            my_led_status = 1;
        } else {
            // LED is on, so let's turn it off
            led_set(host_keyboard_leds() & ~(1<<USB_LED_NUM_LOCK));
            my_led_status = 0;
           
     }
   
}


hook_keyboard_leds_change(uint8_t led_status)
{
    if (my_led_status)
            {
                // LED is off, so let's turn it on
                led_set(host_keyboard_leds() | (1<<USB_LED_NUM_LOCK));
                my_led_status = 1;
            }
            else
            {
                // LED is on, so let's turn it off
                led_set(host_keyboard_leds() & ~(1<<USB_LED_NUM_LOCK));
                my_led_status = 0;
            }
        }
   
hook_late_init(void)
{
if (my_led_status)

    {
        led_set(host_keyboard_leds() & ~(1<<USB_LED_NUM_LOCK));
        my_led_status = 0;
    }
}

Offline hasu

  • Thread Starter
  • Posts: 3199
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #2001 on: Tue, 05 January 2021, 21:04:04 »
Looks good enough.
I think you don't need 'hook_late_init'.

Code: [Select]
#include "host.h"
#include "led.h"
bool my_led_status = 0;

void hook_layer_change(uint32_t layer_state)
{
    if (layer_state & (1L<<1)) {
        // LED is off, so let's turn it on
        led_set(host_keyboard_leds() | (1<<USB_LED_NUM_LOCK));
        my_led_status = 1;
    } else {
        // LED is on, so let's turn it off
        led_set(host_keyboard_leds() & ~(1<<USB_LED_NUM_LOCK));
        my_led_status = 0;
    }
}


void hook_keyboard_leds_change(uint8_t led_status)
{
    if (my_led_status)
    {
        // LED is off, so let's turn it on
        led_set(host_keyboard_leds() | (1<<USB_LED_NUM_LOCK));
        my_led_status = 1;
    }
    else
    {
        // LED is on, so let's turn it off
        led_set(host_keyboard_leds() & ~(1<<USB_LED_NUM_LOCK));
        my_led_status = 0;
    }
}

If you care about initial state of indicators refer this issue.
https://github.com/tmk/tmk_keyboard/issues/665
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline hasu

  • Thread Starter
  • Posts: 3199
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #2002 on: Fri, 29 January 2021, 08:07:05 »
casualdehid,
T0 and Lt0 doesn't work as you expected.
These actions are confusing and make no sense for users. I'll look into them to improve the TOGGLE behaviour but it will take some time.

You can use ACTION_LAYER_SET_CLEAR(0) instead of T0, this aciton disables all layers except for layer 0 at once.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md#229-set-layer

But the action is not supported well in Keymap Editor yet, you have to edit the action with 'Code Edit' tab.
Check the action on Layer 3.
https://bit.ly/2MeJZZg

There is no alternative to Lt0 at this time.


OK. Lets start discussing that layer switching.
I'd like to check if layer switch problem on your keymap is specific to 'power key'.
Share your keymap URL using 'URL Shortener' button on Keymap editor or you can just attach hex file here.
I filmed my issue:
(Attachment Link)

TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline casualdehid

  • Posts: 31
  • Location: Hungary
Re: TMK keyboard firmware
« Reply #2003 on: Mon, 01 February 2021, 16:15:40 »
For now, I'm using Power On as an improvised Fn layer 2 button (5x to toggle, press and hold for switch), and Esc as ESC+Layer 1 on hold on my M0118.
M0116, Model M, AEK II

Offline casualdehid

  • Posts: 31
  • Location: Hungary
Re: TMK keyboard firmware
« Reply #2004 on: Tue, 02 February 2021, 07:08:53 »
For now, I'm using Power On as an improvised Fn layer 2 button (5x to toggle, press and hold for switch), and Esc as ESC+Layer 1 on hold on my M0118.
Hi there
I've been using my M0118 since yesterday, and decided on two different firmwares for the two keyboards (M0118 and AEKII). However, I noticed that I have problems with multifunction buttons (action_layer_tap_key specifically) being slow for key combinations. For example: I have LT3/grave on my escape, and when I want to hit F5, i have to switch to layer 3 to do so. And it's a key combination i press frequently and very fast, I usually get 05 into my code instead of F5, because it won't switch in time, because I'm not holding it down for enough time. Is there a way to turn on "0 delay" on key combinations in the firmware? I think a few people would have problems with this, because for them it'd switch layers when they only wanted a key combination on the current layer, without switching. Maybe I'm askint a bit too much with this question. Sorry guys in advance.
M0116, Model M, AEK II

Offline hasu

  • Thread Starter
  • Posts: 3199
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK keyboard firmware
« Reply #2005 on: Wed, 03 February 2021, 08:24:16 »
This has no "0 delay" support. With that configuration you won't be able to type '05' quickly.

You can change behavior of 'tap key' with TAPPING_TERM somewhat, btw.
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#tap-keydual-role-key-doesnt-work-for-me
TMK products:HHKB Alt  ⌨ConvertersAlps64FC660C AltFC980C Alt

Offline casualdehid

  • Posts: 31
  • Location: Hungary
Re: TMK keyboard firmware
« Reply #2006 on: Wed, 03 February 2021, 12:01:53 »
This has no "0 delay" support. With that configuration you won't be able to type '05' quickly.

You can change behavior of 'tap key' with TAPPING_TERM somewhat, btw.
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#tap-keydual-role-key-doesnt-work-for-me

I have the exact opposite problem, it outputs 05 instead of F5  :))
But this will definietly help on my problems.
Thanks again!
M0116, Model M, AEK II