karl2d.doc.odin 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. // This file is purely documentational. It is generated from the contents of 'karl2d.odin'.
  2. #+build ignore
  3. package karl2d
  4. //-----------------------------------------------//
  5. // SETUP, WINDOW MANAGEMENT AND FRAME MANAGEMENT //
  6. //-----------------------------------------------//
  7. // Opens a window and initializes some internal state. The internal state will use `allocator` for
  8. // all dynamically allocated memory. The return value can be ignored unless you need to later call
  9. // `set_internal_state`.
  10. init :: proc(window_width: int, window_height: int, window_title: string,
  11. window_creation_flags := Window_Flags {},
  12. allocator := context.allocator, loc := #caller_location) -> ^State
  13. // Returns true if the program wants to shut down. This happens when for example pressing the close
  14. // button on the window. The application can decide if it wants to shut down or if it wants to show
  15. // some kind of confirmation dialogue and shut down later.
  16. //
  17. // Commonly used for creating the "main loop" of a game.
  18. shutdown_wanted :: proc() -> bool
  19. // Closes the window and cleans up the internal state.
  20. shutdown :: proc()
  21. // Clear the backbuffer with supplied color.
  22. clear :: proc(color: Color)
  23. // Present the backbuffer. Call at end of frame to make everything you've drawn appear on the
  24. // screen. Also clears the frame_allocator that Karl2D uses for allocations that have the lifetime
  25. // of a single frame.
  26. present :: proc()
  27. // Call at start or end of frame to process all events that have arrived to the window. This
  28. // includes keyboard, mouse, gamepad and window events.
  29. //
  30. // WARNING: Not calling this will make your program impossible to interact with.
  31. process_events :: proc()
  32. get_screen_width :: proc() -> int
  33. get_screen_height :: proc() -> int
  34. set_window_position :: proc(x: int, y: int)
  35. set_window_size :: proc(width: int, height: int)
  36. // Fetch the scale of the window. This usually comes from some DPI scaling setting in the OS.
  37. // 1 means 100% scale, 1.5 means 150% etc.
  38. get_window_scale :: proc() -> f32
  39. set_window_flags :: proc(flags: Window_Flags)
  40. // Flushes the current batch. This sends off everything to the GPU that has been queued in the
  41. // current batch. Normally, you do not need to do this manually. It is done automatically when these
  42. // procedures run:
  43. //
  44. // - present
  45. // - set_camera
  46. // - set_shader
  47. // - set_shader_constant
  48. // - set_scissor_rect
  49. // - draw_texture_* IF previous draw did not use the same texture (1)
  50. // - draw_rect_*, draw_circle_*, draw_line IF previous draw did not use the shapes drawing texture (2)
  51. //
  52. // (1) When drawing textures, the current texture is fed into the active shader. Everything within
  53. // the same batch must use the same texture. So drawing with a new texture will draw the current
  54. // batch. You can combine several textures into an atlas to get bigger batches.
  55. //
  56. // (2) In order to use the same shader for shapes drawing and textured drawing, the shapes drawing
  57. // uses a blank, white texture. For the same reasons as (1), drawing something else than shapes
  58. // before drawing a shape will break up the batches. TODO: Add possibility to customize shape
  59. // drawing texture so that you can put it into an atlas.
  60. //
  61. // The batch has maximum size of VERTEX_BUFFER_MAX bytes. The shader dictates how big a vertex is
  62. // so the maximum number of vertices that can be drawn in each batch is
  63. // VERTEX_BUFFER_MAX / shader.vertex_size
  64. draw_current_batch :: proc()
  65. //-------//
  66. // INPUT //
  67. //-------//
  68. // Returns true if a keyboard key went down between the current and the previous frame. Set when
  69. // 'process_events' runs (probably once per frame).
  70. key_went_down :: proc(key: Keyboard_Key) -> bool
  71. // Returns true if a keyboard key went up (was released) between the current and the previous frame.
  72. // Set when 'process_events' runs (probably once per frame).
  73. key_went_up :: proc(key: Keyboard_Key) -> bool
  74. // Returns true if a keyboard is currently being held down. Set when 'process_events' runs (probably
  75. // once per frame).
  76. key_is_held :: proc(key: Keyboard_Key) -> bool
  77. mouse_button_went_down :: proc(button: Mouse_Button) -> bool
  78. mouse_button_went_up :: proc(button: Mouse_Button) -> bool
  79. mouse_button_is_held :: proc(button: Mouse_Button) -> bool
  80. get_mouse_wheel_delta :: proc() -> f32
  81. get_mouse_position :: proc() -> Vec2
  82. get_mouse_delta :: proc() -> Vec2
  83. is_gamepad_active :: proc(gamepad: Gamepad_Index) -> bool
  84. gamepad_button_went_down :: proc(gamepad: Gamepad_Index, button: Gamepad_Button) -> bool
  85. gamepad_button_went_up :: proc(gamepad: Gamepad_Index, button: Gamepad_Button) -> bool
  86. gamepad_button_is_held :: proc(gamepad: Gamepad_Index, button: Gamepad_Button) -> bool
  87. get_gamepad_axis :: proc(gamepad: Gamepad_Index, axis: Gamepad_Axis) -> f32
  88. // Set the left and right vibration motor speed. The range of left and right is 0 to 1. Note that on
  89. // most gamepads, the left motor is "low frequency" and the right motor is "high frequency". They do
  90. // not vibrate with the same speed.
  91. set_gamepad_vibration :: proc(gamepad: Gamepad_Index, left: f32, right: f32)
  92. //---------//
  93. // DRAWING //
  94. //---------//
  95. draw_rect :: proc(r: Rect, c: Color)
  96. draw_rect_vec :: proc(pos: Vec2, size: Vec2, c: Color)
  97. draw_rect_ex :: proc(r: Rect, origin: Vec2, rot: f32, c: Color)
  98. draw_rect_outline :: proc(r: Rect, thickness: f32, color: Color)
  99. draw_circle :: proc(center: Vec2, radius: f32, color: Color, segments := 16)
  100. draw_circle_outline :: proc(center: Vec2, radius: f32, thickness: f32, color: Color, segments := 16)
  101. draw_line :: proc(start: Vec2, end: Vec2, thickness: f32, color: Color)
  102. draw_texture :: proc(tex: Texture, pos: Vec2, tint := WHITE)
  103. draw_texture_rect :: proc(tex: Texture, rect: Rect, pos: Vec2, tint := WHITE)
  104. draw_texture_ex :: proc(tex: Texture, src: Rect, dst: Rect, origin: Vec2, rotation: f32, tint := WHITE)
  105. measure_text :: proc(text: string, font_size: f32) -> Vec2
  106. draw_text :: proc(text: string, pos: Vec2, font_size: f32, color: Color)
  107. draw_text_ex :: proc(font_handle: Font_Handle, text: string, pos: Vec2, font_size: f32, color: Color)
  108. //--------------------//
  109. // TEXTURE MANAGEMENT //
  110. //--------------------//
  111. create_texture :: proc(width: int, height: int, format: Pixel_Format) -> Texture
  112. // Load a texture from disk and upload it to the GPU so you can draw it to the screen.
  113. // Supports PNG, BMP, TGA and baseline PNG. Note that progressive PNG files are not supported!
  114. //
  115. // The `options` parameter can be used to specify things things such as premultiplication of alpha.
  116. load_texture_from_file :: proc(filename: string, options: Load_Texture_Options = {}) -> Texture
  117. // Load a texture from a byte slice and upload it to the GPU so you can draw it to the screen.
  118. // Supports PNG, BMP, TGA and baseline PNG. Note that progressive PNG files are not supported!
  119. //
  120. // The `options` parameter can be used to specify things things such as premultiplication of alpha.
  121. load_texture_from_bytes :: proc(bytes: []u8, options: Load_Texture_Options = {}) -> Texture
  122. // Load raw texture data. You need to specify the data, size and format of the texture yourself.
  123. // This assumes that there is no header in the data. If your data has a header (you read the data
  124. // from a file on disk), then please use `load_texture_from_bytes` instead.
  125. load_texture_from_bytes_raw :: proc(bytes: []u8, width: int, height: int, format: Pixel_Format) -> Texture
  126. // Get a rectangle that spans the whole texture. Coordinates will be (x, y) = (0, 0) and size
  127. // (w, h) = (texture_width, texture_height)
  128. get_texture_rect :: proc(t: Texture) -> Rect
  129. // Update a texture with new pixels. `bytes` is the new pixel data. `rect` is the rectangle in
  130. // `tex` where the new pixels should end up.
  131. update_texture :: proc(tex: Texture, bytes: []u8, rect: Rect) -> bool
  132. destroy_texture :: proc(tex: Texture)
  133. // Controls how a texture should be filtered. You can choose "point" or "linear" filtering. Which
  134. // means "pixly" or "smooth". This filter will be used for up and down-scaling as well as for
  135. // mipmap sampling. Use `set_texture_filter_ex` if you need to control these settings separately.
  136. set_texture_filter :: proc(t: Texture, filter: Texture_Filter)
  137. // Controls how a texture should be filtered. `scale_down_filter` and `scale_up_filter` controls how
  138. // the texture is filtered when we render the texture at a smaller or larger size.
  139. // `mip_filter` controls how the texture is filtered when it is sampled using _mipmapping_.
  140. //
  141. // TODO: Add mipmapping generation controls for texture and refer to it from here.
  142. set_texture_filter_ex :: proc(
  143. t: Texture,
  144. scale_down_filter: Texture_Filter,
  145. scale_up_filter: Texture_Filter,
  146. mip_filter: Texture_Filter,
  147. )
  148. //-----------------//
  149. // RENDER TEXTURES //
  150. //-----------------//
  151. // Create a texture that you can render into. Meaning that you can draw into it instead of drawing
  152. // onto the screen. Set the texture using `set_render_texture`.
  153. create_render_texture :: proc(width: int, height: int) -> Render_Texture
  154. // Destroy a Render_Texture previously created using `create_render_texture`.
  155. destroy_render_texture :: proc(render_texture: Render_Texture)
  156. // Make all rendering go into a texture instead of onto the screen. Create the render texture using
  157. // `create_render_texture`. Pass `nil` to resume drawing onto the screen.
  158. set_render_texture :: proc(render_texture: Maybe(Render_Texture))
  159. //-------//
  160. // FONTS //
  161. //-------//
  162. load_font_from_file :: proc(filename: string) -> Font_Handle
  163. load_font_from_bytes :: proc(data: []u8) -> Font_Handle
  164. destroy_font :: proc(font: Font_Handle)
  165. get_default_font :: proc() -> Font_Handle
  166. //---------//
  167. // SHADERS //
  168. //---------//
  169. load_shader_from_file :: proc(
  170. vertex_filename: string,
  171. fragment_filename: string,
  172. layout_formats: []Pixel_Format = {}
  173. ) -> Shader
  174. load_shader_from_memory :: proc(
  175. vertex_shader_bytes: []byte,
  176. fragment_shader_bytes: []byte,
  177. layout_formats: []Pixel_Format = {},
  178. ) -> Shader
  179. destroy_shader :: proc(shader: Shader)
  180. get_default_shader :: proc() -> Shader
  181. set_shader :: proc(shader: Maybe(Shader))
  182. set_shader_constant :: proc(shd: Shader, loc: Shader_Constant_Location, val: any)
  183. override_shader_input :: proc(shader: Shader, input: int, val: any)
  184. pixel_format_size :: proc(f: Pixel_Format) -> int
  185. //-------------------------------//
  186. // CAMERA AND COORDINATE SYSTEMS //
  187. //-------------------------------//
  188. set_camera :: proc(camera: Maybe(Camera))
  189. screen_to_world :: proc(pos: Vec2, camera: Camera) -> Vec2
  190. world_to_screen :: proc(pos: Vec2, camera: Camera) -> Vec2
  191. get_camera_view_matrix :: proc(c: Camera) -> Mat4
  192. get_camera_world_matrix :: proc(c: Camera) -> Mat4
  193. //------//
  194. // MISC //
  195. //------//
  196. // Choose how the alpha channel is used when mixing half-transparent color with what is already
  197. // drawn. The default is the .Alpha mode, but you also have the option of using .Premultiply_Alpha.
  198. set_blend_mode :: proc(mode: Blend_Mode)
  199. set_scissor_rect :: proc(scissor_rect: Maybe(Rect))
  200. // Restore the internal state using the pointer returned by `init`. Useful after reloading the
  201. // library (for example, when doing code hot reload).
  202. set_internal_state :: proc(state: ^State)
  203. //---------------------//
  204. // TYPES AND CONSTANTS //
  205. //---------------------//
  206. Vec2 :: [2]f32
  207. Vec3 :: [3]f32
  208. Vec4 :: [4]f32
  209. Mat4 :: matrix[4,4]f32
  210. // A two dimensional vector of integer numeric type.
  211. Vec2i :: [2]int
  212. // A rectangle that sits at position (x, y) and has size (w, h).
  213. Rect :: struct {
  214. x, y: f32,
  215. w, h: f32,
  216. }
  217. // An RGBA (Red, Green, Blue, Alpha) color. Each channel can have a value between 0 and 255.
  218. Color :: [4]u8
  219. WHITE :: Color { 255, 255, 255, 255 }
  220. BLACK :: Color { 0, 0, 0, 255 }
  221. GRAY :: Color { 127, 127, 127, 255 }
  222. RED :: Color { 198, 40, 90, 255 }
  223. GREEN :: Color { 30, 240, 30, 255 }
  224. BLANK :: Color { 0, 0, 0, 0 }
  225. BLUE :: Color { 30, 116, 240, 255 }
  226. // These are from Raylib. They are here so you can easily port a Raylib program to Karl2D.
  227. RL_LIGHTGRAY :: Color { 200, 200, 200, 255 }
  228. RL_GRAY :: Color { 130, 130, 130, 255 }
  229. RL_DARKGRAY :: Color { 80, 80, 80, 255 }
  230. RL_YELLOW :: Color { 253, 249, 0, 255 }
  231. RL_GOLD :: Color { 255, 203, 0, 255 }
  232. RL_ORANGE :: Color { 255, 161, 0, 255 }
  233. RL_PINK :: Color { 255, 109, 194, 255 }
  234. RL_RED :: Color { 230, 41, 55, 255 }
  235. RL_MAROON :: Color { 190, 33, 55, 255 }
  236. RL_GREEN :: Color { 0, 228, 48, 255 }
  237. RL_LIME :: Color { 0, 158, 47, 255 }
  238. RL_DARKGREEN :: Color { 0, 117, 44, 255 }
  239. RL_SKYBLUE :: Color { 102, 191, 255, 255 }
  240. RL_BLUE :: Color { 0, 121, 241, 255 }
  241. RL_DARKBLUE :: Color { 0, 82, 172, 255 }
  242. RL_PURPLE :: Color { 200, 122, 255, 255 }
  243. RL_VIOLET :: Color { 135, 60, 190, 255 }
  244. RL_DARKPURPLE :: Color { 112, 31, 126, 255 }
  245. RL_BEIGE :: Color { 211, 176, 131, 255 }
  246. RL_BROWN :: Color { 127, 106, 79, 255 }
  247. RL_DARKBROWN :: Color { 76, 63, 47, 255 }
  248. RL_WHITE :: WHITE
  249. RL_BLACK :: BLACK
  250. RL_BLANK :: BLANK
  251. RL_MAGENTA :: Color { 255, 0, 255, 255 }
  252. RL_RAYWHITE :: Color { 245, 245, 245, 255 }
  253. Texture :: struct {
  254. handle: Texture_Handle,
  255. width: int,
  256. height: int,
  257. }
  258. Load_Texture_Option :: enum {
  259. Premultiply_Alpha,
  260. }
  261. Load_Texture_Options :: bit_set[Load_Texture_Option]
  262. Blend_Mode :: enum {
  263. Alpha,
  264. Premultiplied_Alpha, // Requires the alpha-channel to be multiplied into texture RGB channels.
  265. }
  266. Render_Texture :: struct {
  267. texture: Texture,
  268. render_target: Render_Target_Handle,
  269. }
  270. Texture_Filter :: enum {
  271. Point, // Similar to "nearest neighbor". Pixly texture scaling.
  272. Linear, // Smoothed texture scaling.
  273. }
  274. Camera :: struct {
  275. target: Vec2,
  276. offset: Vec2,
  277. rotation: f32,
  278. zoom: f32,
  279. }
  280. Window_Flag :: enum {
  281. Resizable,
  282. }
  283. Window_Flags :: bit_set[Window_Flag]
  284. Shader_Handle :: distinct Handle
  285. SHADER_NONE :: Shader_Handle {}
  286. Shader_Constant_Location :: struct {
  287. offset: int,
  288. size: int,
  289. }
  290. Shader :: struct {
  291. handle: Shader_Handle,
  292. // We store the CPU-side value of all constants in a single buffer to have less allocations.
  293. // The 'constants' array says where in this buffer each constant is, and 'constant_lookup'
  294. // maps a name to a constant location.
  295. constants_data: []u8,
  296. constants: []Shader_Constant_Location,
  297. constant_lookup: map[string]Shader_Constant_Location,
  298. // Maps built in constant types such as "model view projection matrix" to a location.
  299. constant_builtin_locations: [Shader_Builtin_Constant]Maybe(Shader_Constant_Location),
  300. texture_bindpoints: []Texture_Handle,
  301. texture_lookup: map[string]int,
  302. default_texture_index: Maybe(int),
  303. inputs: []Shader_Input,
  304. input_overrides: []Shader_Input_Value_Override,
  305. default_input_offsets: [Shader_Default_Inputs]int,
  306. vertex_size: int,
  307. }
  308. SHADER_INPUT_VALUE_MAX_SIZE :: 256
  309. Shader_Input_Value_Override :: struct {
  310. val: [SHADER_INPUT_VALUE_MAX_SIZE]u8,
  311. used: int,
  312. }
  313. Shader_Input_Type :: enum {
  314. F32,
  315. Vec2,
  316. Vec3,
  317. Vec4,
  318. }
  319. Shader_Builtin_Constant :: enum {
  320. MVP,
  321. }
  322. Shader_Default_Inputs :: enum {
  323. Unknown,
  324. Position,
  325. UV,
  326. Color,
  327. }
  328. Shader_Input :: struct {
  329. name: string,
  330. register: int,
  331. type: Shader_Input_Type,
  332. format: Pixel_Format,
  333. }
  334. Pixel_Format :: enum {
  335. Unknown,
  336. RGBA_32_Float,
  337. RGB_32_Float,
  338. RG_32_Float,
  339. R_32_Float,
  340. RGBA_8_Norm,
  341. RG_8_Norm,
  342. R_8_Norm,
  343. R_8_UInt,
  344. }
  345. Font :: struct {
  346. atlas: Texture,
  347. // internal
  348. fontstash_handle: int,
  349. }
  350. Handle :: hm.Handle
  351. Texture_Handle :: distinct Handle
  352. Render_Target_Handle :: distinct Handle
  353. Font_Handle :: distinct int
  354. FONT_NONE :: Font_Handle {}
  355. TEXTURE_NONE :: Texture_Handle {}
  356. RENDER_TARGET_NONE :: Render_Target_Handle {}
  357. // This keeps track of the internal state of the library. Usually, you do not need to poke at it.
  358. // It is created and kept as a global variable when 'init' is called. However, 'init' also returns
  359. // the pointer to it, so you can later use 'set_internal_state' to restore it (after for example hot
  360. // reload).
  361. State :: struct {
  362. allocator: runtime.Allocator,
  363. frame_arena: runtime.Arena,
  364. frame_allocator: runtime.Allocator,
  365. win: Window_Interface,
  366. window_state: rawptr,
  367. rb: Render_Backend_Interface,
  368. rb_state: rawptr,
  369. fs: fs.FontContext,
  370. shutdown_wanted: bool,
  371. mouse_position: Vec2,
  372. mouse_delta: Vec2,
  373. mouse_wheel_delta: f32,
  374. key_went_down: #sparse [Keyboard_Key]bool,
  375. key_went_up: #sparse [Keyboard_Key]bool,
  376. key_is_held: #sparse [Keyboard_Key]bool,
  377. mouse_button_went_down: #sparse [Mouse_Button]bool,
  378. mouse_button_went_up: #sparse [Mouse_Button]bool,
  379. mouse_button_is_held: #sparse [Mouse_Button]bool,
  380. gamepad_button_went_down: [MAX_GAMEPADS]#sparse [Gamepad_Button]bool,
  381. gamepad_button_went_up: [MAX_GAMEPADS]#sparse [Gamepad_Button]bool,
  382. gamepad_button_is_held: [MAX_GAMEPADS]#sparse [Gamepad_Button]bool,
  383. window: Window_Handle,
  384. default_font: Font_Handle,
  385. fonts: [dynamic]Font,
  386. shape_drawing_texture: Texture_Handle,
  387. batch_font: Font_Handle,
  388. batch_camera: Maybe(Camera),
  389. batch_shader: Shader,
  390. batch_scissor: Maybe(Rect),
  391. batch_texture: Texture_Handle,
  392. batch_render_target: Render_Target_Handle,
  393. batch_blend_mode: Blend_Mode,
  394. view_matrix: Mat4,
  395. proj_matrix: Mat4,
  396. depth: f32,
  397. depth_start: f32,
  398. depth_increment: f32,
  399. vertex_buffer_cpu: []u8,
  400. vertex_buffer_cpu_used: int,
  401. default_shader: Shader,
  402. }
  403. // Support for up to 255 mouse buttons. Cast an int to type `Mouse_Button` to use things outside the
  404. // options presented here.
  405. Mouse_Button :: enum {
  406. Left,
  407. Right,
  408. Middle,
  409. Max = 255,
  410. }
  411. // Based on Raylib / GLFW
  412. Keyboard_Key :: enum {
  413. None = 0,
  414. // Numeric keys (top row)
  415. N0 = 48,
  416. N1 = 49,
  417. N2 = 50,
  418. N3 = 51,
  419. N4 = 52,
  420. N5 = 53,
  421. N6 = 54,
  422. N7 = 55,
  423. N8 = 56,
  424. N9 = 57,
  425. // Letter keys
  426. A = 65,
  427. B = 66,
  428. C = 67,
  429. D = 68,
  430. E = 69,
  431. F = 70,
  432. G = 71,
  433. H = 72,
  434. I = 73,
  435. J = 74,
  436. K = 75,
  437. L = 76,
  438. M = 77,
  439. N = 78,
  440. O = 79,
  441. P = 80,
  442. Q = 81,
  443. R = 82,
  444. S = 83,
  445. T = 84,
  446. U = 85,
  447. V = 86,
  448. W = 87,
  449. X = 88,
  450. Y = 89,
  451. Z = 90,
  452. // Special characters
  453. Apostrophe = 39,
  454. Comma = 44,
  455. Minus = 45,
  456. Period = 46,
  457. Slash = 47,
  458. Semicolon = 59,
  459. Equal = 61,
  460. Left_Bracket = 91,
  461. Backslash = 92,
  462. Right_Bracket = 93,
  463. Backtick = 96,
  464. // Function keys, modifiers, caret control etc
  465. Space = 32,
  466. Escape = 256,
  467. Enter = 257,
  468. Tab = 258,
  469. Backspace = 259,
  470. Insert = 260,
  471. Delete = 261,
  472. Right = 262,
  473. Left = 263,
  474. Down = 264,
  475. Up = 265,
  476. Page_Up = 266,
  477. Page_Down = 267,
  478. Home = 268,
  479. End = 269,
  480. Caps_Lock = 280,
  481. Scroll_Lock = 281,
  482. Num_Lock = 282,
  483. Print_Screen = 283,
  484. Pause = 284,
  485. F1 = 290,
  486. F2 = 291,
  487. F3 = 292,
  488. F4 = 293,
  489. F5 = 294,
  490. F6 = 295,
  491. F7 = 296,
  492. F8 = 297,
  493. F9 = 298,
  494. F10 = 299,
  495. F11 = 300,
  496. F12 = 301,
  497. Left_Shift = 340,
  498. Left_Control = 341,
  499. Left_Alt = 342,
  500. Left_Super = 343,
  501. Right_Shift = 344,
  502. Right_Control = 345,
  503. Right_Alt = 346,
  504. Right_Super = 347,
  505. Menu = 348,
  506. // Numpad keys
  507. NP_0 = 320,
  508. NP_1 = 321,
  509. NP_2 = 322,
  510. NP_3 = 323,
  511. NP_4 = 324,
  512. NP_5 = 325,
  513. NP_6 = 326,
  514. NP_7 = 327,
  515. NP_8 = 328,
  516. NP_9 = 329,
  517. NP_Decimal = 330,
  518. NP_Divide = 331,
  519. NP_Multiply = 332,
  520. NP_Subtract = 333,
  521. NP_Add = 334,
  522. NP_Enter = 335,
  523. NP_Equal = 336,
  524. }
  525. MAX_GAMEPADS :: 4
  526. // A value between 0 and MAX_GAMEPADS - 1
  527. Gamepad_Index :: int
  528. Gamepad_Axis :: enum {
  529. Left_Stick_X,
  530. Left_Stick_Y,
  531. Right_Stick_X,
  532. Right_Stick_Y,
  533. Left_Trigger,
  534. Right_Trigger,
  535. }
  536. Gamepad_Button :: enum {
  537. // DPAD buttons
  538. Left_Face_Up,
  539. Left_Face_Down,
  540. Left_Face_Left,
  541. Left_Face_Right,
  542. Right_Face_Up, // XBOX: Y, PS: Triangle
  543. Right_Face_Down, // XBOX: A, PS: X
  544. Right_Face_Left, // XBOX: X, PS: Square
  545. Right_Face_Right, // XBOX: B, PS: Circle
  546. Left_Shoulder,
  547. Left_Trigger,
  548. Right_Shoulder,
  549. Right_Trigger,
  550. Left_Stick_Press, // Clicking the left analogue stick
  551. Right_Stick_Press, // Clicking the right analogue stick
  552. Middle_Face_Left, // Select / back / options button
  553. Middle_Face_Middle, // PS button (not available on XBox)
  554. Middle_Face_Right, // Start
  555. }