Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<<Request>> long-press operation #60

Open
koyoko1127 opened this issue Feb 11, 2022 · 9 comments
Open

<<Request>> long-press operation #60

koyoko1127 opened this issue Feb 11, 2022 · 9 comments
Labels
enhancement New feature or request

Comments

@koyoko1127
Copy link

koyoko1127 commented Feb 11, 2022

I want to activate different key codes by long-press and short-press

It is an operation that is not found in a normal PC keyboard, but it is a popular operation in embedded systems.
It can be used for careful operations and infrequent operations.

Thank you for the wonderful environment for me!
画像 30

@yswallow
Copy link
Contributor

Although, it sends long-press keycode on UP after a long-press (not at the set time),

kbd.define_mode_key :SHORT_A_LONG_1, [ Proc.new { kbd.send_key(:KC_A) }, Proc.new { kbd.send_key(:KC_1) }, 500, nil ]

is not enough?

@koyoko1127
Copy link
Author

koyoko1127 commented Feb 11, 2022

Wow It's almost working!!

In my behavior, the keycode is entered with Long-press set time (500). (Not key UP)
And, If the Long press time is set to 2000, key omissions will occur in continuous operations.
(short -> long -> short -> long ......)
I think the cause is that the timer has not been reset.

Thanks > yswallow

@hasumikin
Copy link
Member

Keyboard#define_mode_key was basically designed to combine a normal key and modifier/layer hold key.
Maybe I should implement a new feature to fulfill @koyoko1127's request.
Let me think how to realize that because I'm personally excited that PRK Firmware will possibly be used in prototyping a real product 💪

@hasumikin hasumikin added the enhancement New feature or request label Feb 13, 2022
@hasumikin
Copy link
Member

hasumikin commented Apr 15, 2022

Now I'm thinking of a feature as "Triple function key" like this:

Behavior model example

                :KC_0
                |
     +----------+
press^          ^release (< 300ms)

                            :KC_1
                      |     |
     +----------------+-----+
press^                |     ^release (between 300ms and 2000ms)
                      |
                      |                   :KC_2(just once)
                      |                   |
                      |                   |       Nothing happens (resets timer internally)
                      |                   |       |
     +----------------+-------------------+-------+
press^                |                   |       ^release (2000ms <)
                      |                   |
     +================+===================+=================
     |                |                   |
     0ms              300ms               2000ms

Namely, three different behaviors are articulated by two threshold values.

In keymap.rb

kbd.add_layer :default, %i(BUTTON KC_ENTER KC_SPACE KC_BSPACE) # meishi keypad for example

Then,

kbd.define_triple_function_key :BUTTON, :KC_0, 300, :KC_1, 2000, :KC_2

If you don't want the "second release key" to happen:

kbd.define_triple_function_key :BUTTON, :KC_0, 300, :KC_NO, 2000, :KC_2

If you don't want the "long press key" to happen:

kbd.define_triple_function_key :BUTTON, :KC_0, 300, :KC_1, 2000, :KC_NO

Each keycode can be an Array of Symbol or a Proc for example:

kbd.define_triple_function_key :BUTTON, :KC_0, 300, [:KC_LSFT, :KC_A], 2000, Proc.new { kbd.macro "Long!" }

@koyoko1127 Tell me what do you think

@koyoko1127
Copy link
Author

Thank you for your aggressive suggestions.
If you are aiming for a multifunctional long press operation, you need to think about the context of use.
I have 4 stories(See figure below)
I think this includes Hi-dynamic range operations with repeat motion. Set the repeat interval time or set nil.

image
image

@hasumikin
Copy link
Member

hasumikin commented Apr 17, 2022

@koyoko1127

[a]      [A]      KC_NO      0

This is not a case this feature should cover because...

kbd.define_triple_function_key :BUTTON_A, :KC_A, 300, [:KC_LSFT, :KC_A], nil, nil
kbd.define_triple_function_key :BUTTON_B, :KC_B, 300, [:KC_LSFT, :KC_B], nil, nil
kbd.define_triple_function_key :BUTTON_C, :KC_C, 300, [:KC_LSFT, :KC_C], nil, nil
kbd.define_triple_function_key :BUTTON_D, :KC_D, 300, [:KC_LSFT, :KC_D], nil, nil
kbd.define_triple_function_key :BUTTON_E, :KC_E, 300, [:KC_LSFT, :KC_E], nil, nil
kbd.define_triple_function_key :BUTTON_F, :KC_F, 300, [:KC_LSFT, :KC_F], nil, nil
kbd.define_triple_function_key :BUTTON_G, :KC_G, 300, [:KC_LSFT, :KC_G], nil, nil
(...)

Nobody wants to write such a verbose code, right?
(Of course you can do it. But it's not meant to be done)

BTW, could you tell me more about "Hi-dynamic range operations"? I don't know it.

@hasumikin
Copy link
Member

Ah, but, you may be able to write like this, lol

("A".."Z").each do |c|
  kbd.define_triple_function_key "BUTTON_#{c}".to_sym, "KC_#{c}".to_sym, 300, [:KC_LSFT, "KC_#{c}".to_sym], nil, nil
end

Evil Ruby...

@koyoko1127
Copy link
Author

@hasumikin

I don't know what " Hi-dynamic range operations " is officially called.

For example, when searching for an arbitrary value from 0 to 1000.
If you have a wide range of values ​​and want to set them in detail, you need both micro motion and coarse motion.

micro motion (微動) ==> 0,1,2,3,4,....1000
coarse motion(粗動) ==> 0.20,40,60,80,.....1000 *It is better to have a repeat in the long-press

From now on, we need to control high resolution and large (long) size data in photo, CAD, and video.
Using multiple inputs with one key, I prototype an embedded product.

Thanks

@hasumikin
Copy link
Member

@koyoko1127
Understood, thanks!
Let me think for a while

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants