Results 1 to 4 of 4

Thread: Fully reading keyboard and mouse in GLUT and FPC

  1. #1

    Fully reading keyboard and mouse in GLUT and FPC

    I see GLUT events for keyboard and mouse aren't very powerful, it doesn't tell when keys are pressed and released. Also I'd prefer and event-less system. Are there any units to use with FPC that can read everything from the mouse and keyboard?

    Regards!
    -Marco

  2. #2

    Fully reading keyboard and mouse in GLUT and FPC

    The keyboard is fairly simple to get back, everything to do with the mouse is another story. Below is a simple IsKeyDown function that you can include to find out if any key (using VK's) is down or not. You should also be able to pass in a byte (eg: ord('a')) to find out if normal keys are pressed as well.[pascal]function IsKeyDown(vk: TVirtualKeyCode): Boolean;
    begin
    if active then
    result := GetAsyncKeyState(vk)<>0
    else
    result := false;
    end;[/pascal]

    If you find a way to get the mouse without using GLUT I'd love to hear it. I asked the same question almost a month ago and found no answers yet.

    If I remember properly, GetAsyncKeyState is defined in LCLIntf but it may have been in Windows. If its in Windows there is an identical version in Linux and Mac as I've compiled the above in all 3 environments.

  3. #3

    Fully reading keyboard and mouse in GLUT and FPC

    Thanks for that example, it will be very useful. Well, maybe I can stick to GLUT's mouse events, the keyboard was my main concern.

    And what about the joystick/paddle? Is there a way to read those devices? :?

  4. #4

    Fully reading keyboard and mouse in GLUT and FPC

    At the point that you start to want Joystick, Paddle, Game pad, Mouse, etc... Its actually easier and better (read A LOT LESS CODE and TIME) to switch to SDL. Use SDL to initialize your OpenGL window, then use standard OpenGL code to render. Now you can use all of the events and handlers surfaced in SDL. S2DL, Phoenix, and even the root JEDI-SDL surface great handlers for such things.

    The down side is that you have another set of DLL's to ship with your application (or a side set of instructions on how to install SDL for the target platforms). The up side is that you don't have to write all of the VERY custom code on each platform you plan on supporting.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •