Skip to content

Commit

Permalink
Start bringing back control map & menu checks.
Browse files Browse the repository at this point in the history
The copy-paste fix to clib seems to have fixed them.
  • Loading branch information
ceejbot committed Dec 29, 2023
1 parent 499ac7b commit 47b4d22
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/controller/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ impl Controller {
pub fn handle_key_event(&mut self, key: u32, button: &ButtonEvent) -> KeyEventResponse {
let hotkey = Hotkey::from(key);
let state = KeyState::from(button);
// log::info!(
// "{key} {} {hotkey} {state}",
// char::from_u32(key).unwrap_or('X')
// );
if matches!(hotkey, Hotkey::None) {
return KeyEventResponse::default();
}
Expand Down
5 changes: 3 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ void message_callback(SKSE::MessagingInterface::Message* msg)
MenuHook::install();
PlayerHook::install();
papyrus::registerPapyrusFunctions();
registerAllListeners();
}
break;
case SKSE::MessagingInterface::kPostLoadGame:
rlog::info("SKSE kPostLoadGame message received: type={};"sv, static_cast<uint32_t>(msg->type));
case SKSE::MessagingInterface::kNewGame:
// rlog::debug("SKSE post load-game / new game callback; type={}"sv, static_cast<uint32_t>(msg->type));
rlog::info("SKSE kNewGame post-hook done: type={};"sv, static_cast<uint32_t>(msg->type));
registerAllListeners();
rlog::info("SKSE kNewGame message received: type={};"sv, static_cast<uint32_t>(msg->type));
initialize_hud();
break;
default: break;
Expand Down
2 changes: 2 additions & 0 deletions src/plugin/sinks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ event_result KeyEventListener::ProcessEvent(RE::InputEvent* const* event_list,
// get chording events, so all the logic is now in the controller.
const KeyEventResponse response = handle_key_event(key, *button);
if (!response.handled) { continue; }
//rlog::info("mod handled key: {}", key);

if (response.stop_timer != Action::None)
{
Expand All @@ -115,6 +116,7 @@ event_result KeyEventListener::ProcessEvent(RE::InputEvent* const* event_list,
}

// Now wipe out the event data so nothing else acts on it.
// Is there a way to respond with `kStop` for just one event in the list?
button->idCode = keycodes::kInvalid;
button->userEvent = "";
} // end event handling for loop
Expand Down
9 changes: 6 additions & 3 deletions src/util/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ namespace helpers
bool playerInControl()
{
const auto* controlMap = RE::ControlMap::GetSingleton();
if (!controlMap) { return false; }
const auto canMove = controlMap->IsMovementControlsEnabled();
if (!controlMap)
{
rlog::info("no control map");
return false;
}
const auto canMove = controlMap->IsMovementControlsEnabled() && controlMap->IsActivateControlsEnabled();
return canMove;
}

Expand All @@ -105,7 +109,6 @@ namespace helpers
if (ui->GameIsPaused() || ui->IsMenuOpen("LootMenu")) return true;
if (!ui->IsCursorHiddenWhenTopmost() || !ui->IsShowingMenus() || !ui->GetMenu<RE::HUDMenu>()) { return true; }


// If we're not in control of the player character or otherwise not in gameplay, move on.
if (!playerInControl()) { return true; }
/*
Expand Down

0 comments on commit 47b4d22

Please sign in to comment.