MCPcopy Create free account
hub / github.com/PerroEngine/Perro / set_button

Method set_button

perro_source/render_stack/perro_app/src/input/gamepad.rs:304–333  ·  view source on GitHub ↗
(
            &mut self,
            app: &mut S,
            gilrs: &Gilrs,
            id: GamepadId,
            button: GamepadButton,
            is_down: bool,
        )

Source from the content-addressed store, hash-verified

302 app.set_gamepad_axis(index, mapped, value);
303 self.log_raw_like_state(gilrs, id, "axis_changed");
304 }
305 } else {
306 self.handle_dpad_axis(app, gilrs, id, axis, value);
307 self.log_raw_like_state(gilrs, id, "dpad_axis_changed");
308 }
309 }
310 _ => {}
311 }
312 }
313
314 fn set_button<S: GamepadSink>(
315 &mut self,
316 app: &mut S,
317 gilrs: &Gilrs,
318 id: GamepadId,
319 button: GamepadButton,
320 is_down: bool,
321 ) {
322 let Some(index) = self.assign_index_if_unique(gilrs, id) else {
323 return;
324 };
325 let bit = 1u32 << (button as usize);
326 let current = self.down_masks.get(&id).copied().unwrap_or(0);
327 let was_down = (current & bit) != 0;
328 if was_down == is_down {
329 return;
330 }
331 let mut next = current;
332 if is_down {
333 next |= bit;
334 } else {
335 next &= !bit;
336 }

Callers 3

handle_eventMethod · 0.80
handle_dpad_axisMethod · 0.80
sync_buttonsMethod · 0.80

Calls 5

getMethod · 0.45
removeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected