mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-02 13:01:18 +12:00
nsyshid: Skylander 360 Portal small optimization and code formatting (#1568)
This commit is contained in:
parent
bed5fdb195
commit
111637a9fd
1 changed files with 20 additions and 20 deletions
|
@ -26,7 +26,7 @@ namespace nsyshid
|
|||
|
||||
Device::ReadResult SkylanderXbox360PortalLibusb::Read(ReadMessage* message)
|
||||
{
|
||||
std::vector<uint8> xboxData(std::min<uint32>(32, message->length + sizeof(XBOX_DATA_HEADER)), 0);
|
||||
std::vector<uint8> xboxData(std::min<uint32>(32, message->length + sizeof(XBOX_DATA_HEADER)));
|
||||
memcpy(xboxData.data(), XBOX_DATA_HEADER, sizeof(XBOX_DATA_HEADER));
|
||||
memcpy(xboxData.data() + sizeof(XBOX_DATA_HEADER), message->data, message->length - sizeof(XBOX_DATA_HEADER));
|
||||
|
||||
|
@ -45,7 +45,7 @@ namespace nsyshid
|
|||
if (message->data[0] == 'M' && message->data[1] == 0x01) // Enables Speaker
|
||||
g72x_init_state(&m_state);
|
||||
|
||||
std::vector<uint8> xboxData(message->length + sizeof(XBOX_DATA_HEADER), 0);
|
||||
std::vector<uint8> xboxData(message->length + sizeof(XBOX_DATA_HEADER));
|
||||
memcpy(xboxData.data(), XBOX_DATA_HEADER, sizeof(XBOX_DATA_HEADER));
|
||||
memcpy(xboxData.data() + sizeof(XBOX_DATA_HEADER), message->data, message->length);
|
||||
|
||||
|
@ -61,7 +61,7 @@ namespace nsyshid
|
|||
{
|
||||
std::vector<uint8> audioData(message->data, message->data + message->length);
|
||||
|
||||
std::vector<uint8_t> xboxAudioData;
|
||||
std::vector<uint8_t> xboxAudioData(audioData.size() / 4);
|
||||
for (size_t i = 0; i < audioData.size(); i += 4)
|
||||
{
|
||||
int16_t sample1 = (static_cast<int16_t>(audioData[i + 1]) << 8) | audioData[i];
|
||||
|
@ -70,10 +70,10 @@ namespace nsyshid
|
|||
uint8_t encoded1 = g721_encoder(sample1, &m_state) & 0x0F;
|
||||
uint8_t encoded2 = g721_encoder(sample2, &m_state) & 0x0F;
|
||||
|
||||
xboxAudioData.push_back((encoded2 << 4) | encoded1);
|
||||
xboxAudioData[i / 4] = ((encoded2 << 4) | encoded1);
|
||||
}
|
||||
|
||||
std::vector<uint8> xboxData(xboxAudioData.size() + sizeof(XBOX_AUDIO_DATA_HEADER), 0);
|
||||
std::vector<uint8> xboxData(xboxAudioData.size() + sizeof(XBOX_AUDIO_DATA_HEADER));
|
||||
memcpy(xboxData.data(), XBOX_AUDIO_DATA_HEADER, sizeof(XBOX_AUDIO_DATA_HEADER));
|
||||
memcpy(xboxData.data() + sizeof(XBOX_AUDIO_DATA_HEADER), xboxAudioData.data(), xboxAudioData.size());
|
||||
|
||||
|
@ -157,4 +157,4 @@ namespace nsyshid
|
|||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} // namespace nsyshid
|
Loading…
Add table
Add a link
Reference in a new issue