Zippy-Egoboo Home EgoWiki > Documentation > MakingZippyObjects > ZippyKeysyms EgoWiki webs:
Main | TWiki | Know | Sandbox
Documentation . { Changes | Index | Search | Go }

SDL Keysyms in Zippy

Zippy (as of 0.0.5) defines a number of methods and constants for using the SDLK_ and SDLM_ constants (see the SDL documentation at http://sdldoc.csn.ul.ie/sdlkey.php#AEN4743 on these constants). The constants have the same names as those in the above-mentioned document. In addition, the following methods exist to work with them:

key_to_char(key)
key_to_string(key)
key_to_constant(key)

These functions each return a string with the corresponding character (if applicable), key name, or constant name, respectively, for key. If key_to_char() is called with a key that does not have a corresponding ASCII symbol, nil is returned.

has_num(mod)
has_caps(mod)
has_left_control(mod)
has_right_control(mod)
has_left_shift(mod)
has_right_shift(mod)
has_left_alt(mod)
has_right_alt(mod)
has_control(mod)
has_alt(mod)
has_shift(mod)

These functions return true if mod includes the named modifier. has_control(), has_shift(), and has_alt() return true if mod has either the left-hand version of the modifier or the right-hand version.

Because the value of a modifier may not be one of the global constants (for example, if multiple modifier keys are pressed at once), you should use these functions rather than a straight comparison to determine if a modifier is pressed. A conditional such as:

if mod == SDLM_LCONTROL then
  -- do something...
end

Will only apply if only the left control key was pressed to produce mod.

EgoCodes

EgoCodes represent the range of possible user inputs to Zippy. EgoCode events may be generated with the following function:

generate_egocode(player, egocode, state)

A call to this function generates an egocode event for the numbered player (acceptable values are from one to four) using the given egocode (see below). The event generated is that the given egocode has transitioned to the given state, which is interpreted as a Lua boolean value (either nil or non-nil).

The following "constants" are defined for use with this function:

-- ElminI - 28 Jan 2005

Topic ZippyKeysyms . { Edit | Attach | Ref-By | Printable | Diffs | r1.2 | > | r1.1 | More }
Revision r1.2 - 28 Jan 2005 - 23:22 GMT - ElminI
Parents: WebHome > MakingZippyObjects
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding EgoWiki? Send feedback.