Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Simple Case

The key a is pressed and released: 3 events fired by GLUTIN LIB

  1. Glutin::Event::KeyboardInput{element_state='Pressed', virtual_key_code: 'A')
  2. Glutin::Event::ReceivedCharacter{'a'}
  3. Glutin::Event::KeyboardInput{element_state='Released', virtual_key_code: 'A')

Complex Case

The keys Ctrl and a are pressed and released at the same time: 5 events fired by GLUTIN LIB

  1. Glutin::Event::KeyboardInput{element_state='Pressed', virtual_key_code: 'LCONTROL'}
  2. Glutin::Event::KeyboardInput{element_state='Pressed', virtual_key_code: '\u{1}'}
  3. Glutin::Event::ReceivedCharacter{'\u{1}'}
  4. Glutin::Event::KeyboardInput{element_state='Released', virtual_key_code: '\u{1}'}
  5. Glutin::Event::KeyboardInput{element_state='Released', virtual_key_code: 'LCONTROL'}

For the complex case, the character received is the ASCII Code of the combination: http://academic.evergreen.edu/projects/biophysics/technotes/program/ascii_ctrl.htm

Diagram for Simple Case

###############################################################################################################################
#
#                                          GLUTIN LIB
#
###############################################################################################################################
   ||                                         ||                                       ||  
   ||                                         ||                                       ||  
   ||                                         ||                                       ||              
 1. Glutin::Event::KeyboardInput        2. Glutin::Event::ReceivedCharacter        3. Glutin::Event::KeyboardInput
   ||                                         ||                                       ||
   ||                                         ||                                       ||  
   ||                                         ||                                       ||  
   \/                                         \/                                       \/
#############################################################################################################################
#                                        handle_window_event()
----------------------------------------------------------------------------------------------------------------------------- #                   
#                                           GLUTIN PORT
#
----------------------------------------------------------------------------------------------------------------------------- 
# handle_keyboard_input()           #      received_character()         #    handle_keyboard_input()    #     handle_key()   
#############################################################################################################################
     ||                                       ||                                        ||                          /\
     ||                                       ||                                        ||                          ||
     ||                                       ||                                        ||                          ||  
1. WindowEvent::KeyEvent                2. WindowEvent::KeyEvent                    3. WindowEvent::KeyEvent      4. Call to fn  
   (KeyState::Pressed)                    (KeyState::Pressed)                          (KeyState::Released)         ||
     ||                                       ||                                        ||                          ||
     ||                                       ||                                        ||                          ||
     ||                                       ||                                        ||                          ||               
     \/                                       \/                                        \/                          ||
###############################################################################################################################
#                                                 handle_events()
----------------------------------------------------------------------------------------------------------------------------- 
#
#                                             COMPOSITOR
#
################################################################################################################################
...
...Not shown here: Events are then sent to the Constellation, then script thread, then it comes back the other way...
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.