From: Tobias Leich Date: Mon, 16 Nov 2009 14:24:43 +0000 (+0100) Subject: docu X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=767fbad8b9a84f5e0cd744a84436bfbb6daecbed;p=sdlgit%2FSDL-Site.git docu --- diff --git a/pages/SDL-Event.html-inc b/pages/SDL-Event.html-inc index 3372f58..a46cabc 100644 --- a/pages/SDL-Event.html-inc +++ b/pages/SDL-Event.html-inc @@ -8,12 +8,12 @@
  • METHODS
  • AUTHOR
  • @@ -213,8 +213,8 @@ which union member relates to which event type.

    -

    active

    -
    +

    Application visibility events

    +

    active is used when an event of type SDL_ACTIVEEVENT is reported.

    When the mouse leaves or enters the window area a SDL_APPMOUSEFOCUS type activation event occurs, if the mouse entered the window then gain will be 1, otherwise gain will be 0.

    @@ -245,8 +245,8 @@ This usually occurs when another application is made active.

    SDL_APPINPUTFOCUS if input focus was gained or lost, and SDL_APPACTIVE if the application was iconified (gain=0) or restored(gain=1).

    -

    key

    -
    +

    Keyboard events

    +

    key is used when an event of type SDL_KEYDOWN or SDL_KEYUP is reported.

    The type and state actually report the same information, they just use different values to do it. A keyboard event generally occurs when a key is released (type=SDL_KEYUP or key_state=SDL_RELEASED) @@ -265,58 +265,115 @@ These special cases are required for compatibility with Sun workstations.

    key_scancode

    +

    The scancode field should generally be left alone, it is the hardware-dependent scancode returned by the keyboard.

    key_sym

    +

    The sym field is extremely useful. It is the SDL-defined value of the key (see the keysym definitions in SDLKey). +This field is very useful when you are checking for certain key presses, like so:

    +
     while(poll_event($event))
    + {
    +     switch($event->type)
    +     {
    +         case SDL_KEYDOWN:
    +             move_left() if($event->key_sym == SDLK_LEFT);
    +             break;
    +         .
    +         .
    +         .
    +     }
    + }
    +
    +

    key_mod

    +

    mod stores the current state of the keyboard modifiers as explained in SDL_GetModState.

    key_unicode

    +

    The unicode field is only used when UNICODE translation is enabled with SDL_EnableUNICODE. +If unicode is non-zero then this is the UNICODE character corresponding to the keypress. +If the high 9 bits of the character are 0, then this maps to the equivalent ASCII character:

    +
     my $char;
    + if(($event->key_unicode & 0xFF80) == 0)
    + {
    +     $char = $event->key_unicode & 0x7F;
    + }
    + else
    + {
    +     print("An International Character.\n");
    + }
    +
    +
    +

    UNICODE translation does create a slight overhead so don't enable it unless its needed.

    +

    NOTE: Key release events (SDL_KEYUP) won't necessarily (ever?) contain unicode information. +See http://lists.libsdl.org/pipermail/sdl-libsdl.org/2005-January/048355.html

    -

    motion

    -
    +

    Mouse motion events

    +
    +

    Simply put, a SDL_MOUSEMOTION type event occurs when a user moves the mouse within the +application window or when SDL_WarpMouse is called. Both the absolute (motion_x and motion_y) +and relative (motion_xrel and motion_yrel) coordinates are reported along with the current +button states (motion_state).

    motion_state

    +

    The button state can be interpreted using the SDL_BUTTON macro (see SDL_GetMouseState).

    motion_x, motion_y

    +

    The X/Y coordinates of the mouse

    motion_xrel, motion_yrel

    +

    Relative motion in the X/Y direction.

    +

    If the cursor is hidden (SDL_ShowCursor(0)) and the input is grabbed (SDL_WM_GrabInput(SDL_GRAB_ON)), +then the mouse will give relative motion events even when the cursor reaches the edge of the screen. +This is currently only implemented on Windows and Linux/Unix-alikes.

    -

    button

    -
    +

    Mouse button events

    +
    +

    When a mouse button press or release is detected the number of the button pressed (from 1 to 255, +with 1 usually being the left button and 2 the right) is placed into button_button, the position of the mouse +when this event occured is stored in the button_x and the button_y fields. Like SDL_KeyboardEvent, +information on whether the event was a press or a release event is stored in both the button_type +and button_state fields, but this should be obvious.

    +

    Mouse wheel events are reported as buttons 4 (up) and 5 (down). Two events are generated i.e. you get +a SDL_MOUSEBUTTONDOWN followed by a SDL_MOUSEBUTTONUP event.

    button_which

    +

    The input device index

    button_button

    +

    The mouse button index (SDL_BUTTON_LEFT, SDL_BUTTON_MIDDLE, SDL_BUTTON_RIGHT, SDL_BUTTON_WHEELUP, +SDL_BUTTON_WHEELDOWN)

    button_state

    +

    SDL_PRESSED or SDL_RELEASED

    button_x, button_y

    +

    The X/Y coordinates of the mouse at press/release time

    -

    jaxis

    -
    +

    Joystick axis events

    +

    jaxis_which

    @@ -331,8 +388,8 @@ These special cases are required for compatibility with Sun workstations.

    -

    jbutton

    -
    +

    Joystick button events

    +

    jbutton_which

    @@ -347,8 +404,8 @@ These special cases are required for compatibility with Sun workstations.

    -

    jhat

    -
    +

    Joystick hat events

    +

    jhat_which

    @@ -363,8 +420,8 @@ These special cases are required for compatibility with Sun workstations.

    -

    jball

    -
    +

    Joystrick trackball events

    +

    jball_which

    @@ -379,28 +436,28 @@ These special cases are required for compatibility with Sun workstations.

    -

    resize

    -
    +

    Window resize events

    +

    resize_x, resize_y

    -

    expose

    -
    +

    Window expose events

    +
    -

    syswm

    -
    +

    System window manager events

    +

    syswm_msg

    -

    user

    -
    +

    User defined events

    +

    user_code

    @@ -411,8 +468,8 @@ These special cases are required for compatibility with Sun workstations.

    -

    quit

    -
    +

    Quit event

    +

    Create a new SDL::Event object.