MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / bloom_android_on_touch

Function bloom_android_on_touch

native/android/src/lib.rs:271–294  ·  view source on GitHub ↗
(action: i32, x: f64, y: f64, pointer_index: i32)

Source from the content-addressed store, hash-verified

269/// Called by Perry's Android layer when a touch event occurs.
270#[no_mangle]
271pub extern "C" fn bloom_android_on_touch(action: i32, x: f64, y: f64, pointer_index: i32) {
272 unsafe {
273 if let Some(eng) = ENGINE.get_mut() {
274 let sw = eng.screen_width();
275 let sh = eng.screen_height();
276 let lx = x * 0.5;
277 let ly = y * 0.5;
278 let msg = std::ffi::CString::new(format!("touch a={} raw=({},{}) scaled=({},{}) sw={} sh={}", action, x, y, lx, ly, sw, sh)).unwrap();
279 __android_log_print(3, b"BloomTouch\0".as_ptr(), b"%s\0".as_ptr(), msg.as_ptr());
280 eng.input.set_mouse_position(lx, ly);
281 if action == 1 || action == 3 {
282 eng.input.release_touch(pointer_index as usize, lx, ly); // UP / CANCEL
283 } else {
284 eng.input.set_touch(pointer_index as usize, lx, ly, true); // DOWN / MOVE
285 }
286 match action {
287 0 => eng.input.set_mouse_button_down(0), // ACTION_DOWN
288 1 => eng.input.set_mouse_button_up(0), // ACTION_UP
289 2 => {} // ACTION_MOVE
290 _ => {}
291 }
292 }
293 }
294}
295
296#[no_mangle]
297pub extern "C" fn bloom_begin_drawing() {

Calls 9

get_mutMethod · 0.80
screen_widthMethod · 0.80
screen_heightMethod · 0.80
as_ptrMethod · 0.80
set_mouse_positionMethod · 0.80
release_touchMethod · 0.80
set_touchMethod · 0.80
set_mouse_button_downMethod · 0.80
set_mouse_button_upMethod · 0.80

Tested by

no test coverage detected