Class: Joystick::Event
- Inherits:
-
Object
- Object
- Joystick::Event
- Defined in:
- ext/joystick.c
Instance Method Summary collapse
-
#number ⇒ Object
Returns the number of the axis or button responsible for the event.
-
#time ⇒ Object
Returns the time, in milliseconds, that the event occurred.
-
#type ⇒ Object
Returns the type of the event.
-
#value ⇒ Object
Returns the value of the event, which is internally a signed 16-bit integer.
Instance Method Details
#number ⇒ Object
Returns the number of the axis or button responsible for the event.
295 296 297 298 299 300 |
# File 'ext/joystick.c', line 295
VALUE js_event_number(VALUE klass)
{
int *fd;
Data_Get_Struct(klass, int, fd);
return INT2FIX((fd && *fd >= 0) ? jse[*fd].number : -1);
}
|
#time ⇒ Object
Returns the time, in milliseconds, that the event occurred. TODO what is time 0?
332 333 334 335 336 337 |
# File 'ext/joystick.c', line 332
VALUE js_event_time(VALUE klass)
{
int *fd;
Data_Get_Struct(klass, int, fd);
return INT2FIX((fd && *fd >= 0) ? jse[*fd].time : -1);
}
|
#type ⇒ Object
Returns the type of the event. Normally this should either be either :axis or :button. If “something goes wrong”, the numerical type is returned.
310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
# File 'ext/joystick.c', line 310
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 ⇒ Object
Returns the value of the event, which is internally a signed 16-bit integer. It can range from -32768 to 32767.
346 347 348 349 350 351 |
# File 'ext/joystick.c', line 346
VALUE js_event_value(VALUE klass)
{
int *fd;
Data_Get_Struct(klass, int, fd);
return INT2FIX((fd && *fd >= 0) ? jse[*fd].value : -1);
}
|