SDLGameEngine

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

Data Structures | Defines | Functions | Variables

# SgeEvent

Low level event handling. More...

## Data Structures
struct | SGEEVENTSTATEINPUT
struct | SGEEVENTSTATE
## Defines
#define | SGEEVENT SDL_Event
#define | EVENT_HANDLED 1
#define | EVENT_UNHANDLED 0
#define | MOUSE_LEFT SDL_BUTTON_LEFT
#define | MOUSE_RIGHT SDL_BUTTON_RIGHT
#define | MOUSE_MIDDLE SDL_BUTTON_MIDDLE
#define | MOUSE_WHEEL_UP SDL_BUTTON_WHEELUP
#define | MOUSE_WHEEL_DOWN SDL_BUTTON_WHEELDOWN
#define | PRESSED 1
#define | RELEASED 2
## Functions
int | sgeKeyUp (SDL_Event *e, int type)
| Check if the up button/key is at a certain state.
int | sgeKeyDown (SDL_Event *e, int type)
int | sgeKeyLeft (SDL_Event *e, int type)
int | sgeKeyRight (SDL_Event *e, int type)
int | sgeKeyStart (SDL_Event *e, int type)
int | sgeKeySelect (SDL_Event *e, int type)
int | sgeKeyFire (SDL_Event *e, int type)
int | sgeKeyL1 (SDL_Event *e, int type)
int | sgeKeyR1 (SDL_Event *e, int type)
int | sgeKeyA (SDL_Event *e, int type)
int | sgeKeyB (SDL_Event *e, int type)
int | sgeKeyX (SDL_Event *e, int type)
int | sgeKeyY (SDL_Event *e, int type)
int | sgeKeyVolUp (SDL_Event *e, int type)
int | sgeKeyVolDown (SDL_Event *e, int type)
void | sgeClearEvents (void)
| Clear the event queue.
void | sgeEventApply (SGEEVENTSTATE *state, SDL_Event *event)
| Update the current state of a game controller.
void | sgeEventResetInputs (SGEEVENTSTATE *state)
| Reset all button states of a game controller.
## Variables
Uint32 | SGEEVENTSTATEINPUT::pressed
Uint32 | SGEEVENTSTATEINPUT::released
SGEEVENTSTATEINPUT | SGEEVENTSTATE::down
SGEEVENTSTATEINPUT | SGEEVENTSTATE::right
SGEEVENTSTATEINPUT | SGEEVENTSTATE::left
SGEEVENTSTATEINPUT | SGEEVENTSTATE::start
SGEEVENTSTATEINPUT | SGEEVENTSTATE::select
SGEEVENTSTATEINPUT | SGEEVENTSTATE::fire
SGEEVENTSTATEINPUT | SGEEVENTSTATE::l1
SGEEVENTSTATEINPUT | SGEEVENTSTATE::r1
SGEEVENTSTATEINPUT | SGEEVENTSTATE::a
SGEEVENTSTATEINPUT | SGEEVENTSTATE::b
SGEEVENTSTATEINPUT | SGEEVENTSTATE::x
SGEEVENTSTATEINPUT | SGEEVENTSTATE::y
SGEEVENTSTATEINPUT | SGEEVENTSTATE::volUp
SGEEVENTSTATEINPUT | SGEEVENTSTATE::volDown

## Detailed Description

Low level event handling.

Event handling for joystick and keyboard events. This is the recommended way to handle user input on the gp2x and other handheld devices.

There is another way to handle events. sgeGamestate does provide event handlers which is a more flexible but harder to use system.

## Define Documentation

#define EVENT_HANDLED 1

Event handler return code if your handler did handle the event

Definition at line 45 of file sgeevent.h.

#define EVENT_UNHANDLED 0

Event handler return code if your handler did NOT handle the event

Definition at line 51 of file sgeevent.h.

#define MOUSE_LEFT SDL_BUTTON_LEFT

Left mouse button was pressed

Definition at line 57 of file sgeevent.h.

