(snapshot: &mut InputSnapshot, event: &InputEvent)
| 193 | } |
| 194 | |
| 195 | fn apply_event(snapshot: &mut InputSnapshot, event: &InputEvent) { |
| 196 | match event { |
| 197 | InputEvent::Key { key, is_down } => snapshot.set_key_state(*key, *is_down), |
| 198 | InputEvent::Text(text) => snapshot.push_text_input(text.clone()), |
| 199 | InputEvent::MouseButton { button, is_down } => { |
| 200 | snapshot.set_mouse_button_state(*button, *is_down) |
| 201 | } |
| 202 | InputEvent::MouseDelta { dx, dy } => snapshot.add_mouse_delta(*dx, *dy), |
| 203 | InputEvent::MouseWheel { dx, dy } => snapshot.add_mouse_wheel(*dx, *dy), |
| 204 | InputEvent::MousePosition { x, y } => snapshot.set_mouse_position(*x, *y), |
| 205 | InputEvent::MouseMode(mode) => snapshot.set_mouse_mode_state(*mode), |
| 206 | InputEvent::ViewportSize { width, height } => snapshot.set_viewport_size(*width, *height), |
| 207 | InputEvent::GamepadButton { |
| 208 | index, |
| 209 | button, |
| 210 | is_down, |
| 211 | } => snapshot.set_gamepad_button_state(*index, *button, *is_down), |
| 212 | InputEvent::GamepadAxis { index, axis, value } => { |
| 213 | snapshot.set_gamepad_axis(*index, *axis, *value) |
| 214 | } |
| 215 | InputEvent::GamepadGyro { index, x, y, z } => snapshot.set_gamepad_gyro(*index, *x, *y, *z), |
| 216 | InputEvent::GamepadAccel { index, x, y, z } => { |
| 217 | snapshot.set_gamepad_accel(*index, *x, *y, *z) |
| 218 | } |
| 219 | InputEvent::JoyConButton { |
| 220 | index, |
| 221 | button, |
| 222 | is_down, |
| 223 | } => snapshot.set_joycon_button_state(*index, *button, *is_down), |
| 224 | InputEvent::JoyConStick { index, stick } => snapshot.set_joycon_stick_unit(*index, *stick), |
| 225 | InputEvent::JoyConSide { index, side } => snapshot.set_joycon_side(*index, *side), |
| 226 | InputEvent::JoyConConnected { index, connected } => { |
| 227 | snapshot.set_joycon_connected(*index, *connected) |
| 228 | } |
| 229 | InputEvent::JoyConCalibrated { index, calibrated } => { |
| 230 | snapshot.set_joycon_calibrated(*index, *calibrated) |
| 231 | } |
| 232 | InputEvent::JoyConCalibrationInProgress { index, in_progress } => { |
| 233 | snapshot.set_joycon_calibration_in_progress(*index, *in_progress) |
| 234 | } |
| 235 | InputEvent::JoyConCalibrationBias { index, x, y, z } => { |
| 236 | snapshot.set_joycon_calibration_bias(*index, *x, *y, *z) |
| 237 | } |
| 238 | InputEvent::JoyConGyro { index, x, y, z } => snapshot.set_joycon_gyro(*index, *x, *y, *z), |
| 239 | InputEvent::JoyConAccel { index, x, y, z } => snapshot.set_joycon_accel(*index, *x, *y, *z), |
| 240 | InputEvent::JoyConMouseSensor { |
| 241 | index, |
| 242 | x, |
| 243 | y, |
| 244 | extra, |
| 245 | distance, |
| 246 | } => snapshot.set_joycon_mouse_sensor(*index, *x, *y, *extra, *distance), |
| 247 | InputEvent::BindPlayer { index, binding } => snapshot.bind_player(*index, *binding), |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | #[cfg(test)] |
| 252 | mod tests { |
no test coverage detected