canselcik / libremarkable

The only public framework for developing applications with native refresh support for Remarkable Tablet
MIT License
607 stars 57 forks source link

C bindings #112

Closed liamdiprose closed 1 year ago

liamdiprose commented 1 year ago

I'd like to wrap this library for Racket.

Is there any interest in adding C bindings to libremarkable?

LinusCDE commented 1 year ago

I don't think there is any interest currently.

It should be pretty doable though. I see two ways for that

Approach 1: Wrapper Rust Lib that exports wrapped functions to C

However it should not be too hard to make a wrapper project that simply exposes things as C functions. Depending on what functionality is needed it should be easy enough to do, however to cover most of the features would probably mean a lot of porting and wrapping types etc.

Here is a good primer that explains how a rust project can export C functions and build a shared object file: https://docs.rust-embedded.org/book/interoperability/rust-with-c.html

I can draft a minimal project that can do that, but I don't have the capacity to make a C Lib that cover a substantial area of the functionality of this rust lib.

There also seems to be a lib that will then automate generating proper header files (the reverse of bindgen): https://github.com/mozilla/cbindgen

Approach 2: Use the old c implementation

This repo also has a branch that preserves the old c implementation I'm not familiar with it, but I think it was the initial project of the lib. There are likely a lot of features missing, but together with remarkable2-framebuffer I'd assume that you could use that to get the core functionality running with that.

Maybe this approach might be the fastest to get going.

liamdiprose commented 1 year ago

Hi @LinusCDE,

Thanks for your detailed reply. I'm thinking of using Approach 1. For some reason I thought the work could only be done in this repository. I'm happy to start the repository if you don't. What do you think of "libremarkable-c"?

EnderKill98 commented 1 year ago

Sure I don't mind.

Any objections regarding the name, @fenollp, @bkirwi ?

bkirwi commented 1 year ago

The name sounds fine to me! Though I generally don't have strong opinions here. It does sound like a distinct crate would be the fastest way to get started... we can always merge it in later if there's more interest / the approach works well.

On Tue, May 16, 2023 at 8:08 AM EnderKill98 @.***> wrote:

Sure I don't mind.

Any objections regarding the name, @fenollp https://github.com/fenollp, @bkirwi https://github.com/bkirwi ?

— Reply to this email directly, view it on GitHub https://github.com/canselcik/libremarkable/issues/112#issuecomment-1549540692, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMFXM7EHBWUD4ORAMYXRW3XGNU5JANCNFSM6AAAAAAYBZPRC4 . You are receiving this because you were mentioned.Message ID: @.***>

liamdiprose commented 1 year ago

Feel free to reach out in the issues.

https://github.com/liamdiprose/libremarkable-c