Skip to content
slaeshjag edited this page Mar 24, 2013 · 5 revisions

DARNIT_KEYACTION

Used by DARNIT_KEY_RAW to specify if it was a press or release event.

typedef enum {
        DARNIT_KEYACTION_PRESS = 1,
        DARNIT_KEYACTION_RELEASE = 2,
} DARNIT_KEYACTION;

DARNIT_KEYS

This struct contains keystatus for all main input keys. 0 means key is not pressed, 1 means the key is pressed.

typedef struct {
        unsigned int    left            : 1;
        unsigned int    right           : 1;
        unsigned int    up              : 1;
        unsigned int    down            : 1;
        unsigned int    x               : 1;
        unsigned int    y               : 1;
        unsigned int    a               : 1;
        unsigned int    b               : 1;
        unsigned int    start           : 1;
        unsigned int    select          : 1;
        unsigned int    l               : 1;
        unsigned int    r               : 1;
        unsigned int    lmb             : 1;    /* Left mouse button */
        unsigned int    rmb             : 1;    /* Right mouse button */
        unsigned int    padding         : 2;    /* Not used for anything */

        /* Modifier keys (SHIFT, CTRL, ALT etc..) */
        unsigned int    mod_lshift      : 1;
        unsigned int    mod_rshift      : 1;
        unsigned int    mod_lctrl       : 1;
        unsigned int    mod_rctrl       : 1;
        unsigned int    mod_lalt        : 1;
        unsigned int    mod_ralt        : 1;
        unsigned int    mod_lmeta       : 1;
        unsigned int    mod_rmeta       : 1;
        unsigned int    mod_num         : 1;
        unsigned int    mod_caps        : 1;
        unsigned int    mod_mode        : 1;
} DARNIT_KEYS;

DARNIT_KEY_RAW

Raw keyboard events. Suitable for text input etc..

typedef struct {
        int                     keysym;
        DARNIT_KEYACTION        action;
        int                     unicode;
} DARNIT_KEY_RAW;

If unicode is enabled, the field unicode contains the unicode representation of the key just pressed. Keysym is just a standard SDL keysym value.

DARNIT_MOUSE

Contains status information about mouse position

typedef struct {
        unsigned int    x       : 16;
        unsigned int    y       : 16;
        signed int      wheel   : 32;
        unsigned int    lmb     : 1;
        unsigned int    rmb     : 1;
} DARNIT_MOUSE;

Note that wheel is relative. It resets every time you request mouse status.

  • x - X coordinate for mouse cursor
  • y - Y coordinate for mouse cursor
  • wheel - Delta value for scroll wheel (negative is up, positive is down)
  • lmb - Left mouse button
  • rmb - Right mouse button

DARNIT_INPUT_MAP

This is the keymapping struct used to remap the main input keys. All values are normal SDL keysyms that maps to the keys. Click here for default key mappings for different systems.

typedef struct {
        unsigned int                    up;
        unsigned int                    down;
        unsigned int                    left;
        unsigned int                    right;
        unsigned int                    x;
        unsigned int                    y;
        unsigned int                    a;
        unsigned int                    b;
        unsigned int                    start;
        unsigned int                    select;
        unsigned int                    l;
        unsigned int                    r;
} DARNIT_INPUT_MAP;

DARNIT_INPUT

Various functions to get status about the supported input devices

  • DARNIT_KEYS d_keys_get();
  • void d_keys_set(DARNIT_KEYS keys);
  • DARNIT_KEYS d_keys_zero();
  • void d_input_grab();
  • void d_input_release();
  • DARNIT_MOUSE d_mouse_get();
  • void d_keymapping_reset();
  • void d_keymapping_set(DARNIT_INPUT_MAP map);
  • DARNIT_INPUT_MAP d_keymapping_get();
  • void d_joystick_get(int *js0_x, int *js0_y, int *js1_x, int *js1_y);
  • void d_key_raw_push(int sym, DARNIT_KEYACTION action, int unicode);
  • DARNIT_KEY_RAW d_key_raw_pop();
  • void d_key_raw_clear();
  • void d_input_unicode(int enable);
  • const char *d_key_name_get(int sym);

Clone this wiki locally