141 lines
2.1 KiB
HTML
141 lines
2.1 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>Townengine Wiki : Input System</title>
|
|
<link rel="stylesheet" href="style.css">
|
|
</head>
|
|
<body>
|
|
<h1 style="margin-bottom:0in;">T2. Input System</h1>
|
|
<a href="index.html">Go back
|
|
<p><a name="design"></a><strong>T2.1 </strong><strong>Design</strong>
|
|
<blockquote>
|
|
<p>One of goals is to make system that has the least variance in handling. We combine mouse inputs with keys
|
|
and don't use keycodes whatsoever. Key combinations are supported. Everything is represented with an encoded string:
|
|
<pre>[control+]+control</pre>
|
|
Any variant should be combinable, even things like mouse movement + key press.
|
|
<p>One current limitation of such design is that actions will only be reported in next frame after they
|
|
were first declared, creating delay. It's possible to fix it in the future however.
|
|
</blockquote>
|
|
<p><a name="api"></a><strong>T2.2 </strong><strong>API</strong>
|
|
<blockquote>
|
|
<p>It's rather small:<pre>
|
|
void input_action(const char *name
|
|
bool input_action_pressed(const char *name);
|
|
bool input_action_just_pressed(const char *name);
|
|
bool input_action_just_released(const char *name);
|
|
Vec2 input_action_position(const char *name);</pre>
|
|
|
|
<p>Lists of controls, from src/twn_input.c:
|
|
<p>-- Keyboard --
|
|
<pre>
|
|
"A"
|
|
"B"
|
|
"C"
|
|
"D"
|
|
"E"
|
|
"F"
|
|
"G"
|
|
"H"
|
|
"I"
|
|
"J"
|
|
"K"
|
|
"L"
|
|
"M"
|
|
"N"
|
|
"O"
|
|
"P"
|
|
"Q"
|
|
"R"
|
|
"S"
|
|
"T"
|
|
"U"
|
|
"V"
|
|
"W"
|
|
"X"
|
|
"Y"
|
|
"Z"
|
|
"1"
|
|
"2"
|
|
"3"
|
|
"4"
|
|
"5"
|
|
"6"
|
|
"7"
|
|
"8"
|
|
"9"
|
|
"0"
|
|
"RETURN"
|
|
"ENTER" /* an alias */
|
|
"ESCAPE"
|
|
"BACKSPACE"
|
|
"TAB"
|
|
"SPACE"
|
|
"MINUS"
|
|
"EQUALS"
|
|
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