#define MOUSE_MIDDLE SDL_BUTTON_MIDDLE

Middle mouse button was pressed

Definition at line 67 of file sgeevent.h.

#define MOUSE_RIGHT SDL_BUTTON_RIGHT

Right mouse button was pressed

Definition at line 62 of file sgeevent.h.

#define MOUSE_WHEEL_DOWN SDL_BUTTON_WHEELDOWN

Mouse scroll wheel was moved down

Definition at line 77 of file sgeevent.h.

#define MOUSE_WHEEL_UP SDL_BUTTON_WHEELUP

Mouse scroll wheel was moved up

Definition at line 72 of file sgeevent.h.

#define PRESSED 1

A button or key was pressed

Definition at line 83 of file sgeevent.h.

#define RELEASED 2

A button or key was released

Definition at line 89 of file sgeevent.h.

#define SGEEVENT SDL_Event

Currently a alias to SDL_Event, may change, use SGEEVENT

Definition at line 39 of file sgeevent.h.

## Function Documentation

int sgeKeyA | ( | SDL_Event * | e,
|  | int | type
| ) |  |

See also:
  sgeKeyUp

Definition at line 106 of file sgeevent.c.

int sgeKeyB | ( | SDL_Event * | e,
|  | int | type
| ) |  |

See also:
  sgeKeyUp

Definition at line 110 of file sgeevent.c.

int sgeKeyDown | ( | SDL_Event * | e,
|  | int | type
| ) |  |

See also:
  sgeKeyUp

Definition at line 74 of file sgeevent.c.

int sgeKeyFire | ( | SDL_Event * | e,
|  | int | type
| ) |  |

See also:
  sgeKeyUp

Definition at line 94 of file sgeevent.c.

int sgeKeyL1 | ( | SDL_Event * | e,
|  | int | type
| ) |  |

See also:
  sgeKeyUp

Definition at line 98 of file sgeevent.c.

int sgeKeyLeft | ( | SDL_Event * | e,
|  | int | type
| ) |  |

See also:
  sgeKeyUp

Definition at line 78 of file sgeevent.c.

int sgeKeyR1 | ( | SDL_Event * | e,
|  | int | type
| ) |  |

See also:
  sgeKeyUp

Definition at line 102 of file sgeevent.c.

int sgeKeyRight | ( | SDL_Event * | e,
|  | int | type
| ) |  |

See also:
  sgeKeyUp

Definition at line 82 of file sgeevent.c.

int sgeKeySelect | ( | SDL_Event * | e,
|  | int | type
| ) |  |

See also:
  sgeKeyUp

Definition at line 90 of file sgeevent.c.

int sgeKeyStart | ( | SDL_Event * | e,
|  | int | type
| ) |  |

See also:
  sgeKeyUp

Definition at line 86 of file sgeevent.c.

int sgeKeyUp | ( | SDL_Event * | e,
|  | int | type
| ) |  |

Check if the up button/key is at a certain state.

Parameters:

  e | The current event
  type | PRESSED or RELEASED

Returns:
  0 or 1 depending if the button/key is equal to type

These function are platform dependant, for example, Up can be the cursor key on a pc, while on a game console its the Up button on the controller.

This applies to all sgeKey* functions with the corresponding button/key.

Definition at line 70 of file sgeevent.c.

int sgeKeyVolDown | ( | SDL_Event * | e,
|  | int | type
| ) |  |

See also:
  sgeKeyUp

Definition at line 126 of file sgeevent.c.

int sgeKeyVolUp | ( | SDL_Event * | e,
|  | int | type
| ) |  |

See also:
  sgeKeyUp

Definition at line 122 of file sgeevent.c.

int sgeKeyX | ( | SDL_Event * | e,
|  | int | type
| ) |  |

See also:
  sgeKeyUp

Definition at line 114 of file sgeevent.c.

int sgeKeyY | ( | SDL_Event * | e,
|  | int | type
| ) |  |

See also:
  sgeKeyUp

Definition at line 118 of file sgeevent.c.

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines