Help with the source code - Key Down Evets

Hello !

I´ve posted the same message on “Issues” in GitHub.

I’m trying to detect only the KeyDown events in a Keyboard, so I can count how much keys a user has pressed during a session. I’ll show the variable in an oled display.
I’ve tryied to work around de main() function and the on board led status. But, it counts twice events (Down and Up).

Can someone help me to identify where, in the source code I can find this event ?

Thank you !

This protocol doesn’t have a concept of key down or key up events, it just sends the whole state, every button is either pressed or not. So you have to look at the previous state. If the key was not pressed in the previous state and is pressed in the current one, this is your “key down event”.

Hi Jacek !

Thank you for you fast reply.

I was thinking on making the mod inside the void monitor_read_input_range in remapper.cc (line 1598)

. . . .
uint32_t actual_usage = source_usage + bits - their_usage.logical_minimum;
// for array range inputs, “key-up” events (value=0) don’t show up in the monitor
if (monitor_enabled && ((actual_usage & 0xFFFF) != 0)) { // HERE
monitor_usage(actual_usage, 1, hub_port);
}
. . . .

Sorry for the extremely basic doubts.
I have already tryied to make a bridge by Myself, using Arduino IDE, Pico-sdk, Pic-Pio, TinyUSB.
It works for about 2 or 3 minutes and the firmware hangs. Everything I’ve tryied, did no work.
So, I’ve found you project. Way more complex, but very stable !