Narsil / rdev

Simple library to listen and send events to keyboard and mouse (MacOS, Windows, Linux)
MIT License
528 stars 131 forks source link

Why get shift state when getting code name #94

Open fufesou opened 1 year ago

fufesou commented 1 year ago

https://github.com/Narsil/rdev/blob/f4d847620bd94f6758042f8daf63e16491d92fb9/src/windows/keyboard.rs#L50

Hi, I'm confused why get shift state is needed here. If I comment out this line, the bug is fixed https://github.com/rustdesk/rustdesk/issues/2670. And there seems no other side effects.

Just run grab in examples to reproduce this issue.

Narsil commented 1 year ago

Ohh I don't remember. Windows API is just weird sometimes, and some which seems innocuous does modify next results.

It might be removable, I don't have the specifics in mind.

fufesou commented 1 year ago

Thanks. I've commented out the line in my fork. If something is wrong, I'll reply here.

Please just let this issue open. Maybe someone can reply here.

fufesou commented 1 year ago

Windows API is just weird sometimes, and some which seems innocuous does modify next results.

Yes, it's wired.

https://stackoverflow.com/questions/45719020/winapi-getkeyboardstate-behavior-modified-by-getkeystate-when-application-is-out As it says

However, if GetKeyState(aVKCode) is called immediately prior to GetKeyboardState(aByteArray), for any value of aVKCode, even if the return value is discarded, then GetKeyboardState(aByteArray) will provide the correct non-zero state of the held SHIFT key when the application is not in focus.

But if GetKeyState(aVKCode) is called immediately prior to GetKeyboardState(aByteArray), some accents cannot be typed correctly. As if Shift is not pressed. When grabbing keyboard, local input in some other windows:

        error        Keybaord Layout
ö turns out ô  French
ö turns out o  Portuguese(Brazil)
ô turns out õ  Portuguese(Brazil)
ò turns out ó  Portuguese(Brazil)
Narsil commented 1 year ago

Welcome to windows !

And thanks for digging that up. I have no idea if a solution is at all imaginable then.

Elendiar commented 1 month ago

Get a problem in windows where the input from the scanner changes, e.g. program always read correct barcode tLds6pDr, but input into notepad (or another progam) is unstable tLdS6pDr, tlds6pDr or tLds^PDr, as if with the shift key pressed. Is it possible at least allow disable this check in builder? This makes it impossible to use (