Skip to content

Commit

Permalink
Add input templates from ssGUIManager to backend input... (8F47mDvMZZ)
Browse files Browse the repository at this point in the history
Add input templates from ssGUIManager to backend input interface (8F47mDvMZZ)
  • Loading branch information
Neko-Box-Coder committed Aug 27, 2023
1 parent b469ee7 commit 21a6ccd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 39 deletions.
27 changes: 27 additions & 0 deletions Include/ssGUI/Backend/Interfaces/BackendSystemInputInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,33 @@ namespace Backend
return IsButtonOrKeyPressExistCurrentFrame(static_cast<ssGUI::Enums::GenericButtonAndKeyInput>(input));
}

//function: IsButtonOrKeyDown
//See <IsButtonOrKeyPressExistCurrentFrame> and <IsButtonOrKeyPressExistLastFrame>
template<typename T>
bool IsButtonOrKeyDown(T input) const
{
return IsButtonOrKeyPressExistCurrentFrame(static_cast<ssGUI::Enums::GenericButtonAndKeyInput>(input)) &&
!IsButtonOrKeyPressExistLastFrame(static_cast<ssGUI::Enums::GenericButtonAndKeyInput>(input));
}

//function: IsButtonOrKeyHeld
//See <IsButtonOrKeyPressExistCurrentFrame> and <IsButtonOrKeyPressExistLastFrame>
template<typename T>
bool IsButtonOrKeyHeld(T input) const
{
return IsButtonOrKeyPressExistCurrentFrame(static_cast<ssGUI::Enums::GenericButtonAndKeyInput>(input)) &&
IsButtonOrKeyPressExistLastFrame(static_cast<ssGUI::Enums::GenericButtonAndKeyInput>(input));
}

//function: IsButtonOrKeyUp
//See <IsButtonOrKeyPressExistCurrentFrame> and <IsButtonOrKeyPressExistLastFrame>
template<typename T>
bool IsButtonOrKeyUp(T input) const
{
return !IsButtonOrKeyPressExistCurrentFrame(static_cast<ssGUI::Enums::GenericButtonAndKeyInput>(input)) &&
IsButtonOrKeyPressExistLastFrame(static_cast<ssGUI::Enums::GenericButtonAndKeyInput>(input));
}

//function: GetLastMousePosition
//Get mouse position relative to the mainWindow from last frame. If nullptr is passed, it will return global mouse position instead.
virtual glm::ivec2 GetLastMousePosition(ssGUI::Backend::BackendMainWindowInterface* mainWindow) const = 0;
Expand Down
30 changes: 6 additions & 24 deletions Include/ssGUI/ssGUIManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,45 +256,27 @@ namespace ssGUI
float GetTargetFramerate();

//function: IsButtonOrKeyDown
//See <ssGUI::Backend::BackendSystemInputInterface::IsButtonOrKeyPressExistCurrentFrame> and
//<ssGUI::Backend::BackendSystemInputInterface::IsButtonOrKeyPressExistLastFrame>
bool IsButtonOrKeyDown(ssGUI::Enums::GenericButtonAndKeyInput input) const;

//function: IsButtonOrKeyDown
//See <ssGUI::Backend::BackendSystemInputInterface::IsButtonOrKeyPressExistCurrentFrame> and
//<ssGUI::Backend::BackendSystemInputInterface::IsButtonOrKeyPressExistLastFrame>
//See <ssGUI::Backend::BackendSystemInputInterface::IsButtonOrKeyDown>
template<typename T>
bool IsButtonOrKeyDown(T input) const
{
return IsButtonOrKeyDown(static_cast<ssGUI::Enums::GenericButtonAndKeyInput>(input));
return BackendInput->IsButtonOrKeyDown(input);
}

//function: IsButtonOrKeyHeld
//See <ssGUI::Backend::BackendSystemInputInterface::IsButtonOrKeyPressExistCurrentFrame> and
//<ssGUI::Backend::BackendSystemInputInterface::IsButtonOrKeyPressExistLastFrame>
bool IsButtonOrKeyHeld(ssGUI::Enums::GenericButtonAndKeyInput input) const;

//function: IsButtonOrKeyHeld
//See <ssGUI::Backend::BackendSystemInputInterface::IsButtonOrKeyPressExistCurrentFrame> and
//<ssGUI::Backend::BackendSystemInputInterface::IsButtonOrKeyPressExistLastFrame>
//See <ssGUI::Backend::BackendSystemInputInterface::IsButtonOrKeyHeld>
template<typename T>
bool IsButtonOrKeyHeld(T input) const
{
return IsButtonOrKeyHeld(static_cast<ssGUI::Enums::GenericButtonAndKeyInput>(input));
return BackendInput->IsButtonOrKeyHeld(input);
}

//function: IsButtonOrKeyUp
//See <ssGUI::Backend::BackendSystemInputInterface::IsButtonOrKeyPressExistCurrentFrame> and
//<ssGUI::Backend::BackendSystemInputInterface::IsButtonOrKeyPressExistLastFrame>
bool IsButtonOrKeyUp(ssGUI::Enums::GenericButtonAndKeyInput input) const;

//function: IsButtonOrKeyUp
//See <ssGUI::Backend::BackendSystemInputInterface::IsButtonOrKeyPressExistCurrentFrame> and
//<ssGUI::Backend::BackendSystemInputInterface::IsButtonOrKeyPressExistLastFrame>
//See <ssGUI::Backend::BackendSystemInputInterface::IsButtonOrKeyUp>
template<typename T>
bool IsButtonOrKeyUp(T input) const
{
return IsButtonOrKeyUp(static_cast<ssGUI::Enums::GenericButtonAndKeyInput>(input));
return BackendInput->IsButtonOrKeyUp(input);
}

//function: GetMousePosition
Expand Down
15 changes: 0 additions & 15 deletions Src/ssGUI/ssGUIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,21 +714,6 @@ namespace ssGUI
return 1000 / TargetFrameInterval;
}

bool ssGUIManager::IsButtonOrKeyDown(ssGUI::Enums::GenericButtonAndKeyInput input) const
{
return BackendInput->IsButtonOrKeyPressExistCurrentFrame(input) && !BackendInput->IsButtonOrKeyPressExistLastFrame(input);
}

bool ssGUIManager::IsButtonOrKeyHeld(ssGUI::Enums::GenericButtonAndKeyInput input) const
{
return BackendInput->IsButtonOrKeyPressExistCurrentFrame(input) && BackendInput->IsButtonOrKeyPressExistLastFrame(input);
}

bool ssGUIManager::IsButtonOrKeyUp(ssGUI::Enums::GenericButtonAndKeyInput input) const
{
return !BackendInput->IsButtonOrKeyPressExistCurrentFrame(input) && BackendInput->IsButtonOrKeyPressExistLastFrame(input);
}

glm::ivec2 ssGUIManager::GetMousePosition(ssGUI::MainWindow* mainWindow) const
{
return BackendInput->GetCurrentMousePosition(mainWindow == nullptr ? nullptr : mainWindow->GetBackendWindowInterface());
Expand Down

0 comments on commit 21a6ccd

Please sign in to comment.