diff --git a/Project.toml b/Project.toml index 3c2e922..32e9fe1 100644 --- a/Project.toml +++ b/Project.toml @@ -1,16 +1,14 @@ name = "MiniFB" uuid = "cc649173-1898-4bb8-8a16-ca5f88bd87d9" authors = ["Avik Sengupta"] -version = "0.1.1" +version = "0.2.0" [deps] Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" -CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82" MiniFB_jll = "b93afbca-07d8-5443-9979-bb4221978155" [compat] Colors = "0.10, 0.11, 0.12" -CEnum = "0.4" julia = "1.3" [extras] diff --git a/docs/make.jl b/docs/make.jl index fecaabb..d896dd6 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -22,8 +22,7 @@ makedocs(; "Image" => "example/Image.md", "Guilloche" => "example/Guilloche.md" ], - "API" => "api.md", - "Generated Code" => "gen.md" + "API" => "api.md" ], sitename="MiniFB", authors="Avik Sengupta" diff --git a/docs/src/gen.md b/docs/src/gen.md deleted file mode 100644 index 7940c13..0000000 --- a/docs/src/gen.md +++ /dev/null @@ -1,27 +0,0 @@ -## Code generation using Clang - -The code for this package has been generated using [Clang.jl](https://github.com/JuliaInterop/Clang.jl). - -* Add Clang.jl to the current environment -* Change current working directory to `MiniFB/src` -* Clone the source of the MiniFB library from `https://github.com/emoon/minifb` to `/tmp` - -Then run the following code will regenerate the files: - -``` -const MINCLUDE = "/tmp/minifb/include/" -const MHEADERS=["/tmp/minifb/include/MiniFB_enums.h", "/tmp/minifb/include/MiniFB.h"] - -wc = init(; headers=MHEADERS, output_file="libminifb_api.jl", - common_file="libminifb_common.jl", - clang_includes=vcat(MINCLUDE, CLANG_INCLUDE), - clang_args=["-I", MINCLUDE], - header_wrapped = (root, current)->root == current, - header_library = x->"libminifb", - clang_diagnostics = true - ) - -run(wc) -``` - -This will generate `ctypes.jl`, `libminifb_api.jl` and `libminifb_common.jl`. diff --git a/example/Guilloche.jl b/example/Guilloche.jl index 588b584..4f56359 100644 --- a/example/Guilloche.jl +++ b/example/Guilloche.jl @@ -1,12 +1,12 @@ -# This code shows how visualisations created with [Luxor.jl](https://github.com/JuliaGraphics/Luxor.jl) can be -# rendered easily with MiniFB. +# This code shows how visualisations created with [Luxor.jl](https://github.com/JuliaGraphics/Luxor.jl) can be +# rendered easily with MiniFB. # Add the Luxor, Colors and MiniFB packages to your environment before running this code. using Luxor, MiniFB, Colors +using MiniFB.LibMiniFB - -# [Guilloché](https://en.wikipedia.org/wiki/Guilloch%C3%A9) is a decorative technique in which a very precise, intricate and repetitive pattern is mechanically -# engraved into an underlying material via engine turning. The following struct contains the metadata used to render the pattern. +# [Guilloché](https://en.wikipedia.org/wiki/Guilloch%C3%A9) is a decorative technique in which a very precise, intricate and repetitive pattern is mechanically +# engraved into an underlying material via engine turning. The following struct contains the metadata used to render the pattern. mutable struct Guilloche f1::Float64 f2::Float64 @@ -48,13 +48,13 @@ function drawguilloche(g::Guilloche, radius=20; strokepath() end -# The main method sets up the Guilloche struct, opens the window for display, and animates the frames using a while loop. +# The main method sets up the Guilloche struct, opens the window for display, and animates the frames using a while loop. function main() WIDTH = 600 HEIGHT = 600 window = mfb_open_ex("Luxor -> MiniFB", WIDTH, HEIGHT, MiniFB.WF_RESIZABLE) y = 0.1 - g2 = Guilloche(2, 1.5, 3, 1, + g2 = Guilloche(2, 1.5, 3, 1, 0.0005, 0.0005, 0.0005, 0.0005, .1, .1, .1, .1) t1 = time_ns() @@ -78,16 +78,16 @@ function main() limit=10, colorfunction = (t) -> sethue(HSL(rescale(t, 0, 300, 0, 359), 0.9, 0.7))) t2 = time_ns() - text(string("fps: ", round(1E9/(t2-t1), digits=2)), + text(string("fps: ", round(1E9/(t2-t1), digits=2)), boxtopleft(BoundingBox() * 0.9)) end 600 600 y = y + 0.001 (y > 1) && (y = 0.1) # The image matrix created by Luxor is, in standard Julia convention, column first. The buffer -# expected by MiniFB is row first. The call to `permutedims` makes that change. +# expected by MiniFB is row first. The call to `permutedims` makes that change. state = mfb_update(window, permutedims(buffer, (2, 1))) t1 = t2 -# Exit when the user closes the window. +# Exit when the user closes the window. if state != MiniFB.STATE_OK break end @@ -95,10 +95,10 @@ function main() mfb_close(window) end -# Call the main function. This produces really attractive animations -- I highly reccomend you run this yourself! -# The static image below shows you one frame, but does not do justice to the whole animation. +# Call the main function. This produces really attractive animations -- I highly reccomend you run this yourself! +# The static image below shows you one frame, but does not do justice to the whole animation. main() # ![](../assets/guilloche.png) -# _Thanks to [`@Cormullion`](https://github.com/cormullion) for this example_ \ No newline at end of file +# _Thanks to [`@Cormullion`](https://github.com/cormullion) for this example_ diff --git a/example/Image.jl b/example/Image.jl index 01d7bb1..1e98b72 100644 --- a/example/Image.jl +++ b/example/Image.jl @@ -5,6 +5,7 @@ using Images using ImageTransformations using MiniFB +using MiniFB.LibMiniFB # Set the size of the window global const WIDTH = 600 diff --git a/example/Noise.jl b/example/Noise.jl index 005508a..a86b43c 100644 --- a/example/Noise.jl +++ b/example/Noise.jl @@ -1,6 +1,8 @@ using MiniFB +using MiniFB.LibMiniFB + # A simple function that renders some noise to a window. Demonstrates how to create a window and render a buffer into it using MiniFB function noise() WIDTH = 800 @@ -18,7 +20,7 @@ function noise() seed = seed >> 1; seed = seed | (carry << 30); noise = noise & 0xFF; - g_buffer[i] = mfb_rgb(noise, noise, noise); + g_buffer[i] = mfb_rgb(noise, noise, noise); end state = mfb_update(window, g_buffer); if state != MiniFB.STATE_OK @@ -31,4 +33,4 @@ end # Call the function noise() -# ![](../assets/noise.png) \ No newline at end of file +# ![](../assets/noise.png) diff --git a/example/Plasma.jl b/example/Plasma.jl index abcc577..dd9a857 100644 --- a/example/Plasma.jl +++ b/example/Plasma.jl @@ -1,7 +1,8 @@ using MiniFB +using MiniFB.LibMiniFB -# This function displays a time-varying mix of colors on screen. Demonstrates how to create a buffer and render it to a window. +# This function displays a time-varying mix of colors on screen. Demonstrates how to create a buffer and render it to a window. function plasma() pallete = zeros(UInt32, 512) WIDTH = 320 @@ -27,9 +28,9 @@ function plasma() time_y = cos(time * π / 180); i = 1; for y in 1:HEIGHT - dy = cos((y * time_y) * π / 180); + dy = cos((y * time_y) * π / 180); for x in 1:WIDTH - dx = sin((x * time_x) * π / 180); + dx = sin((x * time_x) * π / 180); idx = round(Int, ((2 + dx + dy) * 0.25 * 511) + 1) g_buffer[i] = pallete[idx]; i += 1 @@ -47,4 +48,4 @@ end # Call the function plasma() -# ![](../assets/plasma.png) \ No newline at end of file +# ![](../assets/plasma.png) diff --git a/gen/.gitignore b/gen/.gitignore new file mode 100644 index 0000000..a329c57 --- /dev/null +++ b/gen/.gitignore @@ -0,0 +1,4 @@ +MiniFB.h +MiniFB_enums.h +MiniFB_cpp.h +MiniFB_ios.h \ No newline at end of file diff --git a/gen/Manifest.toml b/gen/Manifest.toml new file mode 100644 index 0000000..d02a58c --- /dev/null +++ b/gen/Manifest.toml @@ -0,0 +1,217 @@ +# This file is machine-generated - editing it directly is not advised + +[[ArgTools]] +uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" + +[[Artifacts]] +uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" + +[[Base64]] +uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" + +[[CEnum]] +git-tree-sha1 = "215a9aa4a1f23fbd05b92769fdd62559488d70e9" +uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82" +version = "0.4.1" + +[[Clang]] +deps = ["CEnum", "Clang_jll", "Downloads", "Pkg", "TOML"] +git-tree-sha1 = "c440d15d2afba36364de65ec2870d9eda94ab0c5" +repo-rev = "master" +repo-url = "https://github.com/JuliaInterop/Clang.jl.git" +uuid = "40e3b903-d033-50b4-a0cc-940c62c95e31" +version = "0.14.0" + +[[Clang_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "libLLVM_jll"] +git-tree-sha1 = "a5923c06de3178dd755f4b9411ea8922a7ae6fb8" +uuid = "0ee61d77-7f21-5576-8119-9fcc46b10100" +version = "11.0.1+3" + +[[Dates]] +deps = ["Printf"] +uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" + +[[Downloads]] +deps = ["ArgTools", "LibCURL", "NetworkOptions"] +uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" + +[[InteractiveUtils]] +deps = ["Markdown"] +uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" + +[[JLLWrappers]] +deps = ["Preferences"] +git-tree-sha1 = "642a199af8b68253517b80bd3bfd17eb4e84df6e" +uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" +version = "1.3.0" + +[[LibCURL]] +deps = ["LibCURL_jll", "MozillaCACerts_jll"] +uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" + +[[LibCURL_jll]] +deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] +uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" + +[[LibGit2]] +deps = ["Base64", "NetworkOptions", "Printf", "SHA"] +uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" + +[[LibSSH2_jll]] +deps = ["Artifacts", "Libdl", "MbedTLS_jll"] +uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" + +[[Libdl]] +uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" + +[[Libgcrypt_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Libgpg_error_jll", "Pkg"] +git-tree-sha1 = "b391a18ab1170a2e568f9fb8d83bc7c780cb9999" +uuid = "d4300ac3-e22c-5743-9152-c294e39db1e4" +version = "1.8.5+4" + +[[Libgpg_error_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "ec7f2e8ad5c9fa99fc773376cdbc86d9a5a23cb7" +uuid = "7add5ba3-2f88-524e-9cd5-f83b8a55f7b8" +version = "1.36.0+3" + +[[Libiconv_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "8e924324b2e9275a51407a4e06deb3455b1e359f" +uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531" +version = "1.16.0+7" + +[[Logging]] +uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" + +[[Markdown]] +deps = ["Base64"] +uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" + +[[MbedTLS_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" + +[[MiniFB_jll]] +deps = ["Libdl", "Pkg", "Xorg_libX11_jll"] +git-tree-sha1 = "5f4d80ac70393d7a77a82ba916ef08fed271e44a" +uuid = "b93afbca-07d8-5443-9979-bb4221978155" +version = "0.1.1+1" + +[[MozillaCACerts_jll]] +uuid = "14a3606d-f60d-562e-9121-12d972cd8159" + +[[NetworkOptions]] +uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" + +[[Pkg]] +deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] +uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" + +[[Preferences]] +deps = ["TOML"] +git-tree-sha1 = "00cfd92944ca9c760982747e9a1d0d5d86ab1e5a" +uuid = "21216c6a-2e73-6563-6e65-726566657250" +version = "1.2.2" + +[[Printf]] +deps = ["Unicode"] +uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" + +[[REPL]] +deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] +uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" + +[[Random]] +deps = ["Serialization"] +uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" + +[[SHA]] +uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" + +[[Serialization]] +uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" + +[[Sockets]] +uuid = "6462fe0b-24de-5631-8697-dd941f90decc" + +[[TOML]] +deps = ["Dates"] +uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" + +[[Tar]] +deps = ["ArgTools", "SHA"] +uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" + +[[UUIDs]] +deps = ["Random", "SHA"] +uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" + +[[Unicode]] +uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" + +[[XML2_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "Zlib_jll"] +git-tree-sha1 = "afd2b541e8fd425cd3b7aa55932a257035ab4a70" +uuid = "02c8fc9c-b97f-50b9-bbe4-9be30ff0a78a" +version = "2.9.11+0" + +[[XSLT_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Libgcrypt_jll", "Pkg", "XML2_jll"] +git-tree-sha1 = "2b3eac39df218762d2d005702d601cd44c997497" +uuid = "aed1982a-8fda-507f-9586-7b0439959a61" +version = "1.1.33+4" + +[[Xorg_libX11_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Xorg_libxcb_jll", "Xorg_xtrans_jll"] +git-tree-sha1 = "5be649d550f3f4b95308bf0183b82e2582876527" +uuid = "4f6342f7-b3d2-589e-9d20-edeb45f2b2bc" +version = "1.6.9+4" + +[[Xorg_libXau_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "4e490d5c960c314f33885790ed410ff3a94ce67e" +uuid = "0c0b7dd1-d40b-584c-a123-a41640f87eec" +version = "1.0.9+4" + +[[Xorg_libXdmcp_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "4fe47bd2247248125c428978740e18a681372dd4" +uuid = "a3789734-cfe1-5b06-b2d0-1dd0d9d62d05" +version = "1.1.3+4" + +[[Xorg_libpthread_stubs_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "6783737e45d3c59a4a4c4091f5f88cdcf0908cbb" +uuid = "14d82f49-176c-5ed1-bb49-ad3f5cbd8c74" +version = "0.1.0+3" + +[[Xorg_libxcb_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "XSLT_jll", "Xorg_libXau_jll", "Xorg_libXdmcp_jll", "Xorg_libpthread_stubs_jll"] +git-tree-sha1 = "daf17f441228e7a3833846cd048892861cff16d6" +uuid = "c7cfdc94-dc32-55de-ac96-5a1b8d977c5b" +version = "1.13.0+3" + +[[Xorg_xtrans_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "79c31e7844f6ecf779705fbc12146eb190b7d845" +uuid = "c5fb5394-a638-5e4d-96e5-b29de1b5cf10" +version = "1.4.0+3" + +[[Zlib_jll]] +deps = ["Libdl"] +uuid = "83775a58-1f1d-513f-b197-d71354ab007a" + +[[libLLVM_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "8f36deef-c2a5-5394-99ed-8e07531fb29a" + +[[nghttp2_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" + +[[p7zip_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" diff --git a/gen/Project.toml b/gen/Project.toml new file mode 100644 index 0000000..d010fcb --- /dev/null +++ b/gen/Project.toml @@ -0,0 +1,7 @@ +[deps] +Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31" +Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6" +MiniFB_jll = "b93afbca-07d8-5443-9979-bb4221978155" + +[compat] +Clang = "0.14" diff --git a/gen/generator.jl b/gen/generator.jl new file mode 100644 index 0000000..cabdf48 --- /dev/null +++ b/gen/generator.jl @@ -0,0 +1,29 @@ +using Clang.Generators +# using Clang.JLLEnvs +using MiniFB_jll +using Downloads + +cd(@__DIR__) + +# download header files +git_sha = "dda1275bd741752d1b7cdc1ee4d9941887a1891a" +header_files = [ + "MiniFB.h", + "MiniFB_enums.h", + "MiniFB_cpp.h", + "MiniFB_ios.h", +] +for f in header_files + Downloads.download("https://raw.githubusercontent.com/emoon/minifb/$git_sha/include/$f", "$f") +end + +options = load_options(joinpath(@__DIR__, "generator.toml")) + +args = get_default_args() +push!(args, "-I$(@__DIR__)") + +headers = detect_headers(@__DIR__, args) + +ctx = create_context(headers, args, options) + +build!(ctx) diff --git a/gen/generator.toml b/gen/generator.toml new file mode 100644 index 0000000..2f3cf1a --- /dev/null +++ b/gen/generator.toml @@ -0,0 +1,9 @@ +[general] +library_name = "libminifb" +output_file_path = "../src/LibMiniFB.jl" +module_name = "LibMiniFB" +jll_pkg_name = "MiniFB_jll" +export_symbol_prefixes = ["mfb_", "WF_", "STATE_", "MOUSE_", "KB_"] +use_deterministic_symbol = true +use_julia_native_enum_type = true +printer_blacklist = [] \ No newline at end of file diff --git a/src/LibMiniFB.jl b/src/LibMiniFB.jl new file mode 100644 index 0000000..0ba2453 --- /dev/null +++ b/src/LibMiniFB.jl @@ -0,0 +1,351 @@ +module LibMiniFB + +using MiniFB_jll +export MiniFB_jll + +@enum mfb_update_state::Int32 begin + STATE_OK = 0 + STATE_EXIT = -1 + STATE_INVALID_WINDOW = -2 + STATE_INVALID_BUFFER = -3 + STATE_INTERNAL_ERROR = -4 +end + +@enum mfb_mouse_button::UInt32 begin + MOUSE_BTN_0 = 0 + MOUSE_BTN_1 = 1 + MOUSE_BTN_2 = 2 + MOUSE_BTN_3 = 3 + MOUSE_BTN_4 = 4 + MOUSE_BTN_5 = 5 + MOUSE_BTN_6 = 6 + MOUSE_BTN_7 = 7 +end + +@enum mfb_key::Int32 begin + KB_KEY_UNKNOWN = -1 + KB_KEY_SPACE = 32 + KB_KEY_APOSTROPHE = 39 + KB_KEY_COMMA = 44 + KB_KEY_MINUS = 45 + KB_KEY_PERIOD = 46 + KB_KEY_SLASH = 47 + KB_KEY_0 = 48 + KB_KEY_1 = 49 + KB_KEY_2 = 50 + KB_KEY_3 = 51 + KB_KEY_4 = 52 + KB_KEY_5 = 53 + KB_KEY_6 = 54 + KB_KEY_7 = 55 + KB_KEY_8 = 56 + KB_KEY_9 = 57 + KB_KEY_SEMICOLON = 59 + KB_KEY_EQUAL = 61 + KB_KEY_A = 65 + KB_KEY_B = 66 + KB_KEY_C = 67 + KB_KEY_D = 68 + KB_KEY_E = 69 + KB_KEY_F = 70 + KB_KEY_G = 71 + KB_KEY_H = 72 + KB_KEY_I = 73 + KB_KEY_J = 74 + KB_KEY_K = 75 + KB_KEY_L = 76 + KB_KEY_M = 77 + KB_KEY_N = 78 + KB_KEY_O = 79 + KB_KEY_P = 80 + KB_KEY_Q = 81 + KB_KEY_R = 82 + KB_KEY_S = 83 + KB_KEY_T = 84 + KB_KEY_U = 85 + KB_KEY_V = 86 + KB_KEY_W = 87 + KB_KEY_X = 88 + KB_KEY_Y = 89 + KB_KEY_Z = 90 + KB_KEY_LEFT_BRACKET = 91 + KB_KEY_BACKSLASH = 92 + KB_KEY_RIGHT_BRACKET = 93 + KB_KEY_GRAVE_ACCENT = 96 + KB_KEY_WORLD_1 = 161 + KB_KEY_WORLD_2 = 162 + KB_KEY_ESCAPE = 256 + KB_KEY_ENTER = 257 + KB_KEY_TAB = 258 + KB_KEY_BACKSPACE = 259 + KB_KEY_INSERT = 260 + KB_KEY_DELETE = 261 + KB_KEY_RIGHT = 262 + KB_KEY_LEFT = 263 + KB_KEY_DOWN = 264 + KB_KEY_UP = 265 + KB_KEY_PAGE_UP = 266 + KB_KEY_PAGE_DOWN = 267 + KB_KEY_HOME = 268 + KB_KEY_END = 269 + KB_KEY_CAPS_LOCK = 280 + KB_KEY_SCROLL_LOCK = 281 + KB_KEY_NUM_LOCK = 282 + KB_KEY_PRINT_SCREEN = 283 + KB_KEY_PAUSE = 284 + KB_KEY_F1 = 290 + KB_KEY_F2 = 291 + KB_KEY_F3 = 292 + KB_KEY_F4 = 293 + KB_KEY_F5 = 294 + KB_KEY_F6 = 295 + KB_KEY_F7 = 296 + KB_KEY_F8 = 297 + KB_KEY_F9 = 298 + KB_KEY_F10 = 299 + KB_KEY_F11 = 300 + KB_KEY_F12 = 301 + KB_KEY_F13 = 302 + KB_KEY_F14 = 303 + KB_KEY_F15 = 304 + KB_KEY_F16 = 305 + KB_KEY_F17 = 306 + KB_KEY_F18 = 307 + KB_KEY_F19 = 308 + KB_KEY_F20 = 309 + KB_KEY_F21 = 310 + KB_KEY_F22 = 311 + KB_KEY_F23 = 312 + KB_KEY_F24 = 313 + KB_KEY_F25 = 314 + KB_KEY_KP_0 = 320 + KB_KEY_KP_1 = 321 + KB_KEY_KP_2 = 322 + KB_KEY_KP_3 = 323 + KB_KEY_KP_4 = 324 + KB_KEY_KP_5 = 325 + KB_KEY_KP_6 = 326 + KB_KEY_KP_7 = 327 + KB_KEY_KP_8 = 328 + KB_KEY_KP_9 = 329 + KB_KEY_KP_DECIMAL = 330 + KB_KEY_KP_DIVIDE = 331 + KB_KEY_KP_MULTIPLY = 332 + KB_KEY_KP_SUBTRACT = 333 + KB_KEY_KP_ADD = 334 + KB_KEY_KP_ENTER = 335 + KB_KEY_KP_EQUAL = 336 + KB_KEY_LEFT_SHIFT = 340 + KB_KEY_LEFT_CONTROL = 341 + KB_KEY_LEFT_ALT = 342 + KB_KEY_LEFT_SUPER = 343 + KB_KEY_RIGHT_SHIFT = 344 + KB_KEY_RIGHT_CONTROL = 345 + KB_KEY_RIGHT_ALT = 346 + KB_KEY_RIGHT_SUPER = 347 + KB_KEY_MENU = 348 +end + +@enum mfb_key_mod::UInt32 begin + KB_MOD_SHIFT = 1 + KB_MOD_CONTROL = 2 + KB_MOD_ALT = 4 + KB_MOD_SUPER = 8 + KB_MOD_CAPS_LOCK = 16 + KB_MOD_NUM_LOCK = 32 +end + +@enum mfb_window_flags::UInt32 begin + WF_RESIZABLE = 1 + WF_FULLSCREEN = 2 + WF_FULLSCREEN_DESKTOP = 4 + WF_BORDERLESS = 8 + WF_ALWAYS_ON_TOP = 16 +end + +mutable struct mfb_window end + +mutable struct mfb_timer end + +# typedef void ( * mfb_active_func ) ( struct mfb_window * window , bool isActive ) +const mfb_active_func = Ptr{Cvoid} + +# typedef void ( * mfb_resize_func ) ( struct mfb_window * window , int width , int height ) +const mfb_resize_func = Ptr{Cvoid} + +# typedef void ( * mfb_keyboard_func ) ( struct mfb_window * window , mfb_key key , mfb_key_mod mod , bool isPressed ) +const mfb_keyboard_func = Ptr{Cvoid} + +# typedef void ( * mfb_char_input_func ) ( struct mfb_window * window , unsigned int code ) +const mfb_char_input_func = Ptr{Cvoid} + +# typedef void ( * mfb_mouse_button_func ) ( struct mfb_window * window , mfb_mouse_button button , mfb_key_mod mod , bool isPressed ) +const mfb_mouse_button_func = Ptr{Cvoid} + +# typedef void ( * mfb_mouse_move_func ) ( struct mfb_window * window , int x , int y ) +const mfb_mouse_move_func = Ptr{Cvoid} + +# typedef void ( * mfb_mouse_scroll_func ) ( struct mfb_window * window , mfb_key_mod mod , float deltaX , float deltaY ) +const mfb_mouse_scroll_func = Ptr{Cvoid} + +function mfb_open(title, width, height) + ccall((:mfb_open, libminifb), Ptr{mfb_window}, (Ptr{Cchar}, Cuint, Cuint), title, width, height) +end + +function mfb_open_ex(title, width, height, flags) + ccall((:mfb_open_ex, libminifb), Ptr{mfb_window}, (Ptr{Cchar}, Cuint, Cuint, Cuint), title, width, height, flags) +end + +function mfb_update(window, buffer) + ccall((:mfb_update, libminifb), mfb_update_state, (Ptr{mfb_window}, Ptr{Cvoid}), window, buffer) +end + +function mfb_update_events(window) + ccall((:mfb_update_events, libminifb), mfb_update_state, (Ptr{mfb_window},), window) +end + +function mfb_close(window) + ccall((:mfb_close, libminifb), Cvoid, (Ptr{mfb_window},), window) +end + +function mfb_set_user_data(window, user_data) + ccall((:mfb_set_user_data, libminifb), Cvoid, (Ptr{mfb_window}, Ptr{Cvoid}), window, user_data) +end + +function mfb_get_user_data(window) + ccall((:mfb_get_user_data, libminifb), Ptr{Cvoid}, (Ptr{mfb_window},), window) +end + +function mfb_set_viewport(window, offset_x, offset_y, width, height) + ccall((:mfb_set_viewport, libminifb), Bool, (Ptr{mfb_window}, Cuint, Cuint, Cuint, Cuint), window, offset_x, offset_y, width, height) +end + +function mfb_set_active_callback(window, callback) + ccall((:mfb_set_active_callback, libminifb), Cvoid, (Ptr{mfb_window}, mfb_active_func), window, callback) +end + +function mfb_set_resize_callback(window, callback) + ccall((:mfb_set_resize_callback, libminifb), Cvoid, (Ptr{mfb_window}, mfb_resize_func), window, callback) +end + +function mfb_set_keyboard_callback(window, callback) + ccall((:mfb_set_keyboard_callback, libminifb), Cvoid, (Ptr{mfb_window}, mfb_keyboard_func), window, callback) +end + +function mfb_set_char_input_callback(window, callback) + ccall((:mfb_set_char_input_callback, libminifb), Cvoid, (Ptr{mfb_window}, mfb_char_input_func), window, callback) +end + +function mfb_set_mouse_button_callback(window, callback) + ccall((:mfb_set_mouse_button_callback, libminifb), Cvoid, (Ptr{mfb_window}, mfb_mouse_button_func), window, callback) +end + +function mfb_set_mouse_move_callback(window, callback) + ccall((:mfb_set_mouse_move_callback, libminifb), Cvoid, (Ptr{mfb_window}, mfb_mouse_move_func), window, callback) +end + +function mfb_set_mouse_scroll_callback(window, callback) + ccall((:mfb_set_mouse_scroll_callback, libminifb), Cvoid, (Ptr{mfb_window}, mfb_mouse_scroll_func), window, callback) +end + +function mfb_get_key_name(key) + ccall((:mfb_get_key_name, libminifb), Ptr{Cchar}, (mfb_key,), key) +end + +function mfb_is_window_active(window) + ccall((:mfb_is_window_active, libminifb), Bool, (Ptr{mfb_window},), window) +end + +function mfb_get_window_width(window) + ccall((:mfb_get_window_width, libminifb), Cuint, (Ptr{mfb_window},), window) +end + +function mfb_get_window_height(window) + ccall((:mfb_get_window_height, libminifb), Cuint, (Ptr{mfb_window},), window) +end + +function mfb_get_mouse_x(window) + ccall((:mfb_get_mouse_x, libminifb), Cint, (Ptr{mfb_window},), window) +end + +function mfb_get_mouse_y(window) + ccall((:mfb_get_mouse_y, libminifb), Cint, (Ptr{mfb_window},), window) +end + +function mfb_get_mouse_scroll_x(window) + ccall((:mfb_get_mouse_scroll_x, libminifb), Cfloat, (Ptr{mfb_window},), window) +end + +function mfb_get_mouse_scroll_y(window) + ccall((:mfb_get_mouse_scroll_y, libminifb), Cfloat, (Ptr{mfb_window},), window) +end + +function mfb_get_mouse_button_buffer(window) + ccall((:mfb_get_mouse_button_buffer, libminifb), Ptr{UInt8}, (Ptr{mfb_window},), window) +end + +function mfb_get_key_buffer(window) + ccall((:mfb_get_key_buffer, libminifb), Ptr{UInt8}, (Ptr{mfb_window},), window) +end + +function mfb_set_target_fps(fps) + ccall((:mfb_set_target_fps, libminifb), Cvoid, (UInt32,), fps) +end + +function mfb_wait_sync(window) + ccall((:mfb_wait_sync, libminifb), Bool, (Ptr{mfb_window},), window) +end + +function mfb_timer_create() + ccall((:mfb_timer_create, libminifb), Ptr{mfb_timer}, ()) +end + +function mfb_timer_destroy(tmr) + ccall((:mfb_timer_destroy, libminifb), Cvoid, (Ptr{mfb_timer},), tmr) +end + +function mfb_timer_reset(tmr) + ccall((:mfb_timer_reset, libminifb), Cvoid, (Ptr{mfb_timer},), tmr) +end + +function mfb_timer_now(tmr) + ccall((:mfb_timer_now, libminifb), Cdouble, (Ptr{mfb_timer},), tmr) +end + +function mfb_timer_delta(tmr) + ccall((:mfb_timer_delta, libminifb), Cdouble, (Ptr{mfb_timer},), tmr) +end + +function mfb_timer_get_frequency() + ccall((:mfb_timer_get_frequency, libminifb), Cdouble, ()) +end + +function mfb_timer_get_resolution() + ccall((:mfb_timer_get_resolution, libminifb), Cdouble, ()) +end + +function user_implemented_init(window) + ccall((:user_implemented_init, libminifb), Cvoid, (Ptr{mfb_window},), window) +end + +function user_implemented_update(window) + ccall((:user_implemented_update, libminifb), Cvoid, (Ptr{mfb_window},), window) +end + +const MOUSE_LEFT = MOUSE_BTN_1 + +const MOUSE_RIGHT = MOUSE_BTN_2 + +const MOUSE_MIDDLE = MOUSE_BTN_3 + +const KB_KEY_LAST = KB_KEY_MENU + +# exports +const PREFIXES = ["mfb_", "WF_", "STATE_", "MOUSE_", "KB_"] +for name in names(@__MODULE__; all=true), prefix in PREFIXES + if startswith(string(name), prefix) + @eval export $name + end +end + +end # module diff --git a/src/MiniFB.jl b/src/MiniFB.jl index 13f6512..2c424b5 100644 --- a/src/MiniFB.jl +++ b/src/MiniFB.jl @@ -2,14 +2,12 @@ module MiniFB using Colors using MiniFB_jll -using CEnum +include("LibMiniFB.jl") +using .LibMiniFB -include("ctypes.jl") -export Ctm, Ctime_t, Cclock_t - -include("libminifb_common.jl") -include("libminifb_api.jl") include("libminifb_docs.jl") include("helpers.jl") +export mfb_rgb + end diff --git a/src/ctypes.jl b/src/ctypes.jl deleted file mode 100644 index 436e6ad..0000000 --- a/src/ctypes.jl +++ /dev/null @@ -1,7 +0,0 @@ -## TODO: pending https://github.com/JuliaLang/julia/issues/29420 -# this one is suggested in the issue, but it looks like time_t and tm are two different things? -# const Ctime_t = Base.Libc.TmStruct - -const Ctm = Base.Libc.TmStruct -const Ctime_t = UInt -const Cclock_t = UInt diff --git a/src/helpers.jl b/src/helpers.jl index d020bb2..01a958e 100644 --- a/src/helpers.jl +++ b/src/helpers.jl @@ -1,12 +1,12 @@ -function mfb_rgb(r::UInt8, g::UInt8, b::UInt8)::UInt32 +function mfb_rgb(r::UInt8, g::UInt8, b::UInt8)::UInt32 reinterpret(UInt32, [b, g, r, zero(UInt8)])[1] end """ mfb_rgb(r, g, b)::UInt32 -convert 8 bit color channels to a single 32 bit buffer. -Input should be of some integer type in the range 0-255. +convert 8 bit color channels to a single 32 bit buffer. +Input should be of some integer type in the range 0-255. `InexactError` will be thrown if the inputs are fractional, or larger than 255. """ mfb_rgb(r, g, b) = mfb_rgb(UInt8(r), UInt8(g), UInt8(b)) @@ -21,43 +21,37 @@ function mfb_rgb(c::Colorant)::UInt32 return reinterpret(UInt32, cRGB24) end -foreach(names(@__MODULE__, all=true)) do s - if startswith(string(s), "mfb_") - @eval export $s - end -end - -function mfb_set_active_callback(window, active::Function) +function LibMiniFB.mfb_set_active_callback(window, active::Function) active_c = @cfunction($active, Cvoid, (Ptr{Cvoid}, Bool)) mfb_set_active_callback(window, active_c) end -function mfb_set_resize_callback(window, resize::Function) +function LibMiniFB.mfb_set_resize_callback(window, resize::Function) resize_c = @cfunction($resize, Cvoid, (Ptr{Cvoid}, Cint, Cint)) mfb_set_resize_callback(window, resize_c) end -function mfb_set_keyboard_callback(window, keyboard::Function) +function LibMiniFB.mfb_set_keyboard_callback(window, keyboard::Function) keyboard_c = @cfunction($keyboard, Cvoid, (Ptr{Cvoid}, mfb_key, mfb_key_mod, Bool)) mfb_set_keyboard_callback(window, keyboard_c) end -function mfb_set_char_input_callback(window, char_input::Function) +function LibMiniFB.mfb_set_char_input_callback(window, char_input::Function) char_input_c = @cfunction($char_input, Cvoid, (Ptr{Cvoid}, Cuint, Cuint)) mfb_set_char_input_callback(window, char_input_c) end -function mfb_set_mouse_button_callback(window, mouse_btn::Function) +function LibMiniFB.mfb_set_mouse_button_callback(window, mouse_btn::Function) mouse_btn_c = @cfunction($mouse_btn, Cvoid, (Ptr{Cvoid}, mfb_mouse_button, mfb_key_mod, Bool)) mfb_set_mouse_button_callback(window, mouse_btn_c) end -function mfb_set_mouse_move_callback(window, mouse_move::Function) +function LibMiniFB.mfb_set_mouse_move_callback(window, mouse_move::Function) mouse_move_c = @cfunction($mouse_move, Cvoid, (Ptr{Cvoid}, Cint, Cint)) mfb_set_mouse_move_callback(window, mouse_move_c) end -function mfb_set_mouse_scroll_callback(window, mouse_scroll::Function) +function LibMiniFB.mfb_set_mouse_scroll_callback(window, mouse_scroll::Function) mouse_scroll_c = @cfunction($mouse_scroll, Cvoid, (Ptr{Cvoid}, mfb_key_mod, Cfloat, Cfloat)) mfb_set_mouse_scroll_callback(window, mouse_scroll_c) end diff --git a/src/libminifb_api.jl b/src/libminifb_api.jl deleted file mode 100644 index ccf6da1..0000000 --- a/src/libminifb_api.jl +++ /dev/null @@ -1,142 +0,0 @@ -# Julia wrapper for header: MiniFB_enums.h -# Automatically generated using Clang.jl - -# Julia wrapper for header: MiniFB.h -# Automatically generated using Clang.jl - - -function mfb_open(title, width, height) - ccall((:mfb_open, libminifb), Ptr{mfb_window}, (Cstring, UInt32, UInt32), title, width, height) -end - -function mfb_open_ex(title, width, height, flags) - ccall((:mfb_open_ex, libminifb), Ptr{mfb_window}, (Cstring, UInt32, UInt32, UInt32), title, width, height, flags) -end - -function mfb_update(window, buffer) - ccall((:mfb_update, libminifb), mfb_update_state, (Ptr{mfb_window}, Ptr{Cvoid}), window, buffer) -end - -function mfb_update_events(window) - ccall((:mfb_update_events, libminifb), mfb_update_state, (Ptr{mfb_window},), window) -end - -function mfb_close(window) - ccall((:mfb_close, libminifb), Cvoid, (Ptr{mfb_window},), window) -end - -function mfb_set_user_data(window, user_data) - ccall((:mfb_set_user_data, libminifb), Cvoid, (Ptr{mfb_window}, Ptr{Cvoid}), window, user_data) -end - -function mfb_get_user_data(window) - ccall((:mfb_get_user_data, libminifb), Ptr{Cvoid}, (Ptr{mfb_window},), window) -end - -function mfb_set_viewport(window, offset_x, offset_y, width, height) - ccall((:mfb_set_viewport, libminifb), Bool, (Ptr{mfb_window}, UInt32, UInt32, UInt32, UInt32), window, offset_x, offset_y, width, height) -end - -function mfb_set_active_callback(window, callback) - ccall((:mfb_set_active_callback, libminifb), Cvoid, (Ptr{mfb_window}, mfb_active_func), window, callback) -end - -function mfb_set_resize_callback(window, callback) - ccall((:mfb_set_resize_callback, libminifb), Cvoid, (Ptr{mfb_window}, mfb_resize_func), window, callback) -end - -function mfb_set_keyboard_callback(window, callback) - ccall((:mfb_set_keyboard_callback, libminifb), Cvoid, (Ptr{mfb_window}, mfb_keyboard_func), window, callback) -end - -function mfb_set_char_input_callback(window, callback) - ccall((:mfb_set_char_input_callback, libminifb), Cvoid, (Ptr{mfb_window}, mfb_char_input_func), window, callback) -end - -function mfb_set_mouse_button_callback(window, callback) - ccall((:mfb_set_mouse_button_callback, libminifb), Cvoid, (Ptr{mfb_window}, mfb_mouse_button_func), window, callback) -end - -function mfb_set_mouse_move_callback(window, callback) - ccall((:mfb_set_mouse_move_callback, libminifb), Cvoid, (Ptr{mfb_window}, mfb_mouse_move_func), window, callback) -end - -function mfb_set_mouse_scroll_callback(window, callback) - ccall((:mfb_set_mouse_scroll_callback, libminifb), Cvoid, (Ptr{mfb_window}, mfb_mouse_scroll_func), window, callback) -end - -function mfb_get_key_name(key) - ccall((:mfb_get_key_name, libminifb), Cstring, (mfb_key,), key) -end - -function mfb_is_window_active(window) - ccall((:mfb_is_window_active, libminifb), Bool, (Ptr{mfb_window},), window) -end - -function mfb_get_window_width(window) - ccall((:mfb_get_window_width, libminifb), UInt32, (Ptr{mfb_window},), window) -end - -function mfb_get_window_height(window) - ccall((:mfb_get_window_height, libminifb), UInt32, (Ptr{mfb_window},), window) -end - -function mfb_get_mouse_x(window) - ccall((:mfb_get_mouse_x, libminifb), Cint, (Ptr{mfb_window},), window) -end - -function mfb_get_mouse_y(window) - ccall((:mfb_get_mouse_y, libminifb), Cint, (Ptr{mfb_window},), window) -end - -function mfb_get_mouse_scroll_x(window) - ccall((:mfb_get_mouse_scroll_x, libminifb), Cfloat, (Ptr{mfb_window},), window) -end - -function mfb_get_mouse_scroll_y(window) - ccall((:mfb_get_mouse_scroll_y, libminifb), Cfloat, (Ptr{mfb_window},), window) -end - -function mfb_get_mouse_button_buffer(window) - ccall((:mfb_get_mouse_button_buffer, libminifb), Ptr{UInt8}, (Ptr{mfb_window},), window) -end - -function mfb_get_key_buffer(window) - ccall((:mfb_get_key_buffer, libminifb), Ptr{UInt8}, (Ptr{mfb_window},), window) -end - -function mfb_set_target_fps(fps) - ccall((:mfb_set_target_fps, libminifb), Cvoid, (UInt32,), fps) -end - -function mfb_wait_sync(window) - ccall((:mfb_wait_sync, libminifb), Bool, (Ptr{mfb_window},), window) -end - -function mfb_timer_create() - ccall((:mfb_timer_create, libminifb), Ptr{mfb_timer}, ()) -end - -function mfb_timer_destroy(tmr) - ccall((:mfb_timer_destroy, libminifb), Cvoid, (Ptr{mfb_timer},), tmr) -end - -function mfb_timer_reset(tmr) - ccall((:mfb_timer_reset, libminifb), Cvoid, (Ptr{mfb_timer},), tmr) -end - -function mfb_timer_now(tmr) - ccall((:mfb_timer_now, libminifb), Cdouble, (Ptr{mfb_timer},), tmr) -end - -function mfb_timer_delta(tmr) - ccall((:mfb_timer_delta, libminifb), Cdouble, (Ptr{mfb_timer},), tmr) -end - -function mfb_timer_get_frequency() - ccall((:mfb_timer_get_frequency, libminifb), Cdouble, ()) -end - -function mfb_timer_get_resolution() - ccall((:mfb_timer_get_resolution, libminifb), Cdouble, ()) -end diff --git a/src/libminifb_common.jl b/src/libminifb_common.jl deleted file mode 100644 index 851ae7b..0000000 --- a/src/libminifb_common.jl +++ /dev/null @@ -1,183 +0,0 @@ -# Automatically generated using Clang.jl - - -@cenum mfb_mouse_button::UInt32 begin - MOUSE_BTN_0 = 0 - MOUSE_BTN_1 = 1 - MOUSE_BTN_2 = 2 - MOUSE_BTN_3 = 3 - MOUSE_BTN_4 = 4 - MOUSE_BTN_5 = 5 - MOUSE_BTN_6 = 6 - MOUSE_BTN_7 = 7 -end - - -const MOUSE_LEFT = MOUSE_BTN_1 -const MOUSE_RIGHT = MOUSE_BTN_2 -const MOUSE_MIDDLE = MOUSE_BTN_3 - -@cenum mfb_key::Int32 begin - KB_KEY_UNKNOWN = -1 - KB_KEY_SPACE = 32 - KB_KEY_APOSTROPHE = 39 - KB_KEY_COMMA = 44 - KB_KEY_MINUS = 45 - KB_KEY_PERIOD = 46 - KB_KEY_SLASH = 47 - KB_KEY_0 = 48 - KB_KEY_1 = 49 - KB_KEY_2 = 50 - KB_KEY_3 = 51 - KB_KEY_4 = 52 - KB_KEY_5 = 53 - KB_KEY_6 = 54 - KB_KEY_7 = 55 - KB_KEY_8 = 56 - KB_KEY_9 = 57 - KB_KEY_SEMICOLON = 59 - KB_KEY_EQUAL = 61 - KB_KEY_A = 65 - KB_KEY_B = 66 - KB_KEY_C = 67 - KB_KEY_D = 68 - KB_KEY_E = 69 - KB_KEY_F = 70 - KB_KEY_G = 71 - KB_KEY_H = 72 - KB_KEY_I = 73 - KB_KEY_J = 74 - KB_KEY_K = 75 - KB_KEY_L = 76 - KB_KEY_M = 77 - KB_KEY_N = 78 - KB_KEY_O = 79 - KB_KEY_P = 80 - KB_KEY_Q = 81 - KB_KEY_R = 82 - KB_KEY_S = 83 - KB_KEY_T = 84 - KB_KEY_U = 85 - KB_KEY_V = 86 - KB_KEY_W = 87 - KB_KEY_X = 88 - KB_KEY_Y = 89 - KB_KEY_Z = 90 - KB_KEY_LEFT_BRACKET = 91 - KB_KEY_BACKSLASH = 92 - KB_KEY_RIGHT_BRACKET = 93 - KB_KEY_GRAVE_ACCENT = 96 - KB_KEY_WORLD_1 = 161 - KB_KEY_WORLD_2 = 162 - KB_KEY_ESCAPE = 256 - KB_KEY_ENTER = 257 - KB_KEY_TAB = 258 - KB_KEY_BACKSPACE = 259 - KB_KEY_INSERT = 260 - KB_KEY_DELETE = 261 - KB_KEY_RIGHT = 262 - KB_KEY_LEFT = 263 - KB_KEY_DOWN = 264 - KB_KEY_UP = 265 - KB_KEY_PAGE_UP = 266 - KB_KEY_PAGE_DOWN = 267 - KB_KEY_HOME = 268 - KB_KEY_END = 269 - KB_KEY_CAPS_LOCK = 280 - KB_KEY_SCROLL_LOCK = 281 - KB_KEY_NUM_LOCK = 282 - KB_KEY_PRINT_SCREEN = 283 - KB_KEY_PAUSE = 284 - KB_KEY_F1 = 290 - KB_KEY_F2 = 291 - KB_KEY_F3 = 292 - KB_KEY_F4 = 293 - KB_KEY_F5 = 294 - KB_KEY_F6 = 295 - KB_KEY_F7 = 296 - KB_KEY_F8 = 297 - KB_KEY_F9 = 298 - KB_KEY_F10 = 299 - KB_KEY_F11 = 300 - KB_KEY_F12 = 301 - KB_KEY_F13 = 302 - KB_KEY_F14 = 303 - KB_KEY_F15 = 304 - KB_KEY_F16 = 305 - KB_KEY_F17 = 306 - KB_KEY_F18 = 307 - KB_KEY_F19 = 308 - KB_KEY_F20 = 309 - KB_KEY_F21 = 310 - KB_KEY_F22 = 311 - KB_KEY_F23 = 312 - KB_KEY_F24 = 313 - KB_KEY_F25 = 314 - KB_KEY_KP_0 = 320 - KB_KEY_KP_1 = 321 - KB_KEY_KP_2 = 322 - KB_KEY_KP_3 = 323 - KB_KEY_KP_4 = 324 - KB_KEY_KP_5 = 325 - KB_KEY_KP_6 = 326 - KB_KEY_KP_7 = 327 - KB_KEY_KP_8 = 328 - KB_KEY_KP_9 = 329 - KB_KEY_KP_DECIMAL = 330 - KB_KEY_KP_DIVIDE = 331 - KB_KEY_KP_MULTIPLY = 332 - KB_KEY_KP_SUBTRACT = 333 - KB_KEY_KP_ADD = 334 - KB_KEY_KP_ENTER = 335 - KB_KEY_KP_EQUAL = 336 - KB_KEY_LEFT_SHIFT = 340 - KB_KEY_LEFT_CONTROL = 341 - KB_KEY_LEFT_ALT = 342 - KB_KEY_LEFT_SUPER = 343 - KB_KEY_RIGHT_SHIFT = 344 - KB_KEY_RIGHT_CONTROL = 345 - KB_KEY_RIGHT_ALT = 346 - KB_KEY_RIGHT_SUPER = 347 - KB_KEY_MENU = 348 -end - - -const KB_KEY_LAST = KB_KEY_MENU - -@cenum mfb_update_state::Int32 begin - STATE_OK = 0 - STATE_EXIT = -1 - STATE_INVALID_WINDOW = -2 - STATE_INVALID_BUFFER = -3 - STATE_INTERNAL_ERROR = -4 -end - -@cenum mfb_key_mod::UInt32 begin - KB_MOD_SHIFT = 1 - KB_MOD_CONTROL = 2 - KB_MOD_ALT = 4 - KB_MOD_SUPER = 8 - KB_MOD_CAPS_LOCK = 16 - KB_MOD_NUM_LOCK = 32 -end - -@cenum mfb_window_flags::UInt32 begin - WF_RESIZABLE = 1 - WF_FULLSCREEN = 2 - WF_FULLSCREEN_DESKTOP = 4 - WF_BORDERLESS = 8 - WF_ALWAYS_ON_TOP = 16 -end - - -const mfb_window = Cvoid -const mfb_timer = Cvoid -const mfb_active_func = Ptr{Cvoid} -const mfb_resize_func = Ptr{Cvoid} -const mfb_keyboard_func = Ptr{Cvoid} -const mfb_char_input_func = Ptr{Cvoid} -const mfb_mouse_button_func = Ptr{Cvoid} -const mfb_mouse_move_func = Ptr{Cvoid} -const mfb_mouse_scroll_func = Ptr{Cvoid} - -# Skipping MacroDefinition: MFB_RGB ( r , g , b ) ( ( ( uint32_t ) r ) << 16 ) | ( ( ( uint32_t ) g ) << 8 ) | ( ( uint32_t ) b )