Results 1 to 6 of 6

Thread: SDL.pas missing windowing events?!?

  1. #1

    Exclamation SDL.pas missing windowing events?!?

    Hi all,
    I am trying to detect when the mouse enters/leaves my SDL window in my game "The Probe" so I can show/hide my self-rendered mouse pointer.

    I did some googling and found this site:
    http://wiki.libsdl.org/moin.cgi/SDL_WindowEvent

    Unfortunately, I don't have any of those window events defined in my copy of SDL.pas!

    Any ideas?

    cheers,
    Paul

  2. #2
    As far as I see SDL_WindowEvent is only present in SDL 1.3 but not in SDL 1.2 wich ships with FPC Lazarus.

  3. #3
    I ran across the same issue recently. You might want to read this C++ tutorial from LazyFoo: http://lazyfoo.net/SDL_tutorials/lesson26/index.php
    The interesting part about this is detecting SDL_APPMOUSEMOCUS through event.active.state where event is TSDL_Event in your event loop.
    There is a small bug with that though, if your mouse cursor is over the application when the application starts, the event is not recognized, but if you move the mouse away from the window and then back into the window, it works again.
    Freeze Development | Elysion Game Framework | Twitter: @Stoney_FD
    Check out my new book: Irrlicht 1.7.1 Realtime 3D Engine Beginner's Guide (It's C++ flavored though)

    Programmer: A device for converting coffein into software.

  4. #4
    @SilverWarior: Thanks for the info, I am not going to use SDL 1.3 at this time so I will think of an other way
    @Stoney: Ok, I will take a look at that site...thanks for the info

    EDIT: hmm...I think I might have just thought of a way around my issue, but I need to test it first
    I am going to test the mouse position each frame and if it is within a small border around the screen, then I will not render the cursor.
    If that doesn't work, I will try the SDL_APPMOUSEMOCUS way and see how that goes..

    cheers,
    Paul
    Last edited by paul_nicholls; 01-01-2012 at 02:11 AM. Reason: type

  5. #5
    Quote Originally Posted by paul_nicholls View Post
    hmm...I think I might have just thought of a way around my issue, but I need to test it first
    I am going to test the mouse position each frame and if it is within a small border around the screen, then I will not render the cursor.
    If that doesn't work, I will try the SDL_APPMOUSEMOCUS way and see how that goes..
    Ok, that works, but not if I move the mouse too fast...and it looks strange with the mouse appearing/disappearing with the border test

    I will try the SDL_APPMOUSEMOCUS​ now then

  6. #6
    Quote Originally Posted by paul_nicholls View Post
    hmm...I think I might have just thought of a way around my issue, but I need to test it first
    I am going to test the mouse position each frame and if it is within a small border around the screen, then I will not render the cursor
    If you are testing the mouse position every frame you could simply check whether it's position is over your window instead just for smal border.

    Another idea: When creating your SDL window do you have an option to set default cursor type for it. In windows each window can have it's default cursor type set. This causes mouse cursor to automaticly change as soon as the mouse cursor moves over that window. If you can then you can just set your SDL window's default curspor type to crNone and then programaticly check what is the current cursor type each frame. So when mouse cursor type is set to crNone you know that the mouse cursor is over your window and you need to render your ingame cursor, if mouse cursor is set to anything else then it probably isn't over your window so no ingame cursor renderning is requred.

Tags for this Thread

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
  •