krzema12 / hypergravity

Gravity simulation in Hyper terminal
MIT License
23 stars 5 forks source link

Not working on windows 10 #17

Closed sunny-xgcp closed 6 years ago

sunny-xgcp commented 6 years ago

Seems it's not working on windows 10. I used (windows key + G) for gravity mode but it didn't work. Tried it with CTRL, ALT combinations also but didn't work. Plugin was loaded successfully as it was shown in DevTools console.

krzema12 commented 6 years ago

Thanks for the info. Can you give me the exact version of your Hyper terminal and Hypergravity plugin (seen in DevTools)?

For the record, I plan to make the hotkey configurable (#10), but I agree the default one should work across all systems.

krzema12 commented 6 years ago

Can you see Gravity mode enabled in the dev console when pressing <Windows/Control/Alt> + G, or nothing like this is printed?

sunny-xgcp commented 6 years ago

Nothing is printed on console on pressing those keys. Below are the images of hyper version and dev console.

image

image

krzema12 commented 6 years ago

Thanks. It means that the keyboard handler is not working.

I have an idea how to debug it. If I prepare a test code and push it to a separate branch, will you be able to test it locally? See the README to learn how to test it, it's fairly simple. Unfortunately I don't have access to Windows 10 machine.

You are also welcome to experiment on your own and contribute :)

krzema12 commented 6 years ago

To check: e.ctrlKey may be set to true on Windows, instead of already used e.metaKey. Be careful not to introduce regression and preserve the way it works on OS X and Linux.

See https://stackoverflow.com/a/14180949

sunny-xgcp commented 6 years ago

Yeah sure why not. Just give me some time. I've to finish some stuff right now and then i'll try to debug it get back to you.

krzema12 commented 6 years ago

I pushed some extensive logging to test-key-capture branch, see https://github.com/krzema12/hypergravity/tree/test-key-capture . After you run it on your machine, it should be clear what's going on.

krzema12 commented 6 years ago

I'm going to collect info how it works on various OS, see https://github.com/krzema12/hypergravity/wiki/Capturing-key-presses-on-various-operating-systems

sunny-xgcp commented 6 years ago

Ok, I'll get back to you with the logs in some time.

zxiosalt commented 6 years ago

@krzema12 Weird that it's not working for you. I have it running on Windows 10 just fine. The shortcut is Win+Shift+G. I have a very similar plugins list to you as well, so it shouldn't be a conflict issue.

krzema12 commented 6 years ago

@alexiskknox thanks for the feedback! What version of Hyper are you running?

I suspect that it's just a matter of changing G to g in https://github.com/krzema12/hypergravity/blob/master/src/index.js#L81 so that Windows 10 doesn't require pressing Shift.

Is there any chance you can check out the test branch with the extensive logging I mentioned in one of the previous comments, so that we see what's being reported in the JS event? Ultimately my aim is to fill out this table: https://github.com/krzema12/hypergravity/wiki/Capturing-key-presses-on-various-operating-systems

zxiosalt commented 6 years ago

hyper_version

I tried out the test branch. The issue with it is that Win+G opens the Game Bar, which can't be disabled AFAIK. So the shortcut isn't ideal. Even with the test branch installed, I still can only access it with Win+Shift+G. Weird.

EDIT: Here's the log for you.

log1 log2

I renamed the folder from hypergravity-test-key-capture to just hypergravity, if you were wondering. It is the test branch.

EDIT 2: Maybe try detecting that a user is on Windows with window.navigator.appVersion (if it contains NT or not) and just assign Alt+G or something? Just a thought.

krzema12 commented 6 years ago

What do you mean by a game bar? FTR, the test branch doesn't change anything functionally, it just adds more logging.

I probably understand why it works with Shift on your machine. It's just Windows + G is taken by something else (the game bar), and by pressing Windows + Shift + G, the key handler in hypergravity gets activated because it doesn't took at Shift being pressed or not. It means that if there wasn't the game bar that is activated with Win + G, this shortcut would enable the gravity mode.

@alexiskknox, perhaps could you try with some other key than G (change and rebuild the code) and see if it works with just Windows key, without Shift?

If we know what's going on on @sunny-xgcp 's machine, it would help a lot. Plus, #10 and configuring the shortcut could help, too, by setting the shortcut so that there is no conflict.

zxiosalt commented 6 years ago

I changed https://github.com/krzema12/hypergravity/blob/test-key-capture/src/index.js#L86 to if (e.metaKey && e.keyCode === 'N'.charCodeAt(0)) {. It now works fine if I hit Win+N. I picked that key specifically because lots of the Win+Something combos open apps and stuff.

Working fine without shift now. It didn't work without the capitalization of the 'N' though. When I had it as 'n' it wouldn't fire at all. I suspect it's something to do with Javascript being literal about the keycodes.

Anyway, it fixes the issue. I'm kind of a noob at collaboration on Git, so I've attached a zip file with the code in it. I just added a check for if the OS is Windows or not and if it is, use Win+N, and if it's not, use the standard Super+G combo. Oh, and it says "Gravity mode for Windows enabled/disabled" lol. hypergravity-modified-windows.zip

krzema12 commented 6 years ago

Thanks for your effort, I appreciate it!

I see several options:

Option 1: no change

- Prone to shortcut conflict on Windows (then, one has to press Shift to work around it) - On Linux pressing Windows + G adds a letter g after the gravity mode is disabled

Option 2: change letter to something else on Windows (proposed by @alexiskknox)

+ Preserves behavior on Mac OS and Linux - inconsistent UX across different operating systems (different letter)

Option 3: change to "Control" for Windows and Linux

+ Sort of consistent with Hyper itself (on Linux I see it uses mainly Shift + Control), Electron's "accelerator" (https://github.com/electron/electron/blob/master/docs/api/accelerator.md) and some other extensions, like hyper-search: https://github.com/jaanauati/hyper-search/blob/be86130f106447fab82d4cbfc7bfdccaea057716/src/constants.js#L1 + Consistent across different operating systems (the same letter) + No letter g added after disabling the gravity mode on any system

For now, I opt for option 3. @alexiskknox, I'd be grateful if you could check out the branch https://github.com/krzema12/hypergravity/tree/control-on-windows-and-linux and see if it works with Control + G now. I changed the logic to be like this (tested on Ubuntu and Mac OS already). Also, in the console, win32 should appear as a result of process.platform call. Let me know what you think about this solution.

zxiosalt commented 6 years ago

I have a family commitment to get to, but I'll check it out later today and update you on how it goes.

krzema12 commented 6 years ago

I tested the above fix on Mac OS, Ubuntu and Windows 8.1. On Windows, this time ^G appears in the console after quitting gravity mode, but ultimately it's not a big deal - the important thing is that it works with Control now.

Resolving - feel free to reopen or cut a new issue in case it comes back from any side.