Add (incomplete) ir:USER API based on ctru-rs implementation for Circle Pad Pro support
Adds basic API similar to the ir:U and ir:RST APIs, with all commands documented on 3DBrew implemented. Implementation of some functions was based on that of ctru-rs.
I don't have a circle pad pro to test with so I'm unable to check if everything works correctly, but it should match any documentation that exists.
I'm not super satisfied with my implementation of the iruserGetPackets() function, since it allocates two separate buffers, so please suggest any alternatives which might match how other libctru functions might act. The variable length encoding of packets, as well as the unknown number of packets makes it difficult to do any other way which is why I haven't so far.
Forgot to add review comment:
I think CPP support is good to have (though ideally this would need to be better integrated with hid/ir key sampling code).
There are a few critical bugs with your impl (notably with regards to lifetime and memory ownership).
I wonder if the API could be redesigned such that user provides user buffer instead of it being allocated. I haven't checked if this is possible, but dynamic allocations should be avoided there are cheap alternatives.
Would it be better to simply return a pointer into the existing receive buffer as opposed to dynamically allocating a new one? It’d have no guarantee of still having the data when you read it but so long as you don’t request more packets I think it would be fine?
I haven't added hid integration yet because I'm not sure what a good approach would be. Constantly pinging to see if there is a CPP attached would take a lot of resources so it's not something I want to do. I suppose I could add a connect/disconnect CPP function to hid along with reading data if it's connected, but in that case error handling would be fairly annoying.