class Joystick::Event
Public Instance Methods
number()
click to toggle source
Returns the number of the axis or button responsible for the event.
VALUE js_event_number(VALUE klass) { int *fd; Data_Get_Struct(klass, int, fd); return INT2FIX((fd && *fd >= 0) ? jse[*fd].number : -1); }
time()
click to toggle source
Returns the time, in milliseconds, that the event occurred. TODO what is time 0?
VALUE js_event_time(VALUE klass) { int *fd; Data_Get_Struct(klass, int, fd); return INT2FIX((fd && *fd >= 0) ? jse[*fd].time : -1); }
type()
click to toggle source
Returns the type of the event. Normally this should either be either :axis or :button. If “something goes wrong”, the numerical type is returned.
VALUE js_event_type(VALUE klass) { int *fd; Data_Get_Struct(klass, int, fd); switch(((fd && *fd >= 0) ? jse[*fd].type : -1) & ~JS_EVENT_INIT) { case JS_EVENT_AXIS: return ID2SYM(rb_intern("axis")); case JS_EVENT_BUTTON: return ID2SYM(rb_intern("button")); default: return INT2FIX(((fd && *fd >= 0) ? jse[*fd].type : -1) & ~JS_EVENT_INIT); } }
value()
click to toggle source
Returns the value of the event, which is internally a signed 16-bit integer. It can range from -32768 to 32767.
VALUE js_event_value(VALUE klass) { int *fd; Data_Get_Struct(klass, int, fd); return INT2FIX((fd && *fd >= 0) ? jse[*fd].value : -1); }