views:

170

answers:

1

I'm using GLUT (freeglut3) (via the Haskell GLUT bindings).

import Graphics.UI.GLUT

handleKBMouse :: KeyboardMouseCallback
handleKBMouse key keyState mods mousePos = do
    print (key, keyState, mods, mousePos)

main :: IO ()
main = do
    getArgsAndInitialize
    createWindow "testTitle"
    keyboardMouseCallback $= Just handleKBMouse
    mainLoop

It seems that various important keys (e.g: Shift+Tab) do not call my callback. Also, "mods" doesn't describe the win-key, only Ctrl, Shift and Alt.

Having such limited access to keyboard input is a serious impediment for real application development. Am I doing anything wrong here or is just freeglut just crippled? Is GLUT crippled in general?

+2  A: 

First, Windows traps the shift-tab sequence, so even if you work directly with Win32 you won't normally see it. Second, GLUT is intended to be portable, so unless you can expect to see the same key under Linux, MacOS, etc., chances are that GLUT won't even attempt to deal with it. Third, the GLUT spec was last updated a long time ago, so even if the win-key (or at least something similar) is pretty common now, if it wasn't 12 or 15 years ago, GLUT probably won't know about it.

Jerry Coffin
I used this code with Ubuntu, not Windows.I don't think Windows traps "shift+Tab".If GLUT only knows about things that existed 12 years ago, is it not a crippling limitation?
Peaker
Oops -- it's alt+tab that Windows traps; I apologize. IMO, about the only real use for GLUT is things like testing and/or demos. I doubt I'd really even *consider* using it in code to be delivered to a customer (except, possibly, in something like a mock-up that was never intended for real use).
Jerry Coffin
I see. I am beginning to form that opinion myself :-)The question is, what window-system-independent library is there for input devices? SDL is the closest I've seen, but it has issues with OS X, at least when the Haskell bindings are in use.
Peaker
Window-system-independent is pretty easy -- but "has solid, well-tested Haskell bindings" makes things quite a bit more difficult in a hurry. For something like C or C++, I'd look at FLTK and/or glfw -- but I'm not sure either supports Haskell.
Jerry Coffin