• 2 Posts
  • 25 Comments
Joined 2 years ago
cake
Cake day: July 2nd, 2023

help-circle

  • Do you follow the reasoning for why they set it up this way? The comments in this function from _xorg in keyboard make it seem like it expects K1 K2 K3 K4.

    #: Finds a keycode and index by looking at already used keycodes
            def reuse():
                for _, (keycode, _, _) in self._borrows.items():
                    keycodes = mapping[kc2i(keycode)]
    
                    # Only the first four items are addressable by X
                    for index in range(4):
                        if not keycodes[index]:
                            return keycode, index
    

    I assume that second comment is the reason the person who wrote your function likes the number 4.

    Which way is right/wrong here? It would seem at least part of the issue to me is that they don’t make the list be K1 K2 K1 K2 as they say, since the function I quoted above often receives a list formatted like K1 K2 K1 NoSymbol.

    Also, if I modify the function you quoted from to remove the duplications, I’m still finding that the first element is always duplicated to the third element anyways - it must be happening elsewhere as well. Actually, even if I modify the entire function to just be something nonsensical and predictable like this:

    def keysym_normalize(keysym):
        # Remove trailing NoSymbol
        stripped = list(reversed(list(
            itertools.dropwhile(
                lambda n: n == Xlib.XK.NoSymbol,
                reversed(keysym)))))
        if not stripped:
            return
        else:
            return (keysym_group(stripped[0], stripped[0]), keysym_group(stripped[0], stripped[0]))
    

    then the behavior of the output doesn’t change at all from how it behaves when this function is how it normally is… It still messes up every third special character, duplicating the previously encountered special character

    Later edit: After further investigation, the duplication of the first entry to the third entry seems to happen in the Xlib library, installed with pynput, in the display.py file, in the change_keyboard_mapping function, which only has a single line. Inspecting the output of the get_keyboard_mapping() function both before and after the change_keyboard_mapping function does its thing shows that it jumps right from [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] to [keysym, 0, keysym, 0, 0, 0, 0, 0, 0, 0]. It’s still unclear to me if this is truly intended or a bug.


  • Gonna make some notes since I made some progress tonight (so far).

    Within pynput’s keyboard’s _xorg.py file, in the Controller class, self._keyboard_mapping maps from each key’s unique keysym value, which is an integer, to a 2-tuple of integers. The actual keysym for each key in the mapping appears to be correct, but occasionally the 2-tuple duplicates that of another entry in self._keyboard_mapping - and these duplicates correspond precisely to the errors I see in pynput’s outputs.

    For example, ‘𝕥’ has keysym = 16897381 and ‘𝕖’ has keysym = 16897366, but both 16897381 and 16897366 map, in self._keyboard_mapping, to the 2-tuple (8, 1) - and ‘𝕖’ is indeed printed as ‘𝕥’ by pynput. (𝕥’s keysym appears first in self._keyboard_mapping). (The 2-tuple keysyms map to are not unique or consistent, they vary based on the order they were encountered and reset when X resets)

    Through testing, I found that this type of error happens precisely every third time a new keysym is added to self._keyboard_mapping, and that every third such mapping always duplicates the 2-tuple of the previous successful mapping.

    From that register function I mentioned, the correct 2-tuple should be, I believe, (keycode, index). This is not happening correctly every 3rd registration, but I’m not yet sure why.

    However, I did find a bit more than that: register() gets its keycode and index from one of the three functions above it, reuse() borrow() or overwrite(). The problematic keys always get their keycode and index from reuse - and reuse finds the first unused index 0-3 for a given keycode, then returns that. What I found here is that, for the array keycodes, the first element is always duplicated to the third position as well, so indexes 0 and 2 are identical. As an example, here are two values of keycodes from my testing:

    keycodes = array('I', [16897386, 0, 16897386, 0, 0, 0, 0, 0, 0, 0])
    keycodes = array('I', [16897384, 16897385, 16897384, 0, 0, 0, 0, 0, 0, 0])
    

    With this in mind, I was actually able to fix the bug by changing the line for index in range(4): in reuse() to for index in range(2):. With that change my script no longer produces any incorrect characters.

    However, based on the comments in the function, I believe range(4) is the intended behavior and I’m just avoiding the problem instead of fixing it. I have a rather shallow understanding of what these functions or values are trying to accomplish. I don’t know why the first element of the array is duplicated to the third element. There’s also a different issue I noticed where even when this function returns an index of 3, that index of 3 is never used in self._keyboard_mapping - it uses 1 instead. I’m thinking these may be two separate bugs. Either way, these two behaviors combined explain why it’s every third time a new keysym is added to self._keyboard_mapping that the issue happens: While they in theory support an index of 0 1 2 or 3 for each keycode, in practice only indices 0 1 and 3 work since 2 always copies 0 - and whenever 3 is picked it’s improperly saved as 1 somewhere.

    I may keep investigating the issues in search of a true fix instead of a cover-my-eyes fix.


  • I agree and appreciate it. I’ve been trying to figure it out myself but feel a bit out of my element.

    What I’ve found is that in pynput’s keyboard’s _xorg.py file, the Controller class’s self._keyboard_mapping seems to map some different keycodes to the same value, and that seems to correlate exactly with the errors I’m seeing. I haven’t figured out why yet. I got to thinking it had something to do with the register function in the _resolve_borrowing function but I forget why and I’m too tired to continue for now. I’ll continue tomorrow though.





  • zkfcfbzr@lemmy.worldtoLinux@lemmy.mlFirefox 135.0 released
    link
    fedilink
    English
    arrow-up
    1
    ·
    5 months ago

    Firefox now includes safeguards to prevent sites from abusing the history API by generating excessive history entries, which can make navigating with the back and forward buttons difficult by cluttering the history. This intervention ensures that such entries, unless interacted with by the user, are skipped when using the back and forward buttons.

    Nice









  • I’m a 65% user and it’s great. The only keys right of the main block that I ever really use are delete, PrtSc, and the arrow keys - so all a full size keyboard does for me is force me to awkwardly bend my arms to the left as I type. I especially dislike numpads on laptop keyboards for that reason.

    And I work with numbers a lot. I just prefer the number row. I have remapped the rightmost column of keys to more useful functions as well.


  • This stance has nothing to do with anglocentrism and everything to do with making Lemmy usable. You set your languages in your profile so you’ll only see posts and comments in those languages. No one likes seeing lots of posts in languages they don’t understand, and that that only happens when people are too lazy to set the language indicator. I’d fully expect and encourage non-English speakers to downvote improperly tagged English posts in their feed as well.




  • I’m not so sure about changing the terminology, but if we did, I think it should be a word that implies what the situation is: That the instance they pick isn’t a walled garden in itself, but just an access point to the wider connected Lemmyverse. I think that was a common confusion point for most of us when we first heard of Lemmy.

    So… “access point”? Or “gateway”? Or for a milder change, going from “instance” to “default instance” might get the point across.


  • My passwords use the full set of characters I can type by hand on a standard US qwerty keyboard, and I’ve only run into a few sites that have complained and made me use something simpler. PayPal is one of them. Some of the others are Zenni Optical, eBay, and FedLoan.

    In total that’s about 8% of my accounts. So the vast majority of sites seem to let you use whatever, at least. I only use 15 characters so I have no comments on length. I am equally annoyed when a new site makes me use simpler passwords.


  • I’m pretty sure I’m in a minority here, but I like that lemmy.world is so huge - and think it’s both positive for the lemmyverse and an excellent starting point for new users.

    It ties into the new user experience a lot: lemmy.world has a large userbase so most communities will already show up in its All. It’s consistently had new registrations open where many others have closed during large sign-up rushes. It has a thoughtful admin team experienced with running services like this. It’s likely to be around for the very long term and, short of some DDoS attacks, should be fairly reliable.

    I know having instances this big is objectively bad if you’re measuring things like how distributed or resilient to disruption the Lemmyverse is, but I think the positives outweigh the negatives on the whole.

    If I’m honest, I think the best way to implement an “I know which instance I pick isn’t that important, please just send me to a random one” feature would be to send the user to a random one of the top 5 largest instances. I stopped short of suggesting that because I know it would be deeply unpopular though - enough so that it becomes a bad idea on that merit alone.