VgaGames4

VgaGames4 - input man-pages

[.. upper level ..]

# vg4->input->key_insert()

Insert a key-entry.

SYNTAX
int vg4->input->key_insert(const char *name, VG_BOOL is_changeable, VG_BOOL is_nwkey)
FUNCTION PARAMETERS

name | A short description for this key-entry
is_changeable | Whether the key-codes can be changed, e.g. in a menu
is_nwkey | Whether this key-entry will be sent over network if active (network-key)

RETURN VALUE
Returns the key-entry reference-number (a positive arbitrary unique reference-number to this key-entry) or 0 if the maximal number of key-entries had been reached (VG_MAX_KEYENTRIES)
DESCRIPTION
Insert a key-entry. Before a key-stroke or a gamecontroller button/axis can be queried, it must be inserted with this function. The parameter is_changeable is informative and can be received via vg4->input->keylist(), where is_nwkey will be used automatically to send its key-events via network (if opened).
EXAMPLE

    /* set key-entries going left and right */

    struct {
      int k_goleft;
      int k_goright;
    } kref;

    /* insert key-entry "go left" */
    if ((kref.k_goleft = vg4->input->key_insert("Go left", VG_TRUE, VG_FALSE)) == 0) { VG_dest(); exit(1); }
    /* set it to left cursor key */
    vg4->input->key_setkbd(kref.k_goleft, VG_INPUT_KBDCODE_LCURS);
    /* set it also to right gamecontroller axis moving left for all found gamecontrollers */
    vg4->input->key_setgc(kref.k_goleft, 0, VG_INPUT_GCAXIS_RIGHTX_LEFT);

    /* insert key-entry "go right" */
    if ((kref.k_goright = vg4->input->key_insert("Go right", VG_TRUE, VG_FALSE)) == 0) { VG_dest(); exit(1); }
    /* set it to right cursor key */
    vg4->input->key_setkbd(kref.k_goright, VG_INPUT_KBDCODE_RCURS);
    /* set it also to right gamecontroller axis moving right for all found gamecontrollers */
    vg4->input->key_setgc(kref.k_goright, 0, VG_INPUT_GCAXIS_RIGHTX_RIGHT);

SEE ALSO
vg4->input->key_remove() vg4->input->key_setkbd() vg4->input->key_setgc() vg4->input->keylist()