Send play/pause command c++ - c++

So I'm trying to control my computer with an IR remote control. I get the IR code thanks to an arduino nano which sends it to my computer by the serial port.
I want to, for example depending on the code sent, send a play or pause or next and so on command to spotify or win media player or any other app.
I know that you have keyboards shortcuts for this so my question is how do I reproduce the commands that these keyboards shortcuts send to all the programs to stop the music ?
Thanks in advance for any help ! :)

Related

Capture mouse HID packets on windows using C++?

I want to ditch Razer Synapse because it eats up to 600MB of RAM for nothing. I just want to use my macros for two additional keys found on my Razer Deathadder. I've sucessfully captured the HID packets for my Corsair K95 keyboard with C++ HID API and executed my macros, finally was able to say bye bye to iCUE. But I'm not able to open mouse as HID device. Everything should be configured properly, VID/PID, UsagePage and Usage too. But the interesting thing is that wireshark is able to capture the mouse, for me it doesn't for even when I try to open it with admin priveliges. Does somebody have any idea what I should do?
I've tried hidapitester application which is part of HIDAPI C++ library, it automatically closes the device and doesn't receive anything. If it's not possible to solve it in this way, which approach I should use to be able to capture the packets?
Thank you.

Wemos D1 Mini (ESP8266) control with USB

I have a Wemos D1 Mini (ESP8266), flashed with WLED and I want to create an application like .exe and have control on turning it on/off and choose colors. Does anyone have any idea how I can do without to connect on wifi and just do everything via USB?
To control the WLED firmware over USB, you would use the firmware's ability to be controlled over a serial connection. It looks like you would open the virtual serial port that appears when you plug in the device, at a speed of 115200, and then you take the same JSON that you would POST to /json/state for controlling it over WiFi, and instead send it over the serial connection, and get your responses back over the serial connection.
You could also implement the TPM2 protocol, or the Adalight protocol (which doesn't really seem to be documented except in code), as those are also supposed to be supported.
If you want to do all this in C++ on Windows, you might start by reading the (very old) Windows tutorials for Win32 API serial port programming. If you only want to target Win10 or newer, you could learn C++/WinRT and then use the new WinRT serial APIs. Or you could consult the answers to this question about serial programming on Windows.

console windows tapping into pc's USB recources

is it possible to tap into the USB drivers / resources with a windows console app (win32 c++)?
i would like to detect connected hardware, send and receive midi from my USB keyboard.
but i don't want to build a complete GUI app for my small needs to test my own hardware on perf board.
the main purpose is also to test the software written for the pic microcontroller, it's much faster debugging, rather than compiling and running with the chip from zif socket tot zif socket.
i need some directions, thank you.
This is possible. For midi keyboards, check the midiIn... functions

Issue with hex data being sent out of a serial port

I am really hoping someone can help me with this issue, I have been working on it for 3 days and its driving me insane now.
I have two linux based devices connected over serial, one is an embedded device the other is a pc type device. I have some python code on the PC device that currently, successfully reads messages sent by the embedded device (hence the serial settings are correct).
However I now need to send commands back to the embedded device and this is what i am struggling with, I have a data tap on the serial line so i can see the data being sent / received.
When I send the string "\x2a\x00\x00\x00\x00\x00\x57\x78\xD6\x81\x00\x01\x00\x8D\x54" out of the serial port, on the serial data tap I see only "EF F7 FF FF".
Please see the code below:
import serial
serialport = serial.Serial(port=self.device,
baudrate=self.baudrate,
bytesize=self.bytesize,
parity=self.parity,
stopbits=self.stopbits,
timeout=0)
data = "\x2a\x00\x00\x00\x00\x00\x57\x78\xD6\x81\x00\x01\x00\x8D\x54"
serialport.write(data)
serialport.flushOutput()
This is now resolved, turned out to be a couple of issues the customer neglected to tell me that unless the embedded device is in engineering mode it will ignore commands. Also the data tap had a dip switch set incorrectly, so there was nothing wrong with my code. Thanks to Shane for making me question the hardware and not my code !

How to use mac's default midi sequencer as midi out?

I have been trying to play midi voices with rtmidi. I have sucessfully managed to link it and compile example programs. But unfortunately I can't see my snow leopards own midi sequencer as an output port. I also tried to open a midi output port using the coremidi library with no success.
How can I make rtmidi or another library send it's messages directly to the apple's own midi sequencer?
Should I start a midi out server? If so, how can I do it?
Any help would be greatly appreciated.
PS: I am trying to send these messages and play those voices to turn my computer keyboard in a musical instrument.
So you are just interested in generating midi notes from the desktop keyboard and playing them back locally? You don't need to deal with output ports, RTMidi or anything like that. You would only need to that if you wanted to send message events to an external synth.
See this PlaySoftMidi Apple sample code for generating notes through the soft synth. If you want to load your own sound library (sound font 2 or DSL) search for "AUSampler" and "MusicDeviceMIDIEvent" - there are a few tutorials out there (link)