-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added functionality for multiple devices and fixed stop record option #1
Conversation
Thank you for pull request however there are few minor/major problems. First of all, I decided to use POSIX for portability, since I'm not very familiar with all shells which are freely available to download and their similarities. Although we can speculate that libinput is not probably supported on such systems which run archaic shells there are always people who run unexpected things. Not me and you, but maybe somebody in future will. Thus try to rework your PR to support POSIX shell, shouldn't be that hard, I will add shellcheck actions to check for this automatically for future PRs. Secondly which is more concerning is that while it works using mirror replay I can't make it work with simple replay due to how parsing works. I'm planning to add mouse support sometime in future, but that will need to rework parsing. Also do you get similar warning when running it on wayland? Just wondering if this is x11 issue or not.
|
Thank you for response, I will rework it to be POSIX compliant. For last warning, I have not experienced it, so probably X11 issue. I have no issue recording mouse and mouse movements, as well as keyboard and mouse movements at the same time. Example of keyboard+mouse usage in a game: untitled2.mp4Video 2xFF, cut and lower resolution due to size limitations but shows working demo of both devices replicated. There is start delay on replay, but I think that is due to my swhkd config and/or due to swhkd itself. One thing I also noticed in your commits, you have added tail to pick last device from the list. My list contains first device as one that should be recorded, not the last so that could also come into consideration/be added as an issue. It could be Wayland/X11 difference or just device specific differences, I avoided it by just using /dev/input/event* instead of names, easier for me. |
looks cool, I forgot we could use it in games.
I literally use libinput function for mirroring. I don't experience delay on my side
Read the commit message why i did it this way. You can specify device name via "real name", this way you can have script that will behave same on reboots, because Small edit note: |
Yup, I'm intending to use it for benchmarks. I was looking for both Wayland and X11 solution and stumbled on this.
That's why I mentioned it could be due to swhkd or just due to games/Wayland, through terminal it runs immediately, but there is like 10 seconds delay as also seen in the video by in game counter (as soon as I set my crosshair i pressed the bind at 1:51, but macro starts at 1:39), accounting for my delay from record bind to first key it's still 10 seconds too much. Either swhkd takes too long to pick up signals when in-game, or game/Wayland/ydotool don't start fast enough.
For me /dev/input/event* doesn't change on reboots, and I have issues with "real name" in libinput replay as my keyboard contains character outside of iso8859-1 encoding (.̊ ). Another reason why your program is better than just running macros through libinput.
For games, like FPS games, mouse is always centered and moves through interpolation of change_x - center_x, takes that change, moves the camera matrix and returns mouse to center, so relative positions work great for 3D games. I looked into absolute positions through libinput, but that choice is only for touch inputs. Mouse pointers work differently and only support relative position. To implement absolute positions it would probably take for example a macro at the start of the recording to put mouse in one of display corners by putting massive relative position change, and add that relative position change at the start of replay macro file (but there is always an issue of mouse sensitivity). |
weird or maybe my system is :D
I think whatever name Regarding error I have no idea maybe you could share macro file so i try to reproduce it, but before posting it check if there isn't any security private related information in it. Regarding the delay I mentioned in my previous edit, I was trippin' it should replay immediately, so something definitely happens on your side, you could check Recording starting position is definitely doable, I will think about it. |
I do get that and love it, but that's why I mentioned tail and fetching last event in libinput event list. for me list-kernel-devices is as follows:
Both /dev/input/event4 for mouse and /dev/input/event2 for keyboard is the actual event I want to pick up, additional ones I don't know where they came from. Both keyboard and mouse I want to fetch first, but for you it's the last, that's why you added tail in def792d commit. We can't really ask the user which one because most likely scenario is scripts so maybe with this merge of multiple devices it could record all instances? Extra ones are duds anyway. Anyways, with latest commit I think I made my side POSIX compliant, arrays are not being used anymore and it's back to string. |
Forgot to add, you asked me earlier, this is my config for swhdk, runs normally on desktop, but there is replay delay in games. Probably due to games themselves or the way compositor is acting. Doesn't matter anyways, it's just that one specific scenario. |
I thought it is rational that when you plug new device(with same name) it will be desired one to record, but now I understand that maybe on system boot up you might have plugged 3 devices with same name thus script won't work as expected if desire is to record only first. However when recording multiple devices using name specifier can also result in undesired results. Let's say you want to use device name "USB Gaming Mouse" for event4 in your script all the time but it might change on second boot and suddenly became event5 while other "USB Gaming Mouse" will became event4. For now safest choice is to specify each device I want to use using In my case I can record both device names since bluetooth input get's auto-disabled by Corne itself.
Looks ok, I see this pr generated lots of questions and issues we need to fix. Will open issues for those to keep track of them. I will edit readme and add some information to help regarding this. |
The rest in checker are infos, not errors/warnings. Line 60 is intentional because device names should split, lines 111 and 137 are from master unchanged. Should i just put everything under shellcheck disable? |
no worries I'm on it your pr is ready to merge |
see pr#1
Added functionality for multiple devices:
Keystrokes is amazing, but I did want an ability to record multiple devices at once (keyboard and mouse, for example). As libinput record, the one being used by keystrokes has the ability to record multiple devices I decided to implement that functionality.
Instead of a string containing a device name, this would now contain an array of device names for recording. In given parameters, checks are made that there is an element (gt 0) and that it is not empty or starts with a dash (next option). If it's greater but is another option/empty, it shifts and breaks out of the loop. Otherwise, it runs the same logic of finding the device but adds it to an array instead of initializing a string. Error message also changed to ask for "at least one device" in the -D option.
SIGINT instead of SIGTERM
To stop recording, it should use SIGINT instead of SIGTERM, as SIGTERM will truncate the file. The issue becomes apparent when recording multiple devices. Signal kills the process of recording and writing to the file instantly, and it ends up truncating and usually only finishes writing for one device. SIGINT lets the process clean up and close the file, successfully writing everything it needs to before shutting down. I left SIGTERM in stop replay as it doesn't need to finish a process and we want it just to stop.
This does not affect previous scripts and works normally with just one device. Everything was tested with ydotool in Wayland and should work the same in X11.
Readme and help could be updated to clarify that the -D option supports multiple devices instead of one recording device but that I will leave up to the owner.