Results 1 to 7 of 7

Thread: Problem with Event.Key.KeySym.Mod

  1. #1

    Problem with Event.Key.KeySym.Mod

    I'm trying to use Event.Key.KeySym.Mod to check if SHIFT has been pressed/released, but I'm getting an error when trying to compile, as the Free Pascal compiler doesn't like '.Mod'. I'm guessing that's because of the standard Pascal 'MOD' function. How do I get around that?
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  2. #2

    Problem with Event.Key.KeySym.Mod

    Which version of FPC are you using? I've not come across this error yet.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  3. #3

    Problem with Event.Key.KeySym.Mod

    I'm using FPC 1.0.10 for Win32. The error message I'm getting when trying to compile is:

    'Syntax error, "identifier" expected but "mod" found'

    Some code excerpts:

    [pascal]VAR Event : TSDL_Event

    {...}

    WHILE SDL_PollEvent(@Event) <> 0 DO BEGIN
    CASE Event.Type_ OF
    SDL_KeyDown : BEGIN
    CASE Event.Key.KeySym.Sym OF
    SDLK_Up : KeyIsDown[KeyUp] := True;
    SDLK_Down : KeyIsDown[KeyDown] := True;
    SDLK_Right : KeyIsDown[KeyRight] := True;
    SDLK_Left : KeyIsDown[KeyLeft] := True;
    SDLK_Space : KeyIsDown[KeySpace] := True;
    SDLK_Q : Stop := True;
    SDLK_F12 : IF FullScreen THEN BEGIN
    TheScreen := SDL_SetVideoMode(640, 400, 0, SDL_SWSURFACE);
    FullScreen := False;
    END
    ELSE BEGIN
    TheScreen := SDL_SetVideoMode(640, 400, 0, SDL_SWSURFACE OR SDL_FULLSCREEN);
    FullScreen := True;
    END;
    END;
    CASE Event.Key.KeySym.Mod OF
    KMOD_Shift : WriteLineToScreenBuffer(1, 3, 0, 'SHIFT Pressed!');
    END;
    END;
    SDL_KeyUp : BEGIN
    CASE Event.Key.KeySym.Sym OF
    SDLK_Up : KeyIsDown[KeyUp] := False;
    SDLK_Down : KeyIsDown[KeyDown] := False;
    SDLK_Right : KeyIsDown[KeyRight] := False;
    SDLK_Left : KeyIsDown[KeyLeft] := False;
    SDLK_Space : KeyIsDown[KeySpace] := False;
    END;
    END;
    END;
    END;
    [/pascal]
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  4. #4

    Problem with Event.Key.KeySym.Mod

    Yikes 1.0.10!! May I suggest you upgrade to 2.2.x from http://sourceforge.net/project/showf...?group_id=2174
    as this will mean most people who use FPC will be beter able to help out.

    The 2.2.x compile is a much better compiler all round.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  5. #5

    Problem with Event.Key.KeySym.Mod

    I actually have no clue as to why I'm using such an old version of FPC. I downloaded it through the freepascal.org site only a month ago. I guess I must have clicked a wrong link somewhere!

    I'll install the new version and give it a go.
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  6. #6

    Problem with Event.Key.KeySym.Mod

    Are You sure it is Event.Key.KeySym.Mod not Event.Key.KeySym.Modifier?

  7. #7

    Problem with Event.Key.KeySym.Mod

    Yeah, you're right. It's Modifier not Mod. I was thrown off by some C code using SDL. However, I've just discovered that I can also capture SHIFT by using SDLK_LSHIFT and SDLK_RSHIFT, which is a lot easier for my needs. Yay!

    In other news, I've actually got the latest version of FPC installed. I misread the version of the IDE as the version of the compiler. ops:
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

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
  •