CRpoll_event: Polls next pending event.

View source: R/CRpoll_event.R

CRpoll_eventR Documentation

Polls next pending event.

Description

Polls next event in event queue provided in graphics_list.

Usage

    CRpoll_event(graphics_list, status = NULL)

Arguments

graphics_list

List containing pointers to window, renderer etc. created with CRopen.

status

Optional list status with elements value and message to retrieve warnings and error messages.

Details

CRpoll_event returns a response_list.

Distinguish type of response (keyboard, mouse, etc.) by element type. Possible types are "key_down", "key_up", "mouse_button_down", "mouse_button_up", "mouse_motion", "mouse_wheel", "window_event", "controller_button_down", "controller_button_up", "controller_axis_motion", "quit".

Distinguish specific reaction by element code. Keyboard codes can be converted to Utf-8 strings via intToUtf8 or looked up at https://wiki.libsdl.org/SDLKeycodeLookup.

label gives more understandable descriptions of some events, such as window-events.

state encodes several keyboard states.

For mouse events, elements x and y indicate the mouse's position in the window area.

Element timestamp indicates when the OS registered the response.

Value

Returns NULL if no response is present in queue. Otherwise, a response_list specifying the polled response. Response_list contains elements type (type of event), code (specific event), label (description of event), state (some qualifying information of event), val (value for event), x and y (e.g. mouse coordinates), and timestamp (time of event).

Examples

  rout <- NULL
  
  while (!is.null(rout <- CRpoll_event(gs))) {
    
    if (rout$type == "window_event" && rout$label == "close") {
      
      run <- FALSE
      
    } else if (rout$type == "key_down") {
    
      RT <- CRget_time()
    
    }
  }

lorweiuk/CREx documentation built on March 16, 2024, 3:04 a.m.