Last active
December 15, 2015 15:59
-
-
Save ChunChunMorning/08b88b72ba99e2421019 to your computer and use it in GitHub Desktop.
Siv3Dでキーボードとゲームパッドの両方に簡単に対応させる No5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# include <Siv3D.hpp> | |
# include "AscInput.hpp" | |
using namespace asc; | |
void Main() | |
{ | |
asc::Input input; | |
Gamepad gamepad(0); | |
XInput xinput(0); | |
xinput.setLeftThumbDeadZone(); | |
input.addButton(L"fire", s3d::Input::KeyZ | Gamepad(0).button(2) | XInput(0).buttonA); | |
input.addAxis(L"x", Axis(s3d::Input::KeyRight, s3d::Input::KeyLeft) | Axis(gamepad, GamepadAxis::X) | Axis(xinput, XInputAxis::LeftThumbX)); | |
input.addAxis(L"y", Axis(s3d::Input::KeyUp, s3d::Input::KeyDown) | Axis(gamepad, GamepadAxis::Y) | Axis(xinput, XInputAxis::LeftThumbY)); | |
while (System::Update()) | |
{ | |
ClearPrint(); | |
Println(L"fire = ", input.button(L"fire").clicked); | |
Println(L"x = ", input.axis(L"x")); | |
input.enabled = !input.button(L"fire").pressed; | |
Println(L"(x,y) = ", input.vec2Normalized(L"x", L"y")); | |
input.enabled = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment