mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-21 13:53:49 -07:00
Add cheat for easy pause buffering (#1439)
* Add cheat for easy pause buffering * Add pause input buffering * Fix pause input buffering * Changes from feedback * Convert frame to bool * Handle when pad is nullptr * Add newline * Split input buffering into it's own CVAR * Split SetShouldBlockGameInput up into to methods
This commit is contained in:
parent
d628bafe29
commit
936c493b9e
10 changed files with 60 additions and 11 deletions
|
@ -73,13 +73,11 @@ namespace Ship {
|
|||
}
|
||||
|
||||
void ControlDeck::WriteToPad(OSContPad* pad) const {
|
||||
bool shouldBlockGameInput = CVar_GetS32("gOpenMenuBar", 0) && CVar_GetS32("gControlNav", 0);
|
||||
|
||||
for (size_t i = 0; i < virtualDevices.size(); i++) {
|
||||
const std::shared_ptr<Controller> backend = physicalDevices[virtualDevices[i]];
|
||||
if (backend->GetGuid() == "Auto") {
|
||||
for (const auto& device : physicalDevices) {
|
||||
if(shouldBlockGameInput && device->GetGuid() != "Keyboard") {
|
||||
if(ShouldBlockGameInput() && device->GetGuid() != "Keyboard") {
|
||||
device->Read(nullptr, i);
|
||||
continue;
|
||||
}
|
||||
|
@ -87,7 +85,7 @@ namespace Ship {
|
|||
}
|
||||
continue;
|
||||
}
|
||||
if(shouldBlockGameInput && backend->GetGuid() != "Keyboard") {
|
||||
if(ShouldBlockGameInput() && backend->GetGuid() != "Keyboard") {
|
||||
backend->Read(nullptr, i);
|
||||
continue;
|
||||
}
|
||||
|
@ -258,4 +256,15 @@ namespace Ship {
|
|||
return controllerBits;
|
||||
}
|
||||
|
||||
}
|
||||
void ControlDeck::BlockGameInput() {
|
||||
shouldBlockGameInput = true;
|
||||
}
|
||||
|
||||
void ControlDeck::UnblockGameInput() {
|
||||
shouldBlockGameInput = false;
|
||||
}
|
||||
|
||||
bool ControlDeck::ShouldBlockGameInput() const {
|
||||
return shouldBlockGameInput || (CVar_GetS32("gOpenMenuBar", 0) && CVar_GetS32("gControlNav", 0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,9 +20,13 @@ namespace Ship {
|
|||
int32_t GetVirtualDevice(int32_t slot);
|
||||
size_t GetNumVirtualDevices();
|
||||
uint8_t* GetControllerBits();
|
||||
void BlockGameInput();
|
||||
void UnblockGameInput();
|
||||
bool ShouldBlockGameInput() const;
|
||||
private:
|
||||
std::vector<int32_t> virtualDevices = {};
|
||||
std::vector<std::shared_ptr<Controller>> physicalDevices = {};
|
||||
uint8_t* controllerBits = nullptr;
|
||||
bool shouldBlockGameInput = false;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -78,11 +78,11 @@ namespace Ship {
|
|||
padToBuffer.gyro_y = getGyroY(virtualSlot);
|
||||
|
||||
padBuffer.push_front(padToBuffer);
|
||||
if (pad != nullptr) {
|
||||
*pad = padBuffer[std::min(padBuffer.size(), (size_t)CVar_GetS32("gSimulatedInputLag", 0))];
|
||||
}
|
||||
|
||||
while (padBuffer.size() > 6) {
|
||||
if (pad != nullptr) {
|
||||
*pad = padBuffer[std::min(padBuffer.size(), (size_t)CVar_GetS32("gSimulatedInputLag", 0))];
|
||||
}
|
||||
|
||||
while (padBuffer.size() > 6) {
|
||||
padBuffer.pop_back();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue