ReviewOS

also looking at this

craft-native/craft

feat(android): haptic and vibrate — ratchet 91 -> 89

#150
Merged chris wants to merge feat/android-haptics into main
7 files +410 -3
packages/zig/src/jni_runtime.zigmodified+24-0
Changes to packages/zig/src/jni_runtime.zig
@@ -696,6 +696,30 @@ pub const Jni = struct {
696696 return value;
697697 }
698698
699 // --- Arrays -----------------------------------------------------------
700 //
701 // Only `long[]` so far, because only `VibrationEffect.createWaveform`
702 // needs one. `SetLongArrayRegion` copies from a Zig slice in one call
703 // rather than element by element, which is both faster and the only form
704 // that cannot leave a partially-filled array behind on an error.
705
706 pub fn newLongArray(self: Self, values: []const jlong) JniError!jobject {
707 const new: *const fn (JNIEnv, jsize) callconv(.c) jobject =
708 @ptrCast(self.table().NewLongArray orelse return JniError.NotFound);
709 const array = new(self.env, @intCast(values.len)) orelse {
710 try self.check();
711 return JniError.OutOfMemory;
712 };
713
714 if (values.len == 0) return array;
715
716 const set: *const fn (JNIEnv, jobject, jsize, jsize, [*]const jlong) callconv(.c) void =
717 @ptrCast(self.table().SetLongArrayRegion orelse return JniError.NotFound);
718 set(self.env, array, 0, @intCast(values.len), values.ptr);
719 try self.check();
720 return array;
721 }
722
699723 /// Make a Java `String` from UTF-8.
700724 ///
701725 /// The JVM wants *modified* UTF-8 here, the same encoding `stringToUtf8`