localcc / hid_listener

Keyboard/Mouse event listener library for flutter
MIT License
9 stars 6 forks source link

Program crashes when Capslock/language change pressed. #13

Open asipo opened 6 months ago

asipo commented 6 months ago

I am trying hid_listener 2.0.1 to get keyboard/mouse event on my flutter app. Anroid Studio, Mac Air M1

Following the instruction on the website,

Any idea why this happens?

localcc commented 6 months ago

Are there any logs appearing right before the crash, or does it just quit silently?

asipo commented 6 months ago

It just says: Lost connection to device. the Dart compiler exited unexpectedly.

That's all..

localcc commented 6 months ago

The app is not running on android right? Also which Mac OS version are you on?

asipo commented 5 months ago

Thank you for your prompt reply.

macOS is Sonoma 14.1.2

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel master, 3.18.0-19.0.pre.95, on macOS 14.1.2 23B92 darwin-arm64, locale ko) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.0.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.3) [✓] Connected device (2 available) [✓] Network resources

• No issues found!

Launching lib/main.dart on macOS in debug mode... Building macOS application... --- xcodebuild: WARNING: Using the first of multiple matching destinations: { platform:macOS, arch:arm64, id:00008103-001550321E8A001E } { platform:macOS, arch:x86_64, id:00008103-001550321E8A001E } Debug service listening on ws://127.0.0.1:49615/P3BocaPNyg4=/ws Syncing files to device macOS... flutter: not null flutter: initialization listener backend success [GETX] Instance "GetMaterialController" has been created [GETX] Instance "GetMaterialController" has been initialized 2024-01-08 13:30:54.088 knkbuilder[1869:20346] WARNING: Secure coding is automatically enabled for restorable state! However, not on all supported macOS versions of this application. Opt-in to secure coding explicitly by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState:. Lost connection to device. the Dart compiler exited unexpectedly.

This happens even when I just include getListenerBackend()!.initialize() without adding listener.

localcc commented 5 months ago

Could you try and see if this issue occurs on the nsevent_queue branch?

asipo commented 5 months ago

That's beyond my programming ability. Actually, this is my first program to work on macOS, migrating windows C# code to flutter. It doesn't look like a simple problem, requires digging into OS related stuff.

I appreciate your kind support, but I better find another way.

asipo commented 5 months ago

When I tested the example code, the program crashes with the output, (the listener event handler in your code is void listener(RawKeyEvent event) { print( "${event is RawKeyDownEvent} ${event.logicalKey.debugName} ${event.isShiftPressed} ${event.isAltPressed} ${event.isControlPressed}"); } ) .. flutter: 1121.01953125, 1340.58203125 flutter: false Audio Volume Up false false false flutter: false Audio Volume Up false false false Lost connection to device. the Dart compiler exited unexpectedly.

When I press Audio Volume Up key, the output is flutter: true Audio Volume Up false false false flutter: false Audio Volume Up false false false

When I close the window, the output is flutter: false Audio Volume Up false false false flutter: 806.734375, 1607.078125 flutter: false Audio Volume Up false false false

I also tested RawKeyUpEvent instead of RawKeyDownEvent. So it seems that when the program exits, or capslock pressed, the key up event of Audio Volume Up occurs twice in a row without key down event.

Do you have any idea for this?