mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-07-04 22:32:57 +12:00
More CPP fixes
This commit is contained in:
parent
a3f9ced3aa
commit
935e088ca1
5 changed files with 36 additions and 10 deletions
|
@ -28,8 +28,14 @@ namespace IR {
|
||||||
ButtonState() {
|
ButtonState() {
|
||||||
// Response header for button state reads
|
// Response header for button state reads
|
||||||
cStick.header = static_cast<u8>(CPPResponseID::PollButtons);
|
cStick.header = static_cast<u8>(CPPResponseID::PollButtons);
|
||||||
|
cStick.x = static_cast<u32>(CirclePadPro::ButtonState::C_STICK_CENTER);
|
||||||
|
cStick.y = static_cast<u32>(CirclePadPro::ButtonState::C_STICK_CENTER);
|
||||||
|
|
||||||
// Fully charged
|
// Fully charged
|
||||||
buttons.batteryLevel = 0x1F;
|
buttons.batteryLevel = 0x1F;
|
||||||
|
buttons.zrNotPressed = 1;
|
||||||
|
buttons.zlNotPressed = 1;
|
||||||
|
buttons.rNotPressed = 1;
|
||||||
unknown = 0;
|
unknown = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -79,6 +79,11 @@ class IRUserService {
|
||||||
IRUserService(Memory& mem, const EmulatorConfig& config, Kernel& kernel)
|
IRUserService(Memory& mem, const EmulatorConfig& config, Kernel& kernel)
|
||||||
: mem(mem), config(config), kernel(kernel), cpp([&](IR::Device::Payload payload) { sendPayload(payload); }) {}
|
: mem(mem), config(config), kernel(kernel), cpp([&](IR::Device::Payload payload) { sendPayload(payload); }) {}
|
||||||
|
|
||||||
|
void setZRPressed(bool pressed) { cpp.state.buttons.zrNotPressed = pressed ? 0 : 1; }
|
||||||
|
void setZLPressed(bool pressed) { cpp.state.buttons.zrNotPressed = pressed ? 0 : 1; }
|
||||||
|
void setCStickX(s16 value) { cpp.state.cStick.x = value; }
|
||||||
|
void setCStickY(s16 value) { cpp.state.cStick.y = value; }
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
void handleSyncRequest(u32 messagePointer);
|
void handleSyncRequest(u32 messagePointer);
|
||||||
void updateCirclePadPro();
|
void updateCirclePadPro();
|
||||||
|
|
|
@ -441,7 +441,7 @@ void GPU::fireDMA(u32 dest, u32 source, u32 size) {
|
||||||
u8* fcram = mem.getFCRAM();
|
u8* fcram = mem.getFCRAM();
|
||||||
std::memcpy(&vram[dest - vramStart], &fcram[source - fcramStart], size);
|
std::memcpy(&vram[dest - vramStart], &fcram[source - fcramStart], size);
|
||||||
} else {
|
} else {
|
||||||
printf("Non-trivially optimizable GPU DMA. Falling back to byte-by-byte transfer\n");
|
log("Non-trivially optimizable GPU DMA. Falling back to byte-by-byte transfer\n");
|
||||||
|
|
||||||
for (u32 i = 0; i < size; i++) {
|
for (u32 i = 0; i < size; i++) {
|
||||||
mem.write8(dest + i, mem.read8(source + i));
|
mem.write8(dest + i, mem.read8(source + i));
|
||||||
|
|
|
@ -333,13 +333,7 @@ void IRUserService::updateCirclePadPro() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& response = cpp.state;
|
std::vector<u8> response(sizeof(cpp.state));
|
||||||
response.cStick.x = rand() & 0xFFF;
|
std::memcpy(response.data(), &cpp.state, sizeof(cpp.state));
|
||||||
response.cStick.y = static_cast<u32>(CirclePadPro::ButtonState::C_STICK_CENTER);
|
sendPayload(response);
|
||||||
response.buttons.zlNotPressed = 1;
|
|
||||||
response.buttons.rNotPressed = 1;
|
|
||||||
|
|
||||||
std::vector<u8> responsePayload(sizeof(response));
|
|
||||||
std::memcpy(responsePayload.data(), &response, sizeof(response));
|
|
||||||
sendPayload(responsePayload);
|
|
||||||
}
|
}
|
|
@ -613,6 +613,27 @@ void MainWindow::pollControllers() {
|
||||||
} else {
|
} else {
|
||||||
hid.setCirclepadY(-(stickY / div));
|
hid.setCirclepadY(-(stickY / div));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto& ir = emu->getServiceManager().getIRUser();
|
||||||
|
const s16 l2 = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_TRIGGERLEFT);
|
||||||
|
const s16 r2 = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_TRIGGERRIGHT);
|
||||||
|
const s16 cstickX = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_RIGHTX);
|
||||||
|
const s16 cstickY = SDL_GameControllerGetAxis(gameController, SDL_CONTROLLER_AXIS_RIGHTY);
|
||||||
|
|
||||||
|
ir.setZLPressed(l2 > 16000);
|
||||||
|
ir.setZRPressed(r2 > 16000);
|
||||||
|
|
||||||
|
if (std::abs(cstickX) < deadzone) {
|
||||||
|
ir.setCStickX(IR::CirclePadPro::ButtonState::C_STICK_CENTER);
|
||||||
|
} else {
|
||||||
|
ir.setCStickX(cstickX / 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std::abs(cstickY) < deadzone) {
|
||||||
|
ir.setCStickY(IR::CirclePadPro::ButtonState::C_STICK_CENTER);
|
||||||
|
} else {
|
||||||
|
ir.setCStickY(-(cstickY / 8));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue