VgaGames4

VgaGames4 - dialog man-pages

[.. upper level ..]

# vg4->dialog->keydef()

Open a canvas-dialog to re-define keys of the keyboard or a gamecontroller.

SYNTAX
VG_BOOL vg4->dialog->keydef(const char *cvasdir, const struct VG_Position *posdst, struct VG_Hash *hvar, int gcid)
FUNCTION PARAMETERS

cvasdir | Directory to load canvasses from, or NULL = use system-canvasses
posdst | Canvas-position on window, or NULL = centered
hvar | Hash with variable-values (see vg4->canvas->load())
gcid | Device - 0 = keyboard - >0 = gamecontroller-ID - -1 = let user select the gamecontroller

RETURN VALUE
Returns boolean: - VG_TRUE: OK - VG_FALSE: Got exit-request
DESCRIPTION
Open a canvas-dialog to re-define keys of the keyboard or a gamecontroller. This function uses following canvas-files (installed below share/vgagames4/canvas/) - keydef.top.cvas: Top-canvas - keydef.gclist.cvas: Canvas for user-selecting a gamecontroller - keydef.press.cvas: Sub-canvas for pressing a key/button The parameter hvar should contain following variables - key: top:title value: title of top-canvas - key: top:device value: title of a specific gamecontroller, or may be empty for keyboard - key: press:title value: title of sub-canvas for pressing a key/button If own canvas-files shall be used instead of the system-canvas-files, they must lay in cvasdir or cvasdir/keydef/ and have the same names as the system-canvas-files: - keydef.top.cvas - uses canvas-items: - [CV-TEXT] with name title: text for title - [CV-TEXT] with name device: device-name - [CV-BUTTON] with name done: for returning - [CV-LIST] with name keylist: for the list of defined keys - uses variables: - key: title value: title of canvas - key: device value: name of the gamecontroller or empty if keyboard - keydef.gclist.cvas - uses canvas-items: - [CV-LIST] with name gclist: for the list of gamecontrollers - uses variables: none - keydef.press.cvas - uses canvas-items: - [CV-TEXT] with name title: text for title - [CV-TEXT] with name keyname: name of current key - [CV-UNIQKEY] with name keypress: for pressing a key - uses variables: - key: title value: title of canvas - key: keyname value: name of the current key
EXAMPLE

      struct VG_Hash *hvar;
      struct VG_GCList gclist;

      hvar = vg4->hash->create();

      /* set variables */
      vg4->hash->setstr(hvar, "top:title", "Key Redefinition");
      vg4->hash->setstr(hvar, "press:title", "Press Key");

      vg4->input->gclist(&gclist);

      /* execute dialog */
      if (!vg4->dialog->keydef(NULL, NULL, hvar, (gclist.max > 0 ? -1 : 0))) {
        /* exit request */
        VG_dest();
        exit(0);
      }

      vg4->hash->destroy(hvar);