C ++ Discovers Apple Earphone Buttons in Windows

REFERENCE INFORMATION:

I tried to detect a button press from an Apple headphone. Headphones are connected to a MacBook Pro running on Windows. This is not a virtual machine. This works fine with Windows with the full Windows driver from Apple via Boot Camp.

Headphones are Apple standard headphones that consist of three buttons: volume, volume, middle buttons and a microphone.

When I use Mac Os, if the volume up button clicks on the headphones, Mac Os will increase its volume by one. It also decreases its volume when the smart down button is pressed on the ear phone.

Standard headphones / earphones use three conductive pins for reception (L / R speakers only) , while the apple version uses four conductive pins for reception (L / R speakers) and send signals (buttons) . This headphone was made for the iPhone, but I was surprised when it worked on Mac Os.

This led me to believe that the MacBook Pro hardware was built to support this four conductive headphone jack. It works on Mac Os, but NOT on Windows. My goal is to develop tiny software that will allow the use of Apple headphones in Windows running on Apple hardware.

I know how to increase the volume of Windows using C ++ and the Win32 API, but I am stuck on the part where I really need to detect the click button from the headphones.

QUESTION:

1 ), what ways can I detect input (button press) from the headphones?

Looks like this man here was able to read it. He only did this while working on Mac Os. Detecting Hardware Headphones on Mac

2 ). If I compile the code, this person should work on Mac OS as a DLL file, and then call this function while Windows is working, will it work?

3 ) Do I need to make my own driver for it to work?

4) The code below is from the link above. What is the window API function, the class is equivalent to the following Mac OS code below?

id array = [[DDHidDevice allDevices] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"productName == \"Apple Mikey HID Driver\""]]; DDHidDevice *mic = [array count] ? [array objectAtIndex:0] : nil; // it isn't a keyboard NSLog(@"%@", mic.primaryUsage); assert(mic.usage==1 && mic.usagePage==12); 

THINGS I RECEIVED:

1 ) I tried using GetLastInputInfo() with LASTINPUTINFO from the Windows API to sniff any hardware inputs, but failed unsuccessfully. He worked on the keyboard and mouse, but nothing else.

2 ) I also tried using RAWINPUTDEVICE to read low-level input from hardware, but it only worked on keyboards, mice and joysticks. He did not detect a button press on the headphone.

I'm running out of ideas. Has anyone got any solution?

NOTE. This is not a duplicate question, since I am asking how to do it on Windows, not on Mac.

+5
source share

Source: https://habr.com/ru/post/1205960/


All Articles