Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add class 'GamepadDevice'. For normalized asignment of axis and button and Hot-Plug. #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HiroshiYAMA
Copy link
Contributor

Each game controllers are assigned a different button number, so normalize it using the SDL2 library.

Requirement:

  • 'sudo apt install libsdl2-dev'.
  • -std=c++14

ex.)

auto gamepad = GamepadDevice::Create();
...
while (...)
{
  ...
  gamepad->Poll(1000);
  ...
  if (gamepad->IsAttached()) {
    if (gamepad->IsButtonDown()) {
      if (gamepad->GetButton_A == 1) {
        ... // Processing when button A is pressed.
      }
    }
  }
  ...
}

…n and hot plug.

---
Need SDL2 library. 'sudo apt install libsdl2-dev'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant