Class: SDL2::Event::ControllerButton

Inherits:
SDL2::Event show all
Defined in:
event.c,
event.c

Overview

This class represents the controller button events.

You don’t handle the instance of this class directly, but you handle the instances of two subclasses of this subclasses: ControllerButtonDown and ControllerButtonUp.

Direct Known Subclasses

ControllerButtonDown, ControllerButtonUp

Instance Attribute Summary collapse

Attributes inherited from SDL2::Event

#timestamp, #type

Instance Method Summary collapse

Methods inherited from SDL2::Event

enable=, enabled?, poll, #window

Instance Attribute Details

#buttonInteger

the controller button index

Returns:

  • (Integer)

#pressedBoolean

button is pressed or not

Returns:

  • (Boolean)

#whichInteger

the controller index

Returns:

  • (Integer)

Instance Method Details

#inspectString

Returns inspection string

Returns:

  • (String)

    inspection string



854
855
856
857
858
859
860
861
862
863
# File 'event.c', line 854

static VALUE ControllerButton_inspect(VALUE self)
{
    SDL_Event* ev; Data_Get_Struct(self, SDL_Event, ev);
    return rb_sprintf("<%s: type=%u timestamp=%u"
                      " which=%d button=%s state=%s>",
                      rb_obj_classname(self), ev->common.type, ev->common.timestamp,
                      ev->cbutton.which,
                      SDL_GameControllerGetStringForButton(ev->cbutton.button),
                      INT2BOOLCSTR(ev->cbutton.state));
}