Updated the documentation to reflect the new key codes.

This commit is contained in:
marcus256 2011-01-17 22:41:58 +01:00
parent 8943a78a65
commit 0f0cff46f0
2 changed files with 52 additions and 33 deletions

View File

@ -1212,28 +1212,53 @@ differently on different systems. Do not make any assumptions about when or why
\begin{center} \begin{center}
\begin{tabular}{|l|l|} \hline \raggedright \begin{tabular}{|l|l|} \hline \raggedright
\textbf{Name} & \textbf{Description} \\ \hline \textbf{Name} & \textbf{Description} \\ \hline
GLFW\_KEY\_\textit{X} & Letter (\textit{X} can be in the range A..Z)\\ \hline
GLFW\_KEY\_\textit{n} & Number (\textit{n} can be in the range 0..9)\\ \hline
GLFW\_KEY\_SPACE & Space\\ \hline GLFW\_KEY\_SPACE & Space\\ \hline
GLFW\_KEY\_ESC & Escape\\ \hline GLFW\_KEY\_MINUS & Minus (-)\\ \hline
GLFW\_KEY\_EQUAL & Equal (=)\\ \hline
GLFW\_KEY\_LEFT\_BRACKET & Left bracket ([)\\ \hline
GLFW\_KEY\_RIGHT\_BRACKET & Right bracket (])\\ \hline
GLFW\_KEY\_GRAVE\_ACCENT & Grave accent (`)\\ \hline
GLFW\_KEY\_APOSTROPHE & Apostrophe (')\\ \hline
GLFW\_KEY\_COMMA & Comma (,)\\ \hline
GLFW\_KEY\_PERIOD & Period (.)\\ \hline
GLFW\_KEY\_SEMICOLON & Semicolon (;)\\ \hline
GLFW\_KEY\_SLASH & Slash ($/$)\\ \hline
GLFW\_KEY\_BACKSLASH & Backslash ($\backslash$)\\ \hline
GLFW\_KEY\_WORLD\_1 & Non-US character no. 1\\ \hline
GLFW\_KEY\_WORLD\_2 & Non-US character no. 2\\ \hline
\end{tabular}
\end{center}
\caption[Key codes for printable keys]{Key codes for printable keys. The keys are named according to the US keyboard layout, but represent physical keys (so for instance, GLFW\_KEY\_Z represents the same physical key, regardless of the system input language).}
\label{tab:keys1}
\end{table}
\begin{table}[p]
\begin{center}
\begin{tabular}{|l|l|} \hline \raggedright
\textbf{Name} & \textbf{Description} \\ \hline
GLFW\_KEY\_ESCAPE & Escape\\ \hline
GLFW\_KEY\_F\textit{n} & Function key \textit{n} (\textit{n} can be in the range 1..25)\\ \hline GLFW\_KEY\_F\textit{n} & Function key \textit{n} (\textit{n} can be in the range 1..25)\\ \hline
GLFW\_KEY\_UP & Cursor up\\ \hline GLFW\_KEY\_UP & Cursor up\\ \hline
GLFW\_KEY\_DOWN & Cursor down\\ \hline GLFW\_KEY\_DOWN & Cursor down\\ \hline
GLFW\_KEY\_LEFT & Cursor left\\ \hline GLFW\_KEY\_LEFT & Cursor left\\ \hline
GLFW\_KEY\_RIGHT & Cursor right\\ \hline GLFW\_KEY\_RIGHT & Cursor right\\ \hline
GLFW\_KEY\_LSHIFT & Left shift key\\ \hline GLFW\_KEY\_LEFT\_SHIFT & Left shift key\\ \hline
GLFW\_KEY\_RSHIFT & Right shift key\\ \hline GLFW\_KEY\_RIGHT\_SHIFT & Right shift key\\ \hline
GLFW\_KEY\_LCTRL & Left control key\\ \hline GLFW\_KEY\_LEFT\_CTRL & Left control key\\ \hline
GLFW\_KEY\_RCTRL & Right control key\\ \hline GLFW\_KEY\_RIGHT\_CTRL & Right control key\\ \hline
GLFW\_KEY\_LALT & Left alternate function key\\ \hline GLFW\_KEY\_LEFT\_ALT & Left alternate function key\\ \hline
GLFW\_KEY\_RALT & Right alternate function key\\ \hline GLFW\_KEY\_RIGHT\_ALT & Right alternate function key\\ \hline
GLFW\_KEY\_LSUPER & Left super key, WinKey, or command key\\ \hline GLFW\_KEY\_LEFT\_SUPER & Left super key, WinKey, or command key\\ \hline
GLFW\_KEY\_RSUPER & Right super key, WinKey, or command key\\ \hline GLFW\_KEY\_RIGHT\_SUPER & Right super key, WinKey, or command key\\ \hline
GLFW\_KEY\_TAB & Tabulator\\ \hline GLFW\_KEY\_TAB & Tabulator\\ \hline
GLFW\_KEY\_ENTER & Enter\\ \hline GLFW\_KEY\_ENTER & Enter\\ \hline
GLFW\_KEY\_BACKSPACE & Backspace\\ \hline GLFW\_KEY\_BACKSPACE & Backspace\\ \hline
GLFW\_KEY\_INSERT & Insert\\ \hline GLFW\_KEY\_INSERT & Insert\\ \hline
GLFW\_KEY\_DEL & Delete\\ \hline GLFW\_KEY\_DELETE & Delete\\ \hline
GLFW\_KEY\_PAGEUP & Page up\\ \hline GLFW\_KEY\_PAGE\_UP & Page up\\ \hline
GLFW\_KEY\_PAGEDOWN & Page down\\ \hline GLFW\_KEY\_PAGE\_DOWN & Page down\\ \hline
GLFW\_KEY\_HOME & Home\\ \hline GLFW\_KEY\_HOME & Home\\ \hline
GLFW\_KEY\_END & End\\ \hline GLFW\_KEY\_END & End\\ \hline
GLFW\_KEY\_KP\_\textit{n} & Keypad numeric key \textit{n} (\textit{n} can be in the range 0..9)\\ \hline GLFW\_KEY\_KP\_\textit{n} & Keypad numeric key \textit{n} (\textit{n} can be in the range 0..9)\\ \hline
@ -1244,15 +1269,15 @@ GLFW\_KEY\_KP\_ADD & Keypad add ($+$)\\ \hline
GLFW\_KEY\_KP\_DECIMAL & Keypad decimal (. or ,)\\ \hline GLFW\_KEY\_KP\_DECIMAL & Keypad decimal (. or ,)\\ \hline
GLFW\_KEY\_KP\_EQUAL & Keypad equal (=)\\ \hline GLFW\_KEY\_KP\_EQUAL & Keypad equal (=)\\ \hline
GLFW\_KEY\_KP\_ENTER & Keypad enter\\ \hline GLFW\_KEY\_KP\_ENTER & Keypad enter\\ \hline
GLFW\_KEY\_KP\_NUM\_LOCK & Keypad num lock\\ \hline GLFW\_KEY\_NUM\_LOCK & Num lock\\ \hline
GLFW\_KEY\_CAPS\_LOCK & Caps lock\\ \hline GLFW\_KEY\_CAPS\_LOCK & Caps lock\\ \hline
GLFW\_KEY\_SCROLL\_LOCK & Scroll lock\\ \hline GLFW\_KEY\_SCROLL\_LOCK & Scroll lock\\ \hline
GLFW\_KEY\_PAUSE & Pause key\\ \hline GLFW\_KEY\_PAUSE & Pause key\\ \hline
GLFW\_KEY\_MENU & Menu key\\ \hline GLFW\_KEY\_MENU & Menu key\\ \hline
\end{tabular} \end{tabular}
\end{center} \end{center}
\caption{Special key identifiers} \caption{Key codes for function keys}
\label{tab:keys} \label{tab:keys2}
\end{table} \end{table}
@ -1283,9 +1308,8 @@ int glfwGetKey(int key)
\begin{refparameters} \begin{refparameters}
\begin{description} \begin{description}
\item [\textit{key}]\ \\ \item [\textit{key}]\ \\
A keyboard key identifier, which can be either an uppercase printable A keyboard key identifier, which can be any of the key codes in tables
ISO~8859-1 (Latin~1) character (e.g. 'A', '3' or '.'), or a special key \ref{tab:keys1} and \ref{tab:keys2}.
identifier. Table \ref{tab:keys} lists valid special key identifiers.
\end{description} \end{description}
\end{refparameters} \end{refparameters}
@ -1499,10 +1523,8 @@ void glfwSetKeyCallback(GLFWkeyfun cbfun)
\texttt{void functionname(int key, int action);} \texttt{void functionname(int key, int action);}
Where \textit{functionname} is the name of the callback function, Where \textit{functionname} is the name of the callback function,
\textit{key} is a key identifier, which is an uppercase printable \textit{key} is a key code (see tables \ref{tab:keys1} and \ref{tab:keys2}),
ISO~8859-1 character or a special key identifier (see table and \textit{action} is either GLFW\_PRESS or GLFW\_RELEASE.
\ref{tab:keys}), and \textit{action} is either GLFW\_PRESS or
GLFW\_RELEASE.
If \textit{cbfun} is NULL, any previously set callback function If \textit{cbfun} is NULL, any previously set callback function
will be unset. will be unset.

View File

@ -221,16 +221,14 @@ int glfwGetKey(int key)
\end{lstlisting} \end{lstlisting}
It queries the current status of individual keyboard keys. The argument It queries the current status of individual keyboard keys. The argument
\textit{key} specifies which key to check, and it can be either an \textit{key} specifies which key to check, and it must be a valid GLFW key code
uppercase printable ISO 8859-1 (Latin 1) character (e.g. `A', `3' or `.'), (see the \textit{GLFW Reference Manual} for a list of key codes).
or a special key identifier (see the \textit{GLFW Reference Manual} for a \textbf{glfwGetKey} returns GLFW\_PRESS if the key is currently held down, or
list of special key identifiers). \textbf{glfwGetKey} returns GLFW\_PRESS GLFW\_RELEASE if the key is not being held down. For example:
if the key is currently held down, or GLFW\_RELEASE if the key is not being
held down. For example:
\begin{lstlisting} \begin{lstlisting}
A_pressed = glfwGetKey('A'); A_pressed = glfwGetKey(GLFW_KEY_A);
esc_pressed = glfwGetKey(GLFW_KEY_ESC); esc_pressed = glfwGetKey(GLFW_KEY_ESCAPE);
\end{lstlisting} \end{lstlisting}
In order for \textbf{glfwGetKey} to have any effect, you need to poll for In order for \textbf{glfwGetKey} to have any effect, you need to poll for
@ -282,7 +280,7 @@ int main(void)
glfwSwapBuffers(); glfwSwapBuffers();
// Check if ESC key was pressed or window was closed // Check if ESC key was pressed or window was closed
running = !glfwGetKey(GLFW_KEY_ESC) && running = !glfwGetKey(GLFW_KEY_ESCAPE) &&
glfwGetWindowParam(GLFW_OPENED); glfwGetWindowParam(GLFW_OPENED);
} }
@ -698,8 +696,7 @@ int glfwGetKey(int key)
\end{lstlisting} \end{lstlisting}
It queries the current status of individual keyboard keys. The argument It queries the current status of individual keyboard keys. The argument
\textit{key} specifies which key to check, and it can be either an \textit{key} specifies which key to check, which must be a valid GLFW key code.
uppercase ISO~8859-1 character, or a special key identifier.
\textbf{glfwGetKey} returns GLFW\_PRESS (or 1) if the key is currently \textbf{glfwGetKey} returns GLFW\_PRESS (or 1) if the key is currently
held down, or GLFW\_RELEASE (or 0) if the key is not being held down. held down, or GLFW\_RELEASE (or 0) if the key is not being held down.