GithubHelp home page GithubHelp logo

Comments (11)

drashna avatar drashna commented on June 12, 2024

I think you're looking for void notify_usb_device_state_change_user(enum usb_device_state usb_device_state)

from qmk_firmware.

tim-hilt avatar tim-hilt commented on June 12, 2024

Oh that’s nice! Is there any documentation about this?

from qmk_firmware.

tim-hilt avatar tim-hilt commented on June 12, 2024

Solved by #21777

from qmk_firmware.

andrebrait avatar andrebrait commented on June 12, 2024

@tim-hilt I see you merged my PR into your fork. Is it working ok for you?

from qmk_firmware.

tim-hilt avatar tim-hilt commented on June 12, 2024

Hi and thanks for your work first and foremost! I did flash my code on three different boards:

  • Elite-C based Corne (by splitkb, aurora-line)
  • Frood (RPi 2040) based Hillside 46
  • Splinky (RPi 2040) based TBK Mini

so I can test some variety like that.

It did work everytime, if I were to plug it directly into one machine. OS detection works and does what I expect. However, if I have it plugged into my USB-C monitor and wake a machine from suspend, then it always runs into OS_UNSURE.

I still have to test how it behaves if I switch out host machines and keep the keyboard plugged into the KVM. Also note, that I haven't played with OS_DETECTION_DEBOUNCE or OS_DETECTION_KEYBOARD_RESET yet. I'll do so and report back though.

If you already know what I could try out next (raising OS_DETECTION_DEBOUNCE I guess?) Feel free to share your suspicions and I'll try it out.

from qmk_firmware.

tim-hilt avatar tim-hilt commented on June 12, 2024

So for the TBK Mini, os-detection worked. After switching from Mac to PC, my default layer is now automatically changed.

from qmk_firmware.

andrebrait avatar andrebrait commented on June 12, 2024

from qmk_firmware.

tim-hilt avatar tim-hilt commented on June 12, 2024

@andrebrait actually I was wrong when I said

So for the TBK Mini, os-detection worked. After switching from Mac to PC, my default layer is now automatically changed.

It did in fact switch, but I think it did, because OS_WIN and OS_UNSURE are handled the same in my code:

https://github.com/tim-hilt/qmk_firmware/blob/master/keyboards/bastardkb/tbkmini/keymaps/tim-hilt/keymap.c#L67-L71

so it did at least retrigger, but I'm pretty sure it didn't detect reliably. I started experimenting with OS_DETECTION_DEBOUNCE, but that didn't the behavior, even after bumping it up 1000 ms. So I tried with OS_DETECTION_KEYBOARD_RESET and that finally did the trick.

So I can confirm, that the feature works. However I can't judge whether the fuzzy behavior is because of my KVM or because of the implementation.

from qmk_firmware.

andrebrait avatar andrebrait commented on June 12, 2024

Most likely it's due to the KVM at some point triggering the reinitialization of the USB interface without cutting power to the board, which causes issues with the detection.

I added that flag because my KVM does that when switching machines, but it's weird that yours does it even when plugging the device in for the first time.... Go figure...

You can always enable debugging there and see what comes out, if you want to understand exactly what's up with it.

from qmk_firmware.

tim-hilt avatar tim-hilt commented on June 12, 2024

On first plug the detection worked. But it didn’t when I kept it plugged into the KVM but switched out host machines. This seems to be consistent with what you were experiencing with your hardware!

from qmk_firmware.

andrebrait avatar andrebrait commented on June 12, 2024

Oh, I had misunderstood then.

Yeah, then it's 100% expected you need the reset flag. KVMs don't typically cut power, which is the only thing that would cause the USB interface to be completely restarted, so you need to reset the board and force the device descriptor to be generated again so the detection can capture the data from the host and try to detect the OS.

Otherwise, it's never triggered again.

At least that's my understanding of it. Likely the nomenclature is not 100% accurate per se.

from qmk_firmware.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.