(action: i32, x: f64, y: f64, pointer_index: i32)
| 269 | /// Called by Perry's Android layer when a touch event occurs. |
| 270 | #[no_mangle] |
| 271 | pub 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] |
| 297 | pub extern "C" fn bloom_begin_drawing() { |
no test coverage detected