Comments (4)
Hi,
For minimal wait, you can create and use one instance of KeyBounding for all input.
More information why the library need wait in this link : https://www.kernel.org/doc/html/latest/input/uinput.html#keyboard-events
Extract of link :
/*
* On UI_DEV_CREATE the kernel will create the device node for this
* device. We are inserting a pause here so that userspace has time
* to detect, initialize the new device, and can start listening to
* the event, otherwise it will not notice the event we are about
* to send. This pause is only needed in our example code!
*/
sleep(1);
Best regard
from keybd_event.
Sorry but I didn't get it.
In your code you have this comment: `// For linux, it is very important to wait 2 seconds'.
I'm not questioning the delay, but thinking about the best place to put it. For example if someone forgot to use that delay, or originally developed something for a different platform (thus removed the delay) and then wanted to include Linux again, but forget to put it back.
Then, adding the delay inside that include file that's exclusive for Linux could be safer in my opinion. You can even use an env var with a default of 2sec, so if someone simply didn't specified it, will get the 2 secs..
Just a suggestion.
from keybd_event.
Okay, I get it!
If I add the delay in NewKeyBonding()
, there would be a risk that someone would try to put NewKeyBonding()
in a thread to avoid the delay on Linux or not understand the behaviour. If the user of the library chooses and introduces the delay himself, that guarantees that the person adding it will do it when and where he wants, being aware of its necessity.
In your example, the library user might not understand why his application reacts so slowly on Linux. Let's imagine he uses 30 libraries, and with each one using 5 libraries... :).
The 2 seconds or even 1 second is not negligible as a delay in an application. That's why I used this way.
To avoid this problem, it necessary to write a code that is thread-safety. With Coroutines and Channels.
from keybd_event.
ok. makes sense. Thanks dude π
from keybd_event.
Related Issues (20)
- Using this module on windows fucks up Razer keyboards. HOT 2
- Hold button functionality
- Remote SSH Connections... HOT 2
- High latency on MacOS
- VK_CAPSLOCK is invalid HOT 3
- Question/Bug - Setting the same key twice only outputs once HOT 1
- checksum mismatch HOT 5
- How to type the # character? HOT 3
- Search for key by string? HOT 2
- Problems with the installation
- Shift+arrow sends only arrow key
- Function key in macOS
- Can not compile on macOS 12.3 (C code errors) HOT 1
- Strange error im getting. HOT 3
- Pressing most keys on Windows doesn't work as expected HOT 1
- Compilation fails on macos-11 & macos-12 HOT 3
- Error while building for Linux Arch 386 HOT 5
- Error in libraries when compiling HOT 2
- macos: alt-tab not ... alt tabbing? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keybd_event.