initial commit

master
Ales Katona 6 years ago
parent 194b5b4ccc
commit 13932577e8
Signed by: almindor
GPG Key ID: 08C459E2D8ABB7E8

4
.gitignore vendored

@ -0,0 +1,4 @@
/target
**/*.rs.bk
Cargo.lock
.vscode

@ -0,0 +1,15 @@
[package]
name = "prongs"
version = "1.0.0"
authors = ["Ales Katona <almindor@gmail.com>"]
edition = "2018"
[dependencies]
bitflags = "1.0.4"
serde = { version = "1.0.85", features = ["derive"] }
gilrs = { version = "0.6.3", optional = true }
piston = { version = "0.40.0", optional = true }
[features]
backend_piston = ["piston"]
backend_gilrs = ["gilrs"]

@ -3,3 +3,67 @@
Input handling schema written in rust. Backend agnostic, provides serializability, assignment and unified interface for working with inputs. Keyboard, mouse and controllers supported.
Current backends include Piston and Gilrs with more on the way.
## Using prongs library
To use the prongs library include it in your `Cargo.toml` file. You *MUST* specify a backend via features e.g.
```
[dependencies]
prongs = { version = "1.0.0", features = ["backend_piston"] }
```
### Documentation
[Documentation link](docs/index.html)
### Examples
See [examples repo](../prongs-examples)
### Design
Prongs provides a specific backend Schema struct that unifies and simplifies working with input events.
The goal is to provide serializability, input assigning and unify the interface for working with inputs.
Main target audience are game developer and engine developers.
The main workhorse of the prongs is the Schema. It is a combination of:
1. A keymap (input -> user action mapping)
2. Assigning functionality (create mapping by actuating controls)
3. Processing functionality (apply mapping in main loop)
4. Unified interface and simplification
Prongs abstracts input events into a three layered structure. The layers are:
1. Class of input, e.g. mouse or keyboard or controller
2. Instance of input, e.g. key "k", mouse button #2 or axis #2
3. State of input, e.g. button pressed/released or value of axis
This is expressed best in the [InputCause](docs/types/enum.InputCause.html) enum.
The library does not run any event loop due to various differences between how backends handle the event loop.
To use prongs you need to define an actions type that will identify the mappings on input events.
For example:
```
enum Actions
{
Up,
Down,
Left,
Right,
}
```
You then need to "hook" the `process_event` function into your main event loop for processing. This will
map the input event into the action you specified when you assigned or loaded the Schema configuration.
Assigning the mapping from input events to user actions is done by using the `assign_input` function. This
can be used to assign actions to input events individually as required (e.g. in a menu when something gets clicked).
Note that `assign_input` handles required de-duplication (e.g. it won't consider a button release as a separate mapping to a button press).
Because the Schema object is fully serializable you can also load existing setup from any previously stored one.
## Development
To build you need to specify the required backends e.g. `cargo build --features backend_piston,backend_gilrs`
Same goes for testing `cargo test --features backend_piston,backend_gilrs`
If you don't specify a backend the tests for it will not be compiled and won't run.

@ -0,0 +1,3 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="List of all items in this crate"><meta name="keywords" content="rust, rustlang, rust-lang"><title>List of all items in this crate</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span>
</span>
<span class='in-band'>List of all items</span></h1><h3 id='Structs'>Structs</h3><ul class='structs docblock'><li><a href='backend_gilrs/struct.SchemaGilrs.html'>backend_gilrs::SchemaGilrs</a></li><li><a href='backend_piston/struct.SchemaPiston.html'>backend_piston::SchemaPiston</a></li><li><a href='types/struct.InputTypeFlags.html'>types::InputTypeFlags</a></li><li><a href='types/struct.ProcessingResult.html'>types::ProcessingResult</a></li></ul><h3 id='Enums'>Enums</h3><ul class='enums docblock'><li><a href='types/enum.ButtonState.html'>types::ButtonState</a></li><li><a href='types/enum.InputCause.html'>types::InputCause</a></li></ul></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd></kbd></dt><dd>Move up in search results</dd><dt><kbd></kbd></dt><dd>Move down in search results</dd><dt><kbd></kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../";window.currentCrate = "prongs";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=struct.SchemaGilrs.html">
</head>
<body>
<p>Redirecting to <a href="struct.SchemaGilrs.html">struct.SchemaGilrs.html</a>...</p>
<script>location.replace("struct.SchemaGilrs.html" + location.search + location.hash);</script>
</body>
</html>

@ -0,0 +1,2 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `backend_gilrs` mod in crate `prongs`."><meta name="keywords" content="rust, rustlang, rust-lang, backend_gilrs"><title>prongs::backend_gilrs - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script src="../../storage.js"></script></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><p class='location'>Module backend_gilrs</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li></ul></div><p class='location'><a href='../index.html'>prongs</a></p><script>window.sidebarCurrent = {name: 'backend_gilrs', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../src/prongs/backend_gilrs.rs.html#1-84' title='goto source code'>[src]</a></span><span class='in-band'>Module <a href='../index.html'>prongs</a>::<wbr><a class="mod" href=''>backend_gilrs</a></span></h1><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table><tr class='module-item'><td><a class="struct" href="struct.SchemaGilrs.html" title='prongs::backend_gilrs::SchemaGilrs struct'>SchemaGilrs</a></td><td class='docblock-short'></td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd></kbd></dt><dd>Move up in search results</dd><dt><kbd></kbd></dt><dd>Move down in search results</dd><dt><kbd></kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../";window.currentCrate = "prongs";</script><script src="../../aliases.js"></script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>

@ -0,0 +1 @@
initSidebarItems({"struct":[["SchemaGilrs",""]]});

File diff suppressed because one or more lines are too long

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=struct.SchemaPiston.html">
</head>
<body>
<p>Redirecting to <a href="struct.SchemaPiston.html">struct.SchemaPiston.html</a>...</p>
<script>location.replace("struct.SchemaPiston.html" + location.search + location.hash);</script>
</body>
</html>

@ -0,0 +1,2 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `backend_piston` mod in crate `prongs`."><meta name="keywords" content="rust, rustlang, rust-lang, backend_piston"><title>prongs::backend_piston - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script src="../../storage.js"></script></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><p class='location'>Module backend_piston</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li></ul></div><p class='location'><a href='../index.html'>prongs</a></p><script>window.sidebarCurrent = {name: 'backend_piston', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../src/prongs/backend_piston.rs.html#1-132' title='goto source code'>[src]</a></span><span class='in-band'>Module <a href='../index.html'>prongs</a>::<wbr><a class="mod" href=''>backend_piston</a></span></h1><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table><tr class='module-item'><td><a class="struct" href="struct.SchemaPiston.html" title='prongs::backend_piston::SchemaPiston struct'>SchemaPiston</a></td><td class='docblock-short'></td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd></kbd></dt><dd>Move up in search results</dd><dt><kbd></kbd></dt><dd>Move down in search results</dd><dt><kbd></kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../";window.currentCrate = "prongs";</script><script src="../../aliases.js"></script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>

@ -0,0 +1 @@
initSidebarItems({"struct":[["SchemaPiston",""]]});

File diff suppressed because one or more lines are too long

@ -0,0 +1,2 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `prongs` crate."><meta name="keywords" content="rust, rustlang, rust-lang, prongs"><title>prongs - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><p class='location'>Crate prongs</p><div class="sidebar-elems"><a id='all-types' href='all.html'><p>See all prongs's items</p></a><div class="block items"><ul><li><a href="#modules">Modules</a></li></ul></div><p class='location'></p><script>window.sidebarCurrent = {name: 'prongs', ty: 'mod', relpath: '../'};</script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../src/prongs/lib.rs.html#1-131' title='goto source code'>[src]</a></span><span class='in-band'>Crate <a class="mod" href=''>prongs</a></span></h1><h2 id='modules' class='section-header'><a href="#modules">Modules</a></h2>
<table><tr class='module-item'><td><a class="mod" href="backend_gilrs/index.html" title='prongs::backend_gilrs mod'>backend_gilrs</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="mod" href="backend_piston/index.html" title='prongs::backend_piston mod'>backend_piston</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="mod" href="types/index.html" title='prongs::types mod'>types</a></td><td class='docblock-short'></td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd></kbd></dt><dd>Move up in search results</dd><dt><kbd></kbd></dt><dd>Move down in search results</dd><dt><kbd></kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../";window.currentCrate = "prongs";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>

@ -0,0 +1 @@
initSidebarItems({"mod":[["backend_gilrs",""],["backend_piston",""],["types",""]]});

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=enum.ButtonState.html">
</head>
<body>
<p>Redirecting to <a href="enum.ButtonState.html">enum.ButtonState.html</a>...</p>
<script>location.replace("enum.ButtonState.html" + location.search + location.hash);</script>
</body>
</html>

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=enum.InputCause.html">
</head>
<body>
<p>Redirecting to <a href="enum.InputCause.html">enum.InputCause.html</a>...</p>
<script>location.replace("enum.InputCause.html" + location.search + location.hash);</script>
</body>
</html>

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=struct.InputTypeFlags.html">
</head>
<body>
<p>Redirecting to <a href="struct.InputTypeFlags.html">struct.InputTypeFlags.html</a>...</p>
<script>location.replace("struct.InputTypeFlags.html" + location.search + location.hash);</script>
</body>
</html>

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=struct.ProcessingResult.html">
</head>
<body>
<p>Redirecting to <a href="struct.ProcessingResult.html">struct.ProcessingResult.html</a>...</p>
<script>location.replace("struct.ProcessingResult.html" + location.search + location.hash);</script>
</body>
</html>

@ -0,0 +1,25 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `ButtonState` enum in crate `prongs`."><meta name="keywords" content="rust, rustlang, rust-lang, ButtonState"><title>prongs::types::ButtonState - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script src="../../storage.js"></script></head><body class="rustdoc enum"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><p class='location'>Enum ButtonState</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#variants">Variants</a><div class="sidebar-links"><a href="#variant.Pressed">Pressed</a><a href="#variant.Released">Released</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-PartialEq%3CButtonState%3E">PartialEq&lt;ButtonState&gt;</a><a href="#impl-Eq">Eq</a><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Into">Into</a><a href="#impl-From">From</a><a href="#impl-TryFrom">TryFrom</a><a href="#impl-Borrow">Borrow</a><a href="#impl-Any">Any</a><a href="#impl-TryInto">TryInto</a><a href="#impl-BorrowMut">BorrowMut</a></div></div><p class='location'><a href='../index.html'>prongs</a>::<wbr><a href='index.html'>types</a></p><script>window.sidebarCurrent = {name: 'ButtonState', ty: 'enum', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../src/prongs/types.rs.html#32-38' title='goto source code'>[src]</a></span><span class='in-band'>Enum <a href='../index.html'>prongs</a>::<wbr><a href='index.html'>types</a>::<wbr><a class="enum" href=''>ButtonState</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust enum'>pub enum ButtonState {
Pressed,
Released,
}</pre></div><div class='docblock'><p>Describes states a key or button can be in</p>
</div><h2 id='variants' class='variants small-section-header'>
Variants<a href='#variants' class='anchor'></a></h2>
<span id="variant.Pressed" class="variant small-section-header"><a href="#variant.Pressed" class="anchor field"></a><span id='Pressed.v' class='invisible'><code>Pressed</code></span></span><div class='docblock'><p>when key or button is pressed</p>
</div><span id="variant.Released" class="variant small-section-header"><a href="#variant.Released" class="anchor field"></a><span id='Released.v' class='invisible'><code>Released</code></span></span><div class='docblock'><p>when key or button is released</p>
</div><h2 id='implementations' class='small-section-header'>Trait Implementations<a href='#implementations' class='anchor'></a></h2><div id='implementations-list'><h3 id='impl-PartialEq%3CButtonState%3E' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a>&lt;<a class="enum" href="../../prongs/types/enum.ButtonState.html" title="enum prongs::types::ButtonState">ButtonState</a>&gt; for <a class="enum" href="../../prongs/types/enum.ButtonState.html" title="enum prongs::types::ButtonState">ButtonState</a></code><a href='#impl-PartialEq%3CButtonState%3E' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#31' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.eq' class="method hidden"><span id='eq.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&amp;self, other: &amp;<a class="enum" href="../../prongs/types/enum.ButtonState.html" title="enum prongs::types::ButtonState">ButtonState</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#31' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
</div><h4 id='method.ne' class="method"><span id='ne.v' class='invisible'><table class='table-display'><tbody><tr><td><code><div class="docblock attributes">#[must_use]
</div>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Rhs) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#209' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>This method tests for <code>!=</code>.</p>
</div></div><h3 id='impl-Eq' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="enum" href="../../prongs/types/enum.ButtonState.html" title="enum prongs::types::ButtonState">ButtonState</a></code><a href='#impl-Eq' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#31' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'></div><h3 id='impl-Debug' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="enum" href="../../prongs/types/enum.ButtonState.html" title="enum prongs::types::ButtonState">ButtonState</a></code><a href='#impl-Debug' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#31' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.fmt' class="method hidden"><span id='fmt.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#31' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div></div><h2 id='synthetic-implementations' class='small-section-header'>Auto Trait Implementations<a href='#synthetic-implementations' class='anchor'></a></h2><div id='synthetic-implementations-list'><h3 id='impl-Send' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="enum" href="../../prongs/types/enum.ButtonState.html" title="enum prongs::types::ButtonState">ButtonState</a></code><a href='#impl-Send' class='anchor'></a></span></td><td><span class='out-of-band'></span></td></tr></tbody></table></h3><div class='impl-items'></div><h3 id='impl-Sync' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="enum" href="../../prongs/types/enum.ButtonState.html" title="enum prongs::types::ButtonState">ButtonState</a></code><a href='#impl-Sync' class='anchor'></a></span></td><td><span class='out-of-band'></span></td></tr></tbody></table></h3><div class='impl-items'></div></div><h2 id='blanket-implementations' class='small-section-header'>Blanket Implementations<a href='#blanket-implementations' class='anchor'></a></h2><div id='blanket-implementations-list'><h3 id='impl-Into' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-Into' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#452-457' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.into' class="method hidden"><span id='into.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into' class='fnname'>into</a>(self) -&gt; U</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#454-456' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-From' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a> for T</code><a href='#impl-From' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#461-463' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.from' class="method hidden"><span id='from.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(t: T) -&gt; T</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#462' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-TryFrom' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;U&gt;,&nbsp;</span></code><a href='#impl-TryFrom' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#480-486' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='associatedtype.Error' class="type"><span id='Error.t' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error' class="type">Error</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.never.html">!</a></code></span></h4>
<div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_from</code>)</div></div><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id='method.try_from' class="method hidden"><span id='try_from.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from' class='fnname'>try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#483-485' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='stability hidden'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_from</code>)</div></div><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-Borrow' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Borrow' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#219-221' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.borrow' class="method hidden"><span id='borrow.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow' class='fnname'>borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#220' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
</div></div><h3 id='impl-Any' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Any' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#114-116' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.get_type_id' class="method hidden"><span id='get_type_id.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.get_type_id' class='fnname'>get_type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#115' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='stability hidden'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>get_type_id</code>)</summary><p>this method will likely be replaced by an associated static</p>
</details></div></div><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.get_type_id">Read more</a></p>
</div></div><h3 id='impl-TryInto' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-TryInto' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#468-475' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='associatedtype.Error-1' class="type"><span id='Error.t-1' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error' class="type">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></span></h4>
<div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_from</code>)</div></div><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id='method.try_into' class="method hidden"><span id='try_into.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into' class='fnname'>try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#472-474' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='stability hidden'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_from</code>)</div></div><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-BorrowMut' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-BorrowMut' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#224-226' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.borrow_mut' class="method hidden"><span id='borrow_mut.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut' class='fnname'>borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#225' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd></kbd></dt><dd>Move up in search results</dd><dt><kbd></kbd></dt><dd>Move down in search results</dd><dt><kbd></kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../";window.currentCrate = "prongs";</script><script src="../../aliases.js"></script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>

@ -0,0 +1,26 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `InputCause` enum in crate `prongs`."><meta name="keywords" content="rust, rustlang, rust-lang, InputCause"><title>prongs::types::InputCause - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script src="../../storage.js"></script></head><body class="rustdoc enum"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><p class='location'>Enum InputCause</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#variants">Variants</a><div class="sidebar-links"><a href="#variant.Button">Button</a><a href="#variant.Axis">Axis</a><a href="#variant.Motion">Motion</a></div><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.is_engaged">is_engaged</a><a href="#method.is_axis">is_axis</a><a href="#method.scalar_value">scalar_value</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-PartialEq%3CInputCause%3E">PartialEq&lt;InputCause&gt;</a><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Into">Into</a><a href="#impl-From">From</a><a href="#impl-TryFrom">TryFrom</a><a href="#impl-Borrow">Borrow</a><a href="#impl-Any">Any</a><a href="#impl-TryInto">TryInto</a><a href="#impl-BorrowMut">BorrowMut</a></div></div><p class='location'><a href='../index.html'>prongs</a>::<wbr><a href='index.html'>types</a></p><script>window.sidebarCurrent = {name: 'InputCause', ty: 'enum', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../src/prongs/types.rs.html#42-50' title='goto source code'>[src]</a></span><span class='in-band'>Enum <a href='../index.html'>prongs</a>::<wbr><a href='index.html'>types</a>::<wbr><a class="enum" href=''>InputCause</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust enum'>pub enum InputCause {
Button(<a class="enum" href="../../prongs/types/enum.ButtonState.html" title="enum prongs::types::ButtonState">ButtonState</a>),
Axis(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>,&nbsp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>),
Motion(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>,&nbsp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>),
}</pre></div><div class='docblock'><p>Describes the source of input for a <a href="struct.ProcessingResult.html">ProcessingResult</a></p>
</div><h2 id='variants' class='variants small-section-header'>
Variants<a href='#variants' class='anchor'></a></h2>
<span id="variant.Button" class="variant small-section-header"><a href="#variant.Button" class="anchor field"></a><span id='Button.v' class='invisible'><code>Button(<a class="enum" href="../../prongs/types/enum.ButtonState.html" title="enum prongs::types::ButtonState">ButtonState</a>)</code></span></span><div class='docblock'><p>a key or button as source, with given state</p>
</div><span id="variant.Axis" class="variant small-section-header"><a href="#variant.Axis" class="anchor field"></a><span id='Axis.v' class='invisible'><code>Axis(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>,&nbsp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>)</code></span></span><div class='docblock'><p>an axis set to specific value in range &lt;-1.0, 1.0&gt;</p>
</div><span id="variant.Motion" class="variant small-section-header"><a href="#variant.Motion" class="anchor field"></a><span id='Motion.v' class='invisible'><code>Motion(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>,&nbsp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>)</code></span></span><div class='docblock'><p>a motion source (e.g. mouse) with x, y values</p>
</div><h2 id='methods' class='small-section-header'>Methods<a href='#methods' class='anchor'></a></h2><h3 id='impl' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="enum" href="../../prongs/types/enum.InputCause.html" title="enum prongs::types::InputCause">InputCause</a></code><a href='#impl' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#52-80' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.is_engaged' class="method"><span id='is_engaged.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.is_engaged' class='fnname'>is_engaged</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#54-60' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><h4 id='method.is_axis' class="method"><span id='is_axis.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.is_axis' class='fnname'>is_axis</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#62-67' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><h4 id='method.scalar_value' class="method"><span id='scalar_value.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.scalar_value' class='fnname'>scalar_value</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#69-79' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4></div><h2 id='implementations' class='small-section-header'>Trait Implementations<a href='#implementations' class='anchor'></a></h2><div id='implementations-list'><h3 id='impl-PartialEq%3CInputCause%3E' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a>&lt;<a class="enum" href="../../prongs/types/enum.InputCause.html" title="enum prongs::types::InputCause">InputCause</a>&gt; for <a class="enum" href="../../prongs/types/enum.InputCause.html" title="enum prongs::types::InputCause">InputCause</a></code><a href='#impl-PartialEq%3CInputCause%3E' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#41' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.eq' class="method hidden"><span id='eq.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&amp;self, other: &amp;<a class="enum" href="../../prongs/types/enum.InputCause.html" title="enum prongs::types::InputCause">InputCause</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#41' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
</div><h4 id='method.ne' class="method hidden"><span id='ne.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&amp;self, other: &amp;<a class="enum" href="../../prongs/types/enum.InputCause.html" title="enum prongs::types::InputCause">InputCause</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#41' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>This method tests for <code>!=</code>.</p>
</div></div><h3 id='impl-Debug' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="enum" href="../../prongs/types/enum.InputCause.html" title="enum prongs::types::InputCause">InputCause</a></code><a href='#impl-Debug' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#41' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.fmt' class="method hidden"><span id='fmt.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#41' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div></div><h2 id='synthetic-implementations' class='small-section-header'>Auto Trait Implementations<a href='#synthetic-implementations' class='anchor'></a></h2><div id='synthetic-implementations-list'><h3 id='impl-Send' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="enum" href="../../prongs/types/enum.InputCause.html" title="enum prongs::types::InputCause">InputCause</a></code><a href='#impl-Send' class='anchor'></a></span></td><td><span class='out-of-band'></span></td></tr></tbody></table></h3><div class='impl-items'></div><h3 id='impl-Sync' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="enum" href="../../prongs/types/enum.InputCause.html" title="enum prongs::types::InputCause">InputCause</a></code><a href='#impl-Sync' class='anchor'></a></span></td><td><span class='out-of-band'></span></td></tr></tbody></table></h3><div class='impl-items'></div></div><h2 id='blanket-implementations' class='small-section-header'>Blanket Implementations<a href='#blanket-implementations' class='anchor'></a></h2><div id='blanket-implementations-list'><h3 id='impl-Into' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-Into' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#452-457' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.into' class="method hidden"><span id='into.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into' class='fnname'>into</a>(self) -&gt; U</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#454-456' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-From' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a> for T</code><a href='#impl-From' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#461-463' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.from' class="method hidden"><span id='from.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(t: T) -&gt; T</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#462' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-TryFrom' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;U&gt;,&nbsp;</span></code><a href='#impl-TryFrom' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#480-486' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='associatedtype.Error' class="type"><span id='Error.t' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error' class="type">Error</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.never.html">!</a></code></span></h4>
<div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_from</code>)</div></div><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id='method.try_from' class="method hidden"><span id='try_from.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from' class='fnname'>try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#483-485' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='stability hidden'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_from</code>)</div></div><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-Borrow' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Borrow' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#219-221' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.borrow' class="method hidden"><span id='borrow.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow' class='fnname'>borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#220' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
</div></div><h3 id='impl-Any' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Any' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#114-116' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.get_type_id' class="method hidden"><span id='get_type_id.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.get_type_id' class='fnname'>get_type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#115' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='stability hidden'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>get_type_id</code>)</summary><p>this method will likely be replaced by an associated static</p>
</details></div></div><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.get_type_id">Read more</a></p>
</div></div><h3 id='impl-TryInto' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-TryInto' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#468-475' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='associatedtype.Error-1' class="type"><span id='Error.t-1' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error' class="type">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></span></h4>
<div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_from</code>)</div></div><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id='method.try_into' class="method hidden"><span id='try_into.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into' class='fnname'>try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#472-474' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='stability hidden'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_from</code>)</div></div><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-BorrowMut' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-BorrowMut' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#224-226' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.borrow_mut' class="method hidden"><span id='borrow_mut.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut' class='fnname'>borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#225' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd></kbd></dt><dd>Move up in search results</dd><dt><kbd></kbd></dt><dd>Move down in search results</dd><dt><kbd></kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../";window.currentCrate = "prongs";</script><script src="../../aliases.js"></script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>

@ -0,0 +1,10 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `types` mod in crate `prongs`."><meta name="keywords" content="rust, rustlang, rust-lang, types"><title>prongs::types - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script src="../../storage.js"></script></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><p class='location'>Module types</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li></ul></div><p class='location'><a href='../index.html'>prongs</a></p><script>window.sidebarCurrent = {name: 'types', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../src/prongs/types.rs.html#1-128' title='goto source code'>[src]</a></span><span class='in-band'>Module <a href='../index.html'>prongs</a>::<wbr><a class="mod" href=''>types</a></span></h1><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table><tr class='module-item'><td><a class="struct" href="struct.InputTypeFlags.html" title='prongs::types::InputTypeFlags struct'>InputTypeFlags</a></td><td class='docblock-short'><p>InputTypeFlags are used to specify what type of input
is to be allowed when in &quot;assignment mode&quot; for event mapping.
This allows the caller to filter out unwanted event types in a
generic way without having to handle the backend implementation details.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.ProcessingResult.html" title='prongs::types::ProcessingResult struct'>ProcessingResult</a></td><td class='docblock-short'><p>The result of a successful input processing by a Schema</p>
</td></tr></table><h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2>
<table><tr class='module-item'><td><a class="enum" href="enum.ButtonState.html" title='prongs::types::ButtonState enum'>ButtonState</a></td><td class='docblock-short'><p>Describes states a key or button can be in</p>
</td></tr><tr class='module-item'><td><a class="enum" href="enum.InputCause.html" title='prongs::types::InputCause enum'>InputCause</a></td><td class='docblock-short'><p>Describes the source of input for a <a href="struct.ProcessingResult.html">ProcessingResult</a></p>
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd></kbd></dt><dd>Move up in search results</dd><dt><kbd></kbd></dt><dd>Move down in search results</dd><dt><kbd></kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../";window.currentCrate = "prongs";</script><script src="../../aliases.js"></script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>

@ -0,0 +1 @@
initSidebarItems({"enum":[["ButtonState","Describes states a key or button can be in"],["InputCause","Describes the source of input for a ProcessingResult"]],"struct":[["InputTypeFlags","InputTypeFlags are used to specify what type of input is to be allowed when in \"assignment mode\" for event mapping. This allows the caller to filter out unwanted event types in a generic way without having to handle the backend implementation details."],["ProcessingResult","The result of a successful input processing by a Schema"]]});

File diff suppressed because one or more lines are too long

@ -0,0 +1,44 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `ProcessingResult` struct in crate `prongs`."><meta name="keywords" content="rust, rustlang, rust-lang, ProcessingResult"><title>prongs::types::ProcessingResult - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script src="../../storage.js"></script></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><p class='location'>Struct ProcessingResult</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#fields">Fields</a><div class="sidebar-links"><a href="#structfield.action">action</a><a href="#structfield.player_id">player_id</a><a href="#structfield.cause">cause</a></div><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.input_is_engaged">input_is_engaged</a><a href="#method.input_is_axis">input_is_axis</a><a href="#method.input_scalar_value">input_scalar_value</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-PartialEq%3CProcessingResult%3CTUserAction%3E%3E">PartialEq&lt;ProcessingResult&lt;TUserAction&gt;&gt;</a><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Into">Into</a><a href="#impl-From">From</a><a href="#impl-TryFrom">TryFrom</a><a href="#impl-Borrow">Borrow</a><a href="#impl-Any">Any</a><a href="#impl-TryInto">TryInto</a><a href="#impl-BorrowMut">BorrowMut</a></div></div><p class='location'><a href='../index.html'>prongs</a>::<wbr><a href='index.html'>types</a></p><script>window.sidebarCurrent = {name: 'ProcessingResult', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../src/prongs/types.rs.html#84-93' title='goto source code'>[src]</a></span><span class='in-band'>Struct <a href='../index.html'>prongs</a>::<wbr><a href='index.html'>types</a>::<wbr><a class="struct" href=''>ProcessingResult</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust struct'>pub struct ProcessingResult&lt;TUserAction&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;TUserAction: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="../../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>,&nbsp;</span> {
pub action: TUserAction,
pub player_id: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;,
pub cause: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="../../prongs/types/enum.InputCause.html" title="enum prongs::types::InputCause">InputCause</a>&gt;,
}</pre></div><div class='docblock'><p>The result of a successful input processing by a Schema</p>
</div><h2 id='fields' class='fields small-section-header'>
Fields<a href='#fields' class='anchor'></a></h2><span id="structfield.action" class="structfield small-section-header">
<a href="#structfield.action" class="anchor field"></a>
<span id="action.v" class='invisible'>
<code>action: TUserAction</code>
</span></span><div class='docblock'><p>The user defined action to be performed based on the input event</p>
</div><span id="structfield.player_id" class="structfield small-section-header">
<a href="#structfield.player_id" class="anchor field"></a>
<span id="player_id.v" class='invisible'>
<code>player_id: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;</code>
</span></span><div class='docblock'><p>The player_id if assigned to the Schema previously, otherwise None</p>
</div><span id="structfield.cause" class="structfield small-section-header">
<a href="#structfield.cause" class="anchor field"></a>
<span id="cause.v" class='invisible'>
<code>cause: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="../../prongs/types/enum.InputCause.html" title="enum prongs::types::InputCause">InputCause</a>&gt;</code>
</span></span><div class='docblock'><p>The <a href="enum.InputCause.html">InputCause</a> of this input, if known. None only if backend implementation is incomplete.</p>
</div><h2 id='methods' class='small-section-header'>Methods<a href='#methods' class='anchor'></a></h2><h3 id='impl' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;TUserAction&gt; <a class="struct" href="../../prongs/types/struct.ProcessingResult.html" title="struct prongs::types::ProcessingResult">ProcessingResult</a>&lt;TUserAction&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;TUserAction: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="../../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>,&nbsp;</span></code><a href='#impl' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#95-128' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.input_is_engaged' class="method"><span id='input_is_engaged.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.input_is_engaged' class='fnname'>input_is_engaged</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#100-106' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Specifies if the input cause is engaged (pressed or not equal to 0)
<em>NOTE</em>: some input causes are never engaged, e.g. Motion</p>
</div><h4 id='method.input_is_axis' class="method"><span id='input_is_axis.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.input_is_axis' class='fnname'>input_is_axis</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#109-115' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Specifies if the input cause is an axis</p>
</div><h4 id='method.input_scalar_value' class="method"><span id='input_scalar_value.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.input_scalar_value' class='fnname'>input_scalar_value</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#121-127' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Reduces the input cause state value to a single f64
Key or button states are either 0.0 or 1.0 for pressed
Axis value stays same
Motion x, y values are multiplied (x * y)</p>
</div></div><h2 id='implementations' class='small-section-header'>Trait Implementations<a href='#implementations' class='anchor'></a></h2><div id='implementations-list'><h3 id='impl-PartialEq%3CProcessingResult%3CTUserAction%3E%3E' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;TUserAction:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a>&lt;<a class="struct" href="../../prongs/types/struct.ProcessingResult.html" title="struct prongs::types::ProcessingResult">ProcessingResult</a>&lt;TUserAction&gt;&gt; for <a class="struct" href="../../prongs/types/struct.ProcessingResult.html" title="struct prongs::types::ProcessingResult">ProcessingResult</a>&lt;TUserAction&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;TUserAction: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="../../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>,&nbsp;</span></code><a href='#impl-PartialEq%3CProcessingResult%3CTUserAction%3E%3E' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#83' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.eq' class="method hidden"><span id='eq.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&amp;self, other: &amp;<a class="struct" href="../../prongs/types/struct.ProcessingResult.html" title="struct prongs::types::ProcessingResult">ProcessingResult</a>&lt;TUserAction&gt;) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#83' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
</div><h4 id='method.ne' class="method hidden"><span id='ne.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&amp;self, other: &amp;<a class="struct" href="../../prongs/types/struct.ProcessingResult.html" title="struct prongs::types::ProcessingResult">ProcessingResult</a>&lt;TUserAction&gt;) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#83' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>This method tests for <code>!=</code>.</p>
</div></div><h3 id='impl-Debug' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;TUserAction:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../prongs/types/struct.ProcessingResult.html" title="struct prongs::types::ProcessingResult">ProcessingResult</a>&lt;TUserAction&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;TUserAction: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="../../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>,&nbsp;</span></code><a href='#impl-Debug' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#83' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.fmt' class="method hidden"><span id='fmt.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/prongs/types.rs.html#83' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div></div><h2 id='synthetic-implementations' class='small-section-header'>Auto Trait Implementations<a href='#synthetic-implementations' class='anchor'></a></h2><div id='synthetic-implementations-list'><h3 id='impl-Send' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;TUserAction&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../prongs/types/struct.ProcessingResult.html" title="struct prongs::types::ProcessingResult">ProcessingResult</a>&lt;TUserAction&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;TUserAction: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,&nbsp;</span></code><a href='#impl-Send' class='anchor'></a></span></td><td><span class='out-of-band'></span></td></tr></tbody></table></h3><div class='impl-items'></div><h3 id='impl-Sync' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;TUserAction&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../prongs/types/struct.ProcessingResult.html" title="struct prongs::types::ProcessingResult">ProcessingResult</a>&lt;TUserAction&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;TUserAction: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>,&nbsp;</span></code><a href='#impl-Sync' class='anchor'></a></span></td><td><span class='out-of-band'></span></td></tr></tbody></table></h3><div class='impl-items'></div></div><h2 id='blanket-implementations' class='small-section-header'>Blanket Implementations<a href='#blanket-implementations' class='anchor'></a></h2><div id='blanket-implementations-list'><h3 id='impl-Into' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-Into' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#452-457' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.into' class="method hidden"><span id='into.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into' class='fnname'>into</a>(self) -&gt; U</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#454-456' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-From' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a> for T</code><a href='#impl-From' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#461-463' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.from' class="method hidden"><span id='from.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(t: T) -&gt; T</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#462' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-TryFrom' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;U&gt;,&nbsp;</span></code><a href='#impl-TryFrom' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#480-486' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='associatedtype.Error' class="type"><span id='Error.t' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error' class="type">Error</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.never.html">!</a></code></span></h4>
<div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_from</code>)</div></div><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id='method.try_from' class="method hidden"><span id='try_from.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from' class='fnname'>try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#483-485' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='stability hidden'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_from</code>)</div></div><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-Borrow' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Borrow' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#219-221' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.borrow' class="method hidden"><span id='borrow.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow' class='fnname'>borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#220' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
</div></div><h3 id='impl-Any' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Any' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#114-116' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.get_type_id' class="method hidden"><span id='get_type_id.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.get_type_id' class='fnname'>get_type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#115' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='stability hidden'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>get_type_id</code>)</summary><p>this method will likely be replaced by an associated static</p>
</details></div></div><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.get_type_id">Read more</a></p>
</div></div><h3 id='impl-TryInto' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-TryInto' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#468-475' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='associatedtype.Error-1' class="type"><span id='Error.t-1' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error' class="type">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></span></h4>
<div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_from</code>)</div></div><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id='method.try_into' class="method hidden"><span id='try_into.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into' class='fnname'>try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#472-474' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='stability hidden'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_from</code>)</div></div><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-BorrowMut' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-BorrowMut' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#224-226' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.borrow_mut' class="method hidden"><span id='borrow_mut.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut' class='fnname'>borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#225' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd></kbd></dt><dd>Move up in search results</dd><dt><kbd></kbd></dt><dd>Move down in search results</dd><dt><kbd></kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../";window.currentCrate = "prongs";</script><script src="../../aliases.js"></script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>

@ -0,0 +1,84 @@
use gilrs::{Event, EventType as GilrsEType};
use serde::{Serialize, Deserialize};
use crate::types::{InputCause, ButtonState, InputTypeFlags, ProcessingResult};
use crate::{Schema, ToEventType, EventType};
#[derive(Serialize, Deserialize)]
pub struct SchemaGilrs<TUserAction>
where TUserAction: Clone + Serialize,
{
schema: Schema<Event, usize, TUserAction>,
}
impl<TUserAction> SchemaGilrs<TUserAction>
where TUserAction: Clone + Serialize,
{
pub fn new(name: &str) -> Self {
SchemaGilrs {
schema: Schema::new(name)
}
}
pub fn assign_controller(&mut self, event: &Event, iaf: InputTypeFlags) -> bool {
self.schema.assign_controller(event, iaf)
}
pub fn assign_input(&mut self, event: &Event, action: TUserAction, iaf: InputTypeFlags) -> bool {
self.schema.assign_input(event, action, iaf)
}
pub fn process_event(&mut self, event: &Event) -> Option<ProcessingResult<TUserAction>> {
self.schema.process_event(event)
}
pub fn set_player_id(&mut self, player_id: Option<usize>) {
self.schema.set_player_id(player_id);
}
pub fn player_id(&self) -> Option<usize> {
self.schema.player_id
}
pub fn controller_id(&self) -> Option<usize> {
self.schema.controller_id
}
}
impl ToEventType<usize> for Event
{
fn to_raw(&self) -> Option<EventType> {
match self.event {
GilrsEType::ButtonPressed(b, _) => Some(EventType::new(1, b as u64)),
GilrsEType::ButtonReleased(b, _) => Some(EventType::new(1, b as u64)),
GilrsEType::AxisChanged(axis, _, _) => Some(EventType::new(axis as u64, 0)),
_ => None
}
}
fn controller_id(&self) -> Option<usize> {
Some(self.id)
}
fn filter_for_assignment(&self, iaf: InputTypeFlags) -> bool {
match self.event {
GilrsEType::ButtonPressed(_, _) => iaf.contains(InputTypeFlags::Button),
GilrsEType::ButtonReleased(_, _) => false, // do not get releases
GilrsEType::ButtonRepeated(_, _) => false, // not sure why this would be used for assignment
GilrsEType::ButtonChanged(_, _, _) => false,
GilrsEType::AxisChanged(_, val, _) => val.abs() > 0.5 && iaf.contains(InputTypeFlags::Axis), // ensure we capture only the major axis change
_ => iaf.contains(InputTypeFlags::Other),
}
}
fn get_cause(&self) -> Option<InputCause> {
match self.event {
GilrsEType::ButtonPressed(_, _) => Some(InputCause::Button(ButtonState::Pressed)),
GilrsEType::ButtonReleased(_, _) => Some(InputCause::Button(ButtonState::Released)), // do not get releases
GilrsEType::ButtonRepeated(_, _) => None, // not sure why this would be used for assignment
GilrsEType::ButtonChanged(_, _, _) => None,
GilrsEType::AxisChanged(axis, val, _) => Some(InputCause::Axis(axis as u8, f64::from(val))),
_ => None,
}
}
}

@ -0,0 +1,132 @@
use piston::input::{Button, Event, Input, Motion, ButtonState as PButtonState};
use serde::{Serialize, Deserialize};
use crate::types::{InputTypeFlags, InputCause, ButtonState, ProcessingResult};
use crate::{Schema, ToEventType, EventType};
#[derive(Serialize, Deserialize)]
pub struct SchemaPiston<TUserAction>
where TUserAction: Clone + Serialize,
{
schema: Schema<Event, usize, TUserAction>,
}
impl<TUserAction> SchemaPiston<TUserAction>
where TUserAction: Clone + Serialize,
{
pub fn new(name: &str) -> Self {
SchemaPiston {
schema: Schema::new(name)
}
}
pub fn assign_controller(&mut self, event: &Event, iaf: InputTypeFlags) -> bool {
self.schema.assign_controller(event, iaf)
}
pub fn assign_input(&mut self, event: &Event, action: TUserAction, iaf: InputTypeFlags) -> bool {
self.schema.assign_input(event, action, iaf)
}
pub fn process_event(&mut self, event: &Event) -> Option<ProcessingResult<TUserAction>> {
self.schema.process_event(event)
}
pub fn set_player_id(&mut self, player_id: Option<usize>) {
self.schema.set_player_id(player_id);
}
pub fn player_id(&self) -> Option<usize> {
self.schema.player_id
}
pub fn controller_id(&self) -> Option<usize> {
self.schema.controller_id
}
}
impl ToEventType<usize> for Event
{
fn to_raw(&self) -> Option<EventType> {
match self {
Event::Input(input) => match input {
Input::Button(args) => match args.button {
Button::Keyboard(v) => Some(EventType::new(1, v as u64)),
Button::Mouse(v) => Some(EventType::new(2, v as u64)),
_ => None
},
Input::Move(args) => match args {
Motion::ControllerAxis(v) => Some(EventType::new(3, u64::from(v.axis))),
Motion::MouseCursor(_, _) => Some(EventType::new(4, 0)), // we only care that it's mouse move here
_ => None
},
_ => None
}
_ => None,
}
}
fn controller_id(&self) -> Option<usize> {
match self {
Event::Input(input) => match input {
Input::Move(args) => match args {
Motion::ControllerAxis(c) => Some(c.id as usize),
_ => None,
},
Input::Button(args) => match args.button {
Button::Controller(c) => Some(c.id as usize),
Button::Hat(c) => Some(c.id as usize),
_ => None,
}
_ => None,
},
_ => None,
}
}
fn filter_for_assignment(&self, iaf: InputTypeFlags) -> bool {
match self {
Event::Input(input) => match input {
Input::Button(args) => match args.state {
PButtonState::Press => match args.button {
Button::Keyboard(_) => iaf.intersects(InputTypeFlags::Key),
Button::Controller(_) | // any non key button here
Button::Mouse(_) |
Button::Hat(_) => iaf.intersects(InputTypeFlags::Button)
},
PButtonState::Release => false, // do not assign from release
},
Input::Move(args) => match args {
Motion::MouseCursor(_, _) => iaf.contains(InputTypeFlags::MouseMove),
Motion::MouseRelative(_, _) => iaf.contains(InputTypeFlags::MouseMove),
Motion::MouseScroll(_, _) => false, // TODO: add proper mouse scroll support to prongs
Motion::ControllerAxis(_) => iaf.contains(InputTypeFlags::Axis),
Motion::Touch(_) => false, // TODO: add touch support to prongs
}
_ => iaf.contains(InputTypeFlags::Other),
},
_ => false,
}
}
fn get_cause(&self) -> Option<InputCause> {
match self {
Event::Input(input) => match input {
Input::Button(args) => match args.state {
PButtonState::Press => Some(InputCause::Button(ButtonState::Pressed)),
PButtonState::Release => Some(InputCause::Button(ButtonState::Released)),
},
Input::Move(args) => match args {
Motion::MouseCursor(x, y) => Some(InputCause::Motion(*x, *y)),
Motion::MouseRelative(_, _) => None,
Motion::MouseScroll(_, _) => None,
Motion::ControllerAxis(_) => None, // InputCause::Axis(), TODO
Motion::Touch(_) => None, // TODO: add touch support to prongs
}
_ => None,
},
_ => None,
}
}
}

@ -0,0 +1,131 @@
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use crate::types::{InputCause, InputTypeFlags, ProcessingResult};
pub mod types;
// error out specifically if no backend is chosen
#[cfg(not(any(feature="backend_piston", feature="backend_gilrs")))]
compile_error!("No backend selected, use features=<backend> in Cargo.toml or --features <backend> when building directly.");
#[cfg(feature="backend_piston")]
pub mod backend_piston;
#[cfg(feature="backend_gilrs")]
pub mod backend_gilrs;
#[cfg(test)]
mod tests;
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(transparent)]
struct EventType(u128);
impl EventType
{
fn new(rt: u64, rv: u64) -> Self {
EventType {
0: (rt as u128).rotate_left(64) + u128::from(rv)
}
}
}
/// Converts backend events to more "generic" and serializable
/// event types. This usually means stripping down needless data
/// and making the result small (u64). For example, for keyboard key mapping
/// we only care about the event's "identifier" for the key and it's state (pressed/released)
/// If there's more info in the backend event we discard that as it could be tied to the
/// instance rather than the "type of input" such as event_id sequence or such.
/// This should be typically implemented by the prongs-backend-<name> sub-cargos.
trait ToEventType<TControllerID>
where TControllerID: Copy + PartialEq + Serialize
{
fn to_raw(&self) -> Option<EventType>;
fn controller_id(&self) -> Option<TControllerID>;
fn filter_for_assignment(&self, iaf: InputTypeFlags) -> bool;
fn get_cause(&self) -> Option<InputCause>;
}
type KeyMap<TUserAction> = HashMap<EventType, TUserAction>;
const TYPICAL_MAPPING_SIZE: usize = 255;
#[derive(Serialize, Deserialize)]
struct Schema<TEventType, TControllerID, TUserAction>
where TEventType: ToEventType<TControllerID>,
TControllerID: Copy + PartialEq + Serialize,
TUserAction: Clone + Serialize,
{
name: String,
player_id: Option<usize>,
controller_id: Option<TControllerID>,
keymap: KeyMap<TUserAction>,
#[serde(skip)]
_phantom: std::marker::PhantomData<TEventType>,
}
impl<TEventType, TControllerID, TUserAction> Schema<TEventType, TControllerID, TUserAction>
where TEventType: ToEventType<TControllerID>,
TControllerID: Copy + PartialEq + Serialize,
TUserAction: Clone + Serialize,
{
fn new(name: &str) -> Self {
Schema {
name: name.to_string(),
keymap: KeyMap::with_capacity(TYPICAL_MAPPING_SIZE),
player_id: None,
controller_id: None,
_phantom: std::marker::PhantomData,
}
}
fn assign_controller(&mut self, event: &TEventType, iaf: InputTypeFlags) -> bool {
let event_controller_id = event.controller_id();
if event_controller_id != self.controller_id
&& event_controller_id.is_some()
&& event.filter_for_assignment(iaf) {
self.controller_id = event.controller_id();
return true
}
false
}
fn assign_input(&mut self, event: &TEventType, action: TUserAction, iaf: InputTypeFlags) -> bool {
if event.filter_for_assignment(iaf) {
if let Some(event_type) = event.to_raw() {
self.keymap.insert(event_type, action);
self.assign_controller(event, iaf);
return true
}
}
false
}
fn process_event(&mut self, event: &TEventType) -> Option<ProcessingResult<TUserAction>> {
if let Some(event_type) = event.to_raw() {
if let Some(action) = self.keymap.get(&event_type) {
if self.controller_id.is_some() && self.controller_id != event.controller_id() {
return None
}
return Some(ProcessingResult {
action: action.clone(),
player_id: self.player_id,
cause: event.get_cause(),
});
}
}
None
}
fn set_player_id(&mut self, player_id: Option<usize>) {
self.player_id = player_id;
}
}

@ -0,0 +1,3 @@
mod types;
mod lib;
mod backends;

@ -0,0 +1,5 @@
#[cfg(any(feature="default", feature="backend_piston"))]
mod backend_piston;
#[cfg(feature="backend_gilrs")]
mod backend_gilrs;

@ -0,0 +1,17 @@
use crate::backend_gilrs::SchemaGilrs;
#[test]
fn schema_set_player_id() {
let mut schema = SchemaGilrs::<u64>::new("Testing");
assert_eq!(schema.player_id(), None);
schema.set_player_id(Some(5));
assert_eq!(schema.player_id(), Some(5));
schema.set_player_id(None);
assert_eq!(schema.player_id(), None);
}
// unable to test assign_controller or assign_input due to Code being hidden and uninstantiable
// unable to test Event* since it's not instantiable from outside the gilrs crate

@ -0,0 +1,63 @@
use crate::backend_piston::SchemaPiston;
use crate::{EventType, ToEventType};
use crate::types::{InputTypeFlags, InputCause, ButtonState};
use piston::input::{Event, Input, Button, ButtonArgs, Key, ButtonState as PButtonState, ControllerButton, Motion};
fn new_event_button(button: Button, state: PButtonState) -> Event {
Event::Input(Input::Button(ButtonArgs {
button: button,
scancode: Some(0x20),
state: state,
}))
}
#[test]
fn event_to_raw() {
let event = new_event_button(Button::Keyboard(Key::Space), PButtonState::Press);
let event_ignorable = Event::Input(Input::Cursor(false));
assert_eq!(event.to_raw(), Some(EventType((1 as u128).rotate_left(64) + (Key::Space as u128))));
assert_eq!(event_ignorable.to_raw(), None);
}
#[test]
fn event_controller_id() {
let event = new_event_button(Button::Controller(ControllerButton::new(5, 1)), PButtonState::Press);
let event_ignorable = Event::Input(Input::Cursor(false));
assert_eq!(event.controller_id(), Some(5));
assert_eq!(event_ignorable.controller_id(), None);
}
#[test]
fn event_filter_for_assignment() {
let event = new_event_button(Button::Controller(ControllerButton::new(5, 1)), PButtonState::Press);
let event_other = Event::Input(Input::Cursor(false));
assert_eq!(event.filter_for_assignment(InputTypeFlags::Axis), false);
assert_eq!(event.filter_for_assignment(InputTypeFlags::Key), false);
assert_eq!(event.filter_for_assignment(InputTypeFlags::Button), true);
assert_eq!(event_other.filter_for_assignment(InputTypeFlags::Other), true);
}
#[test]
fn event_get_cause() {
let event = new_event_button(Button::Controller(ControllerButton::new(5, 1)), PButtonState::Press);
let event_other = Event::Input(Input::Cursor(false));
let event_mouse = Event::Input(Input::Move(Motion::MouseCursor(0.4, 0.5)));
assert_eq!(event.get_cause(), Some(InputCause::Button(ButtonState::Pressed)));
assert_eq!(event_other.get_cause(), None);
assert_eq!(event_mouse.get_cause(), Some(InputCause::Motion(0.4, 0.5)));
}
#[test]
fn schema_set_player_id() {
let mut schema = SchemaPiston::<u64>::new("Testing");
assert_eq!(schema.player_id(), None);
schema.set_player_id(Some(5));
assert_eq!(schema.player_id(), Some(5));
schema.set_player_id(None);
assert_eq!(schema.player_id(), None);
}

@ -0,0 +1,107 @@
use crate::{EventType, ToEventType, Schema};
// required for schema instantiations
impl ToEventType<usize> for u64
{
fn to_raw(&self) -> Option<EventType> {
Some(EventType::new(*self, *self))
}
fn controller_id(&self) -> Option<usize> {
if *self > 0 { // we can test both variants in schema tests this way
return Some(*self as usize)
}
None
}
fn filter_for_assignment(&self, iaf: crate::types::InputTypeFlags) -> bool {
iaf == crate::types::InputTypeFlags::Other
}
fn get_cause(&self) -> Option<crate::types::InputCause> {
match *self {
1 => Some(crate::types::InputCause::Button(crate::types::ButtonState::Pressed)),
2 => Some(crate::types::InputCause::Button(crate::types::ButtonState::Released)),
3 => Some(crate::types::InputCause::Axis(0, 0.0)),
4 => Some(crate::types::InputCause::Axis(0, 1.0)),
5 => Some(crate::types::InputCause::Motion(0.0, 0.0)),
6 => Some(crate::types::InputCause::Motion(1.0, 1.0)),
103 => Some(crate::types::InputCause::Motion(0.2, 0.5)),
_ => None,
}
}
}
#[test]
fn event_type_new() {
let rt: u64 = 348;
let rv: u64 = 982374;
assert!(EventType::new(rt, rv).0 == (rt as u128).rotate_left(64) + u128::from(rv));
}
#[test]
fn schema_new() {
assert!(Schema::<u64, usize, usize>::new("somename").name == "somename");
}
#[test]
fn schema_assign_controller() {
let mut schema = Schema::<u64, usize, usize>::new("somename");
assert!(schema.assign_controller(&0, crate::types::InputTypeFlags::Any) == false);
assert!(schema.assign_controller(&1, crate::types::InputTypeFlags::Other) == true);
assert!(schema.controller_id == Some(1));
assert!(schema.assign_controller(&2, crate::types::InputTypeFlags::Other) == true);
assert!(schema.controller_id == Some(2));
assert!(schema.assign_controller(&2, crate::types::InputTypeFlags::Other) == false);
assert!(schema.controller_id == Some(2));
}
fn schema_assign_input_internal(schema: &mut Schema<u64, usize, usize>) {
assert_eq!(schema.assign_input(&100, 3, crate::types::InputTypeFlags::Any), false); // filtered out (InputTypeFlags::Any -> ignore)
assert_eq!(schema.assign_input(&110, 0, crate::types::InputTypeFlags::Other), true); // empty cause
assert_eq!(schema.assign_input(&101, 4, crate::types::InputTypeFlags::Other), true); // 0/1.0 axis
assert_eq!(schema.assign_input(&102, 1, crate::types::InputTypeFlags::Other), true); // release button
assert_eq!(schema.assign_input(&103, 5, crate::types::InputTypeFlags::Other), true); // 0.0/0.0 motion
assert_eq!(schema.keymap.len(), 4);
assert_eq!(schema.keymap.get(&EventType::new(110, 110)), Some(&0));
assert_eq!(schema.keymap.get(&EventType::new(101, 101)), Some(&4));
assert_eq!(schema.keymap.get(&EventType::new(102, 102)), Some(&1));
assert_eq!(schema.keymap.get(&EventType::new(103, 103)), Some(&5));
assert_eq!(schema.assign_input(&103, 6, crate::types::InputTypeFlags::Other), true); // override with motion 1.0/1.0
assert_eq!(schema.keymap.get(&EventType::new(103, 103)), Some(&6));
}
#[test]
fn schema_assign_input() {
let mut schema = Schema::<u64, usize, usize>::new("somename");
schema_assign_input_internal(&mut schema);
}
#[test]
fn schema_process_event() {
let mut schema = Schema::<u64, usize, usize>::new("somename");
schema_assign_input_internal(&mut schema);
// NOTE: last assign set the controller_id to "103" so this is the only one that passes here
assert_eq!(schema.process_event(&103), Some(crate::types::ProcessingResult::<usize> {
action: 6,
player_id: None,
cause: Some(crate::types::InputCause::Motion(0.2, 0.5)),
}));
// doesn't pass since controller_id for event != controller_id set for schema
assert_eq!(schema.process_event(&102), None);
}
#[test]
fn schema_set_player_id() {
let mut schema = Schema::<u64, usize, usize>::new("somename");
schema.set_player_id(Some(5));
assert!(schema.player_id == Some(5));
schema.set_player_id(Some(34258));
assert!(schema.player_id == Some(34258));
}

@ -0,0 +1,98 @@
use crate::types::{InputCause, ButtonState, ProcessingResult};
// ------------------- InputCause ------------------- //
#[test]
fn input_cause_is_engaged() {
assert!(InputCause::Button(ButtonState::Pressed).is_engaged() == true);
assert!(InputCause::Button(ButtonState::Released).is_engaged() == false);
assert!(InputCause::Axis(0, 0.0).is_engaged() == false);
assert!(InputCause::Axis(1, 0.0).is_engaged() == false);
assert!(InputCause::Axis(1, 0.1).is_engaged() == true);
assert!(InputCause::Motion(0.0, 0.0).is_engaged() == false);
assert!(InputCause::Motion(0.0, 1.0).is_engaged() == false);
assert!(InputCause::Motion(1.0, 1.0).is_engaged() == false);
}
#[test]
fn input_cause_is_axis() {
assert!(InputCause::Button(ButtonState::Released).is_axis() == false);
assert!(InputCause::Axis(0, 0.0).is_axis() == true);
assert!(InputCause::Motion(0.0, 0.0).is_axis() == false);
}
#[test]
fn input_cause_scalar_value() {
assert!(InputCause::Button(ButtonState::Pressed).scalar_value() == 1.0);
assert!(InputCause::Button(ButtonState::Released).scalar_value() == 0.0);
assert!(InputCause::Axis(0, 0.0).scalar_value() == 0.0);
assert!(InputCause::Axis(1, 0.0).scalar_value() == 0.0);
assert!(InputCause::Axis(1, 0.1).scalar_value() == 0.1);
assert!(InputCause::Motion(0.0, 0.0).scalar_value() == 0.0);
assert!(InputCause::Motion(0.0, 1.0).scalar_value() == 0.0);
assert!(InputCause::Motion(1.0, 1.0).scalar_value() == 1.0);
}
// ------------------- ProcessingResult ------------------- //
#[test]
fn processing_result_input_is_engaged() {
let pr_with_cause = |cause| {
ProcessingResult {
action: 0,
player_id: Some(0),
cause: Some(cause),
}
};
assert!(pr_with_cause(InputCause::Button(ButtonState::Pressed)).input_is_engaged() == true);
assert!(pr_with_cause(InputCause::Button(ButtonState::Released)).input_is_engaged() == false);
assert!(pr_with_cause(InputCause::Axis(0, 0.0)).input_is_engaged() == false);
assert!(pr_with_cause(InputCause::Axis(1, 0.0)).input_is_engaged() == false);
assert!(pr_with_cause(InputCause::Axis(1, 0.1)).input_is_engaged() == true);
assert!(pr_with_cause(InputCause::Motion(0.0, 0.0)).input_is_engaged() == false);
assert!(pr_with_cause(InputCause::Motion(0.0, 1.0)).input_is_engaged() == false);
assert!(pr_with_cause(InputCause::Motion(1.0, 1.0)).input_is_engaged() == false);
assert!(ProcessingResult { action: 0, player_id: Some(0), cause: None }.input_is_engaged() == false);
}
#[test]
fn processing_result_input_is_axis() {
let pr_with_cause = |cause| {
ProcessingResult {
action: 0,
player_id: Some(0),
cause: Some(cause),
}
};
assert!(pr_with_cause(InputCause::Button(ButtonState::Pressed)).input_is_axis() == false);
assert!(pr_with_cause(InputCause::Axis(0, 0.0)).input_is_axis() == true);
assert!(pr_with_cause(InputCause::Motion(0.0, 0.0)).input_is_axis() == false);
assert!(ProcessingResult { action: 0, player_id: Some(0), cause: None }.input_is_axis() == false);
}
#[test]
fn processing_result_input_scalar_value() {
let pr_with_cause = |cause| {
ProcessingResult {
action: 0,
player_id: Some(0),
cause: Some(cause),
}
};
assert!(pr_with_cause(InputCause::Button(ButtonState::Pressed)).input_scalar_value() == 1.0);
assert!(pr_with_cause(InputCause::Button(ButtonState::Released)).input_scalar_value() == 0.0);
assert!(pr_with_cause(InputCause::Axis(0, 0.0)).input_scalar_value() == 0.0);
assert!(pr_with_cause(InputCause::Axis(1, 0.0)).input_scalar_value() == 0.0);
assert!(pr_with_cause(InputCause::Axis(1, 0.1)).input_scalar_value() == 0.1);
assert!(pr_with_cause(InputCause::Motion(0.0, 0.0)).input_scalar_value() == 0.0);
assert!(pr_with_cause(InputCause::Motion(0.0, 1.0)).input_scalar_value() == 0.0);
assert!(pr_with_cause(InputCause::Motion(1.0, 1.0)).input_scalar_value() == 1.0);
assert!(ProcessingResult { action: 0, player_id: Some(0), cause: None }.input_scalar_value() == 0.0);
}

@ -0,0 +1,128 @@
use serde::{Serialize};
bitflags::bitflags! {
/// InputTypeFlags are used to specify what type of input
/// is to be allowed when in "assignment mode" for event mapping.
/// This allows the caller to filter out unwanted event types in a
/// generic way without having to handle the backend implementation details.
#[derive(Default)]
pub struct InputTypeFlags: u64
{
/// Any controller or mouse button including controller "hat" presses
const Button = 0b0000_0001;
/// Any keyboard key
const Key = 0b0000_0010;
/// Any controller axis
const Axis = 0b0000_0100;
/// Any mouse movement
const MouseMove = 0b0000_1000;
/// Key or Button combination
const KeyOrButton = Self::Button.bits | Self::Key.bits;
/// Axis, Key or Button combination
const AxisKeyOrButton = Self::Axis.bits | Self::KeyOrButton.bits;
/// Anything else (so you can do Any - Other for e.g. disconnect events etc.)
const Other = 0b0010_0000;
/// Any type
const Any = 0xffff_ffff_ffff_ffff;
}
}
/// Describes states a key or button can be in
#[derive(Debug, PartialEq, Eq)]
pub enum ButtonState
{
/// when key or button is pressed
Pressed,
/// when key or button is released
Released,
}
/// Describes the source of input for a [ProcessingResult](struct.ProcessingResult.html)
#[derive(Debug, PartialEq)]
pub enum InputCause
{
/// a key or button as source, with given state
Button(ButtonState),
/// an axis set to specific value in range <-1.0, 1.0>
Axis(u8, f64), // axis, value TODO: map axis to actual possibilities
/// a motion source (e.g. mouse) with x, y values
Motion(f64, f64), // x, y
}
impl InputCause
{
pub fn is_engaged(&self) -> bool {
match self {
InputCause::Button(state) => *state == ButtonState::Pressed,
InputCause::Axis(_, value) => *value != 0.0,
InputCause::Motion(_, _) => false, // never "engaged"
}
}
pub fn is_axis(&self) -> bool {
match self {
InputCause::Axis(_, _) => true,
_ => false,
}
}
pub fn scalar_value(&self) -> f64 {
match self {
InputCause::Button(state) => if *state == ButtonState::Pressed {
1.0
} else {
0.0
},
InputCause::Axis(_, value) => *value,
InputCause::Motion(x, y) => x * y,
}
}
}
/// The result of a successful input processing by a Schema
#[derive(Debug, PartialEq)]
pub struct ProcessingResult<TUserAction>
where TUserAction: Clone + Serialize,
{
/// The user defined action to be performed based on the input event
pub action: TUserAction,
/// The player_id if assigned to the Schema previously, otherwise None
pub player_id: Option<usize>,
/// The [InputCause](enum.InputCause.html) of this input, if known. None only if backend implementation is incomplete.
pub cause: Option<InputCause>,
}
impl<TUserAction> ProcessingResult<TUserAction>
where TUserAction: Clone + Serialize,
{
/// Specifies if the input cause is engaged (pressed or not equal to 0)
/// *NOTE*: some input causes are never engaged, e.g. Motion
pub fn input_is_engaged(&self) -> bool {
if let Some(cause) = &self.cause {
return cause.is_engaged()
}
false
}
/// Specifies if the input cause is an axis
pub fn input_is_axis(&self) -> bool {
if let Some(cause) = &self.cause {
return cause.is_axis()
}
false
}
/// Reduces the input cause state value to a single f64
/// Key or button states are either 0.0 or 1.0 for pressed
/// Axis value stays same
/// Motion x, y values are multiplied (x * y)
pub fn input_scalar_value(&self) -> f64 {
if let Some(cause) = &self.cause {
return cause.scalar_value()
}
0.0
}
}
Loading…
Cancel
Save