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

Function bloom_get_language

native/android/src/lib.rs:1406–1433  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1404/// user-set locale first, then the factory defaults. Falls back to "en".
1405#[no_mangle]
1406pub 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]
1435pub extern "C" fn bloom_is_any_input_pressed() -> f64 {
1436 if engine().input.is_any_input_pressed() { 1.0 } else { 0.0 }

Callers

nothing calls this directly

Calls 2

parseFunction · 0.85
as_ptrMethod · 0.80

Tested by

no test coverage detected