Skip to content

Instantly share code, notes, and snippets.

@voidproc
Last active September 23, 2021 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voidproc/4e901a58ed2f7834140d7460fa4c7a84 to your computer and use it in GitHub Desktop.
Save voidproc/4e901a58ed2f7834140d7460fa4c7a84 to your computer and use it in GitHub Desktop.
OpenSiv3D v0.6.0 キーボードとマウスの押されているボタンをすべて表示
# include <Siv3D.hpp> // OpenSiv3D v0.6.0
String commaSeparatedInputNames(const Array<Input>& inputs)
{
return inputs.map([](const auto& x) { return x.name(); })
.join(U", ", U"", U"");
}
void Main()
{
Scene::SetBackground(ColorF{ 0.0, 0.05, 0.1 });
Font font{ 32, Typeface::Bold };
while (System::Update())
{
Array<String> inputNames;
if (const auto keyInputs = Keyboard::GetAllInputs(); not keyInputs.isEmpty())
{
inputNames.push_back(commaSeparatedInputNames(keyInputs));
}
if (const auto mouseInputs = Mouse::GetAllInputs(); not mouseInputs.isEmpty())
{
inputNames.push_back(commaSeparatedInputNames(mouseInputs));
}
font(inputNames.join(U", ", U"", U"")).drawAt(Scene::Center(), ColorF{0.95, 0.98, 1.00});
}
}
@voidproc
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment