PIC32MZ USB Host mode device enumeration issue - usb-otg

I try to use USB keyboard with PIC32MZ1024ECG64 in USB host mode, but the PIC can recognize the keyboard only if the keyboard already connected before I release the PIC from reset.
If I disconnect the keyboard and I attach it back then the PIC cannot recognize it, but if I just disconnect the D- and D+ lines only and I connect those lines back then the PIC can recognize the keyboard again.
When I disconnect the keyboard (not only D- and D+) and take look the USBOTG register, the PIC switched itself to the USB-B mode and stay in this mode.
I using MPLAB Harmony with 1.06 library.
The VBUS3V3 pin connected to 3,3V supply, the VBUS pin connected to 5V supply and the USBID pin connected to the ground.
Anybody has any idea why the PIC switching itself to the USB-B mode when I disconnect the USB connector of the keyboard?
Any suggestion will be appreciated.
Br,
Viktor Venczel

Related

Prevent mouse from waking computer from sleep mode

Mouse seems to wake my computer from sleeping at the smallest touch, this is totally useless, but found no way to turn it off.
I did disable the 'Allow device to wake computer..' under Device Manager > Mouse settings.
Windows 10 and mouse is a Logitech M220.
I suggest you the following method, check if it works correctly.
1: Open Command Prompt with Run as administrator
2: type powercfg \DEVICEDISABLEWAKE "devicename" and press Enter
3: Restart the computer
Note: Use your device name you want to disable within quotes instead of devicename, in my example my device name is HID-compliant mouse, you can find your device name from Device Properties > Hardware > Devices > Name

Which KEY_ macro in Linux input.h matches the menu key?

I want to use uinput to emulate pressing the menu key just next to the right Alt key. I tried KEY_MENU and KEY_CONTEXT_MENU, but neither of them worked. The key in Win32 API is VK_APPS.
KEY_COMPOSE is the correct Kernel keycode.
Some elaboration from Chromium’s keyboard event notes:
'Menu' and 'Props' naming differs between evdev and USB / UI Events. USB 0x010085 [System Main Menu] and USB 0x0C0040 [Menu Mode] both map to evdev 0x8B KEY_MENU (which has no corresponding UI Events |code|). USB 0x070076 [Keyboard Menu] does not map to KEY_MENU; it maps to evdev 0x82 KEY_PROPS, which is not the same as USB and UI Events "Props". USB 0x0700A3 [Props], which does correspond to UI Events "Props", is not mapped by the kernel. (And all of these are distinct from UI Events' "ContextMenu", which corresponds to USB 0x070065 [Keyboard Application] via evdev 0x7F KEY_COMPOSE, following Windows convention.)

disable the keyboard FnLock at startup

The FnLock key is activated at boot on my wired keyboard.
Is there a way to disable it?
Unfortunately, pressing the FnLock key is not visible through showkey nor keytouch.
it is really annoying because all the F1... keyx are remapped to unwanted actions like closing the window.
The FnLock key is under the control of the keyboard firmware and there is no way for software to change this. You would need to rewrite the firmware, but the keyboard manufacturer will not tell you how.

How can I create a button (or hotkey) that will automatically connect my bluetooth headset?

I have a bluetooth headset that I would like to be able to quickly switch between connection from my laptop(running windows 8) to my phone. I downloaded autohotkey to help me make a hotkey that would connect to my bluetooth headset, but I was only able to make a hotkey that would open the bluetooth control panel for my specific headset, which is not what I was trying to accomplish. What I am trying to accomplish is a hotkey that would immediately connect my headset when typed.
The code I used in autohotkey, to open the bluetooth control panel(by clicking Ctrl+Alt+B) is:
^!b:: run "C:\Program Files\WIDCOMM\Bluetooth Software\BTWUIExt.exe" /deviceAddr=445ef3aa5294
this code won't work for you as the numbers and letters on the end are a uniqe idendifier for my specific headset. You can find your unique id by opening bluetooth in the control panel and right clicking your headset, selecting properties, clicking the bluetooth tab (remove the dots and colons).
This worked to connect the first bluetooth device in the list (Windows 10)
#SingleInstance,force
;https://autohotkey.com/board/topic/83571-autohotkey-connect-to-bluetooth/
^F1::
Run, bthprops.cpl
Sleep, 2000
Send, {tab}{tab}{enter}{tab}{enter}
Sleep, 200
Send,!{Tab}
return
There is very little information to give exact solution. But from given information I can say:
You can automate GUI with AutoHotkey so that script will go to the
place where unique id is located. In fact, AutoHotkey allows any
GUI automation (conventional or non conventional GUI).
If the unique id is there as a text and you can copy it, then it
also can be automated by several ways. If unique id cant be coped
and is as image, then it is slightly complicated and you need to use some OCR
techniques. In that case you need to make screenshot of that region
and use some OCR script getting text out of it. Or with AutoHotkey pass image to OCR software and get text from it.
After you have text, you can manipulate it the way you like. Most powerfull solution
is Regular Expressions which are supported by AutoHotkey.
When unique id is ready to use, you can use it in Run
command this way:
^!b:: run "C:\Program Files\WIDCOMM\Bluetooth Software\BTWUIExt.exe" %MyUnicIDVariable%
Turns out that the code I have works on its own. If I just wait for about 10 seconds after typing out the hotkey, the headphones connect, and the control panel that opened automatically closes. Quite convenient actually as I didn't expect it to connect or to auto-close the window.
Thanks for the effort anyway!
Try to install [Broadcom Bluetooth 4.0 Driver for Windows 8.1 ] LINK=>> 1 !
At least works fine on my HP-EliteBook-8570p with stereo "BlueDio 99B" headset. After switching the headset ON the Windows connect the device automatically, and switch Audio-Stream into new-attached device. Optimal!
PS - Unfortunately it is still the Problem with Windows 8.1 + Skype( MIC-Problem) :( Windows 8 is the first OS, than not support Skype at all! ;)

How HID devices work when programming?

I have a barcode scanner works as HID device. Everytime a barcode scans it goes directly to windows keyboard, for example if I open notepad I can see the barcode typed there.
As far as I know programmatically is it possible to to read HID data from your HID devices.
But what happens if the user is already on a form with a text edit control? The scanned code will go inside the text box.
Can you block incoming text and make a background-only processing?
Can you explain the theory please?
See if your barcode scanner can emulate a serial port and just read the data directly from the the serial port into your app.
That is cleaner and less expensive then a global keyboard hook. When I was looking into this awhile ago I found that most USB barcode scanners can emulate a serial port, it's a cinch to read serial port data in most programming languages. I happened to be doing mine in Java, I posted an example in answer to this question actually.
You can set up your scanner to use USB-HID(POS) setting. Your datasheet of barcode settings for the scanner device should have it. I use this project to test my scanners. http://www.codeproject.com/Articles/18099/A-USB-HID-Component-for-C
Sure, just capture keypresses before they are handled by the control and suppress normal handling of the events. In VB.NET you might override the OnKeyPress method in your form and set KeyPreview to true, for example.

Resources