Mercurial > projects > mde
view mde/input/input.d @ 0:d547009c104c
Repository creation.
committer: Diggory Hardy <diggory.hardy@gmail.com>
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sat, 27 Oct 2007 18:05:39 +0100 |
parents | |
children | 78eb491bd642 |
line wrap: on
line source
/** This module contains the interface to the input system; it should be the only module of the * input package imported from outside this package. */ module mde.input.input; /+import derelict.sdl.events; import mde.input.core; import mde.input.config; import mde.input.eventstream; /// Get key status at this ID bool button (uint id) { return b_tbl[cast(index_t) id]; } /// Get axis status at this ID (range -1.0 .. 1.0) real axis (uint id) { return axis_tbl[cast(index_t) id]; } /** Get mouse pointer position in screen coordinates. * Window managers only support one mouse, so there will only be one screen coordinate. * Unlike everything else, this is not configurable. */ void mouseScreenPos (uint x, uint y) { x = mouse_x; y = mouse_y; } /** Get relative mouse position (also for joystick balls). * * Converts to a real via sensitivity settings (defaults may be set and overriden per item). * * To avoid confusion over the ID here, the idea is for the input-layer upward to support * multiple mice, even though it's unlikely for the input system itself to support them. Also * joystick balls (supported by SDL) can be used in the same way as a mouse for relative * positions. Thus this must be configured only on one-mouse systems. */ void mouseRelativePos (out real x, out real y, uint id) { RelPair rp = axis_rel_tbl[cast(index_t) id]; x = rp.x; y = rp.y; } /// As it says. Optional. bool modifierStatus (uint id); /// Adds a callback delegate for key with this ID for both DOWN and UP events. /// Passes current status. void addKeyCallback (void delegate(bool) dg); /// Similar function for axis events. void addAxisCallback (void delegate(real) dg); /** Similar function for mouse/joystick ball motion. * Last parameter is true if it's for the window-manager mouse (use mouseScreenPos to get * mouse screen position). */ void addMouseCallback (void delegate(real,real,bool) dg); /** Feed an SDL_Event struct (only uses if it's a key, mouse or joystick event). * Other types of event functions may be added. */ void SDLEvent (SDL_Event event); +/