# Detecting controllers total button count

**URL:** <https://discourse.glfw.org/t/detecting-controllers-total-button-count/699>\
**Category:** support\
**Created:** [July 4, 2016, 2:11pm UTC](https://discourse.glfw.org/t/detecting-controllers-total-button-count/699 "2016-07-04T14:11:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![0xen](https://avatars.discourse-cdn.com/v4/letter/0/f05b48/32.png) [@0xen](https://discourse.glfw.org/u/0xen)\
**Post date:** [July 4, 2016, 2:11pm UTC](https://discourse.glfw.org/t/detecting-controllers-total-button-count/699/1 "2016-07-04T14:11:28Z")

</div>

I have been writing a controller class to interpret controller input into my game, but I can’t find any reference to getting the current controllers total button count. The reason I require this is so one every tick I can loop through the controller buttons and check their states.

Any advice?

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [July 4, 2016, 2:39pm UTC](https://discourse.glfw.org/t/detecting-controllers-total-button-count/699/2 "2016-07-04T14:39:02Z")

</div>

See [the documentation for glfwGetJoystickButtons](http://www.glfw.org/docs/latest/group__input.html#gace54cd930dcd502e118fe4021384ce1b). The variable pointed to by **count** will be modified to contain the number of button states returned for that joystick.
