0

I am working on a game using OpenGL and I noticed that I have to register a

glutMouseFunc(void (*func)(int button, int state, int x, int y))

to detect mouse presses and releases, but I have to register a

glutKeyboardFunc(void (*func)(unsigned char button, int x, int y)) and a

glutKeyboardUpFunc(void (*func)(unsigned char button, int x, int y)) (both of which I pipe to the function handleKey(char state unsigned char button, int x, int y) function anyway) to do the same thing for key presses. Why doesn't glutKeyboardFunc just pass the state like glutMouseFunc does?

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
Jesse McDonald
  • 159
  • 1
  • 10
  • 1
    An average mouse has 3-5 buttons (left,right, middle, and maybe some thumb buttons). You can therefore encode the state of the mouse buttons in a single 8-bit bitmask. An average keyboard has 100+. You would thus need at least 100 bits to keep the entire state, 90% of which would be zeroes. – Botje Apr 13 '18 at 12:04
  • State is the state of the button passed, which brings up another question... why is mouse button an int but keyboard is a char – Jesse McDonald Apr 14 '18 at 21:21

0 Answers0