Fix name formatting

This commit is contained in:
wheremyfoodat 2025-07-03 03:00:49 +03:00
parent 2a0661f968
commit cee16d8cf2
3 changed files with 25 additions and 23 deletions

View file

@ -25,6 +25,7 @@ void CirclePadPro::receivePayload(Payload payload) {
} }
case CPPRequestID::ReadCalibrationData: { case CPPRequestID::ReadCalibrationData: {
// Data from https://github.com/azahar-emu/azahar/blob/f8b8b6e53cf518a53c0ae5f0201660c1250c0393/src/core/hle/service/ir/extra_hid.cpp#L73
static constexpr std::array<u8, 0x40> calibrationData = { static constexpr std::array<u8, 0x40> calibrationData = {
0x00, 0x00, 0x08, 0x80, 0x85, 0xEB, 0x11, 0x3F, 0x85, 0xEB, 0x11, 0x3F, 0xFF, 0xFF, 0xFF, 0xF5, 0xFF, 0x00, 0x08, 0x80, 0x85, 0xEB, 0x00, 0x00, 0x08, 0x80, 0x85, 0xEB, 0x11, 0x3F, 0x85, 0xEB, 0x11, 0x3F, 0xFF, 0xFF, 0xFF, 0xF5, 0xFF, 0x00, 0x08, 0x80, 0x85, 0xEB,
0x11, 0x3F, 0x85, 0xEB, 0x11, 0x3F, 0xFF, 0xFF, 0xFF, 0x65, 0xFF, 0x00, 0x08, 0x80, 0x85, 0xEB, 0x11, 0x3F, 0x85, 0xEB, 0x11, 0x3F, 0x11, 0x3F, 0x85, 0xEB, 0x11, 0x3F, 0xFF, 0xFF, 0xFF, 0x65, 0xFF, 0x00, 0x08, 0x80, 0x85, 0xEB, 0x11, 0x3F, 0x85, 0xEB, 0x11, 0x3F,
@ -32,10 +33,10 @@ void CirclePadPro::receivePayload(Payload payload) {
}; };
struct ReadCalibrationDataRequest { struct ReadCalibrationDataRequest {
u8 requestID; u8 requestID; // Always CPPRequestID::ReadCalibrationData for this command
u8 expectedResponseTime; u8 unknown;
u16_le offset; u16_le offset; // Offset in calibration data to read from
u16_le size; u16_le size; // Bytes in calibration data to read
}; };
static_assert(sizeof(ReadCalibrationDataRequest) == 6, "ReadCalibrationDataRequest has wrong size"); static_assert(sizeof(ReadCalibrationDataRequest) == 6, "ReadCalibrationDataRequest has wrong size");
@ -47,16 +48,17 @@ void CirclePadPro::receivePayload(Payload payload) {
ReadCalibrationDataRequest request; ReadCalibrationDataRequest request;
std::memcpy(&request, payload.data(), sizeof(request)); std::memcpy(&request, payload.data(), sizeof(request));
const u16 offset = request.offset & ~0xF; // Get the offset and size for the calibration data read. Bottom 4 bits are ignored, aligning reads to 16 bytes
const u16 size = request.size & ~0xF; const auto offset = usize(request.offset & ~0xF);
const auto size = usize(request.size & ~0xF);
if (static_cast<std::size_t>(offset + size) > calibrationData.size()) { if (offset + size > calibrationData.size()) {
Helpers::warn("IR::ReadCalibrationData: Read beyond the end of calibration data!!"); Helpers::warn("IR::ReadCalibrationData: Read beyond the end of calibration data!!");
return; return;
} }
std::vector<u8> response(5 + size); std::vector<u8> response(size + 5);
response[0] = static_cast<u8>(CPPResponseID::ReadCalibrationData); response[0] = CPPResponseID::ReadCalibrationData;
std::memcpy(&response[1], &request.offset, sizeof(request.offset)); std::memcpy(&response[1], &request.offset, sizeof(request.offset));
std::memcpy(&response[3], &request.size, sizeof(request.size)); std::memcpy(&response[3], &request.size, sizeof(request.size));
std::memcpy(&response[5], calibrationData.data() + offset, size); std::memcpy(&response[5], calibrationData.data() + offset, size);

View file

@ -621,24 +621,24 @@ void MainWindow::pollControllers() {
const s16 l2 = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_TRIGGERLEFT); const s16 l2 = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_TRIGGERLEFT);
const s16 r2 = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_TRIGGERRIGHT); const s16 r2 = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_TRIGGERRIGHT);
const s16 cstickX = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_RIGHTX); const s16 cStickX = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_RIGHTX);
const s16 cstickY = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_RIGHTY); const s16 cStickY = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_RIGHTY);
hid.setKey(HID::Keys::ZL, l2 > triggerThreshold); hid.setKey(HID::Keys::ZL, l2 > triggerThreshold);
hid.setKey(HID::Keys::ZR, r2 > triggerThreshold); hid.setKey(HID::Keys::ZR, r2 > triggerThreshold);
// Update C-Stick // Update C-Stick
// To convert from SDL coordinates, ie [-32768, 32767] to [-2048, 2047] we just divide by 8 // To convert from SDL coordinates, ie [-32768, 32767] to [-2048, 2047] we just divide by 8
if (std::abs(cstickX) < deadzone) { if (std::abs(cStickX) < deadzone) {
hid.setCStickX(IR::CirclePadPro::ButtonState::C_STICK_CENTER); hid.setCStickX(IR::CirclePadPro::ButtonState::C_STICK_CENTER);
} else { } else {
hid.setCStickX(cstickX / 8); hid.setCStickX(cStickX / 8);
} }
if (std::abs(cstickY) < deadzone) { if (std::abs(cStickY) < deadzone) {
hid.setCStickY(IR::CirclePadPro::ButtonState::C_STICK_CENTER); hid.setCStickY(IR::CirclePadPro::ButtonState::C_STICK_CENTER);
} else { } else {
hid.setCStickY(-(cstickY / 8)); hid.setCStickY(-(cStickY / 8));
} }
} }

View file

@ -429,24 +429,24 @@ void FrontendSDL::run() {
const s16 l2 = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_TRIGGERLEFT); const s16 l2 = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_TRIGGERLEFT);
const s16 r2 = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_TRIGGERRIGHT); const s16 r2 = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_TRIGGERRIGHT);
const s16 cstickX = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_RIGHTX); const s16 cStickX = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_RIGHTX);
const s16 cstickY = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_RIGHTY); const s16 cStickY = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_RIGHTY);
hid.setKey(HID::Keys::ZL, l2 > triggerThreshold); hid.setKey(HID::Keys::ZL, l2 > triggerThreshold);
hid.setKey(HID::Keys::ZR, r2 > triggerThreshold); hid.setKey(HID::Keys::ZR, r2 > triggerThreshold);
// Update C-Stick // Update C-Stick
// To convert from SDL coordinates, ie [-32768, 32767] to [-2048, 2047] we just divide by 8 // To convert from SDL coordinates, ie [-32768, 32767] to [-2048, 2047] we just divide by 8
if (std::abs(cstickX) < deadzone) { if (std::abs(cStickX) < deadzone) {
hid.setCStickX(IR::CirclePadPro::ButtonState::C_STICK_CENTER); hid.setCStickX(IR::CirclePadPro::ButtonState::C_STICK_CENTER);
} else { } else {
hid.setCStickX(cstickX / 8); hid.setCStickX(cStickX / 8);
} }
if (std::abs(cstickY) < deadzone) { if (std::abs(cStickY) < deadzone) {
hid.setCStickY(IR::CirclePadPro::ButtonState::C_STICK_CENTER); hid.setCStickY(IR::CirclePadPro::ButtonState::C_STICK_CENTER);
} else { } else {
hid.setCStickY(-(cstickY / 8)); hid.setCStickY(-(cStickY / 8));
} }
} }