Scroll flick to single keypress/layer change?

Hello, I would like to change my horizontal scroll wheel to toggle a scroll layer where flicking it up turns it on and flicking it down turns it off.

Currently, I have it set to H Scroll -1 [Layer 0] = Layer 1 (Sticky) and H Scroll 1 [Layer 1] = Layer 1 (Tap)

This sorta works but if I flick and the scroll steps are an even count, it does nothing. Is there a way to do this with expressions?

You can do it with an expression like this:

/* H scroll: right = layer on, left = layer off, no movement = keep current state */
0x000c0238 input_state
0x000c0238 input_state 0 gt
1 recall
ifte
1 store

and mapping Register 1 to Layer 1.

Here’s a more detailed explanation from Claude:

https://claude.ai/share/48a7f293-9534-4db7-b444-f05641447f5a