the keyboard have two sets of buttons: those that can be represented using ASCII code and those that could not. the ones that can be represented in ASCII returns 1 byte when pressed, the ones that couldn't return two bytes the first of which is NULL
glut abstract this by giving you two set of functions to handle keyboard events: one to handle normal ASCII standard buttons glutKeyboardFunc, the other to handle special two byte buttons glutSpecialFunc
the special function have constants for common keyboard special buttons :
GLUT_KEY_F1:0x0001,
GLUT_KEY_F2:0x0002,
GLUT_KEY_F3:0x0003,
GLUT_KEY_F4:0x0004,
GLUT_KEY_F5:0x0005,
GLUT_KEY_F6:0x0006,
GLUT_KEY_F7:0x0007,
GLUT_KEY_F8:0x0008,
GLUT_KEY_F9:0x0009,
GLUT_KEY_F10:0x000A,
GLUT_KEY_F11:0x000B,
GLUT_KEY_F12:0x000C,
GLUT_KEY_LEFT:0x0064,
GLUT_KEY_UP:0x0065,
GLUT_KEY_RIGHT:0x0066,
GLUT_KEY_DOWN:0x0067,
GLUT_KEY_PAGE_UP:0x0068,
GLUT_KEY_PAGE_DOWN:0x0069,
GLUT_KEY_HOME:0x006A,
GLUT_KEY_END:0x006B,
GLUT_KEY_INSERT:0x006C,
GLUT_KEY_REPEAT_OFF:0x0000,
GLUT_KEY_REPEAT_ON:0x0001,
GLUT_KEY_REPEAT_DEFAULT:0x0002.
mouse clicks can be handled with the glutMouseFunc and the constants associated with the mouse buttons are:
GLUT_LEFT_BUTTON:0x0000,
GLUT_MIDDLE_BUTTON:0x0001,
GLUT_RIGHT_BUTTON:0x0002
glut can also handle joysticks with the glutJoystickFunc which has the following constants:
GLUT_HAS_JOYSTICK:0x0264,
GLUT_OWNS_JOYSTICK:0x0265,
GLUT_JOYSTICK_BUTTONS:0x0266,
GLUT_JOYSTICK_AXES:0x0267,
GLUT_JOYSTICK_POLL_RATE:0x0268,
GLUT_JOYSTICK_BUTTON_A:0x0001,
GLUT_JOYSTICK_BUTTON_B:0x0002,
GLUT_JOYSTICK_BUTTON_C:0x0004,
GLUT_JOYSTICK_BUTTON_D:0x0008.
if you are using a gaming mouse or a keyboard/joystick with more buttons you can test for what each button returns by outputting the button pressed to the console then directly use this value in your code to know if one of those button is pressed