| 1404 | /// user-set locale first, then the factory defaults. Falls back to "en". |
| 1405 | #[no_mangle] |
| 1406 | pub extern "C" fn bloom_get_language() -> f64 { |
| 1407 | fn parse(buf: &[u8], n: i32) -> Option<f64> { |
| 1408 | if n < 2 { return None; } |
| 1409 | let lc = |b: u8| if b.is_ascii_uppercase() { b + 32 } else { b }; |
| 1410 | let (c0, c1) = (lc(buf[0]), lc(buf[1])); |
| 1411 | if c0.is_ascii_alphabetic() && c1.is_ascii_alphabetic() { |
| 1412 | Some((c0 as f64) * 256.0 + (c1 as f64)) |
| 1413 | } else { |
| 1414 | None |
| 1415 | } |
| 1416 | } |
| 1417 | let props: [&[u8]; 3] = [ |
| 1418 | b"persist.sys.locale\0", |
| 1419 | b"ro.product.locale\0", |
| 1420 | b"ro.product.locale.language\0", |
| 1421 | ]; |
| 1422 | for prop in props { |
| 1423 | let mut buf = [0u8; 92]; // PROP_VALUE_MAX |
| 1424 | let n = unsafe { |
| 1425 | libc::__system_property_get( |
| 1426 | prop.as_ptr() as *const libc::c_char, |
| 1427 | buf.as_mut_ptr() as *mut libc::c_char, |
| 1428 | ) |
| 1429 | }; |
| 1430 | if let Some(v) = parse(&buf, n) { return v; } |
| 1431 | } |
| 1432 | 25966.0 |
| 1433 | } |
| 1434 | #[no_mangle] |
| 1435 | pub extern "C" fn bloom_is_any_input_pressed() -> f64 { |
| 1436 | if engine().input.is_any_input_pressed() { 1.0 } else { 0.0 } |