Code Monkey home page Code Monkey logo

rosu_native's Introduction

rosu_native

packaged rosu-pp into native library that can use in other language like java

current state: WIP(only one simple function)

input format:

#[repr(C)]
pub struct OsuMap {
    /// .osu file path not the map folder
    path: *const c_char,
    /// mods combine 
    /// <see>https://docs.rs/rosu-pp/latest/rosu_pp/trait.Mods.html<see/>
    mods: u32,
    /// accuracy
    acc: f64,
    /// miss count
    miss: usize,
    /// scores max combo
    combo: usize,
    /// map max combo
    max_combo: usize,
}

output format:

#[repr(C)]
pub struct PPResult {
    /// pp
    pub pp: f64,
    /// The accuracy portion of the final pp.
    pub pp_acc: f64,
    /// The aim portion of the final pp.
    pub pp_aim: f64,
    /// The speed portion of the final pp.
    pub pp_speed: f64,
    /// Max pp
    pub max_pp: f64,
    /// pp if fc
    pub pp_fc: f64,
    /// map star
    pub map_star: f64,
    /// debug text
    pub debug_text: *const c_char,
}

Then you can use in java

example:

public interface Rosu_PP extends StdCallLibrary {
    File dllFile = new File("path/to/native/dll complied file");
    
    Rosu_PP INSTANCE = (Rosu_PP) Native.load(dllFile.getAbsolutePath(),
            Rosu_PP.class);
            
    PPResult cal_pp(OsuMap map);

}
@Structure.FieldOrder({"path","mods","acc","miss","combo","max_combo"})
public class OsuMap extends Structure {

    public String
    path;

    public long
    mods;
    public double
    acc;
    public long
    miss;
    public long
    combo;
    public long
    max_combo;
    //ingored constructor
}
public static void main(String[] args) {
    File osuFile = new File("path/to/osu/file");
    OsuMap map = new OsuMap(
        osuFile.getAbsolutePath(),//path
        0,//mods (None)
        93.89,//acc
        23,//miss
        372,//combo
        2063//max combo
    );
    PPResult ppResult = Rosu_PP.INSTANCE.cal_pp(map);
}

rosu_native's People

Contributors

daygoodtime avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.