Banjo API 0.0.1
Multi-purpose C99 API
Loading...
Searching...
No Matches
Event

Handle input events such as keyboard, mouse and focus. More...

Collaboration diagram for Event:

Detailed Description

The event system provides a simple callback interface for handling user interactions with windows, including cursor movement, button presses, keyboard input, and window enter/leave detection.

Events are dispatched via polling with bj_dispatch_events.

Data Structures

struct  bj_enter_event_t
 Represent a mouse enter or leave event. More...
 
struct  bj_cursor_event_t
 Represent a mouse cursor movement event. More...
 
struct  bj_button_event_t
 Represent a mouse button event. More...
 
struct  bj_key_event_t
 Represent a keyboard key event. More...
 
struct  bj_event_t
 Represent a generic window-related event. More...
 
union  bj_event_t.__unnamed0__
 

Macros

#define BJ_BUTTON_1   1
 First button.
 
#define BJ_BUTTON_2   2
 Second button.
 
#define BJ_BUTTON_3   3
 Third button.
 
#define BJ_BUTTON_4   4
 Fourth button.
 
#define BJ_BUTTON_5   5
 Fifth button.
 
#define BJ_BUTTON_LEFT   BJ_BUTTON_1
 Left mouse button.
 
#define BJ_BUTTON_RIGHT   BJ_BUTTON_3
 Right mouse button.
 
#define BJ_BUTTON_MIDDLE   BJ_BUTTON_2
 Middle mouse button.
 
#define BJ_BUTTON_UP   BJ_BUTTON_4
 Scroll up mouse button.
 
#define BJ_BUTTON_DOWN   BJ_BUTTON_5
 Scroll down mouse button.
 
#define BJ_KEY_APOSTROPHE   BJ_KEY_OEM_7
 Alias for BJ_KEY_OEM_7.
 
#define BJ_KEY_BACKSLASH   BJ_KEY_OEM_5
 Alias for BJ_KEY_OEM_5.
 
#define BJ_KEY_BACKSPACE   BJ_KEY_BACK
 Alias for BJ_KEY_BACK.
 
#define BJ_KEY_CAPSLOCK   BJ_KEY_CAPITAL
 Alias for BJ_KEY_CAPITAL.
 
#define BJ_KEY_COMMA   BJ_KEY_OEM_COMMA
 Alias for BJ_KEY_OEM_COMMA.
 
#define BJ_KEY_ENTER   BJ_KEY_RETURN
 Alias for BJ_KEY_RETURN.
 
#define BJ_KEY_GRAVE_ACCENT   BJ_KEY_OEM_3
 Alias for BJ_KEY_OEM_3.
 
#define BJ_KEY_HANGUL   BJ_KEY_KANA
 Alias for BJ_KEY_KANA.
 
#define BJ_KEY_HANJA   BJ_KEY_KANJI
 Alias for BJ_KEY_KANJI.
 
#define BJ_KEY_LEFT_ALT   BJ_KEY_LMENU
 Alias for BJ_KEY_LMENU.
 
#define BJ_KEY_LEFT_BRACKET   BJ_KEY_OEM_4
 Alias for BJ_KEY_OEM_4.
 
#define BJ_KEY_LEFT_CONTROL   BJ_KEY_LCONTROL
 Alias for BJ_KEY_LCONTROL.
 
#define BJ_KEY_LEFT_OS   BJ_KEY_LWIN
 Alias for BJ_KEY_LWIN.
 
#define BJ_KEY_LEFT_SHIT   BJ_KEY_LSHIFT
 Alias for BJ_KEY_LSHIFT.
 
#define BJ_KEY_MINUS   BJ_KEY_OEM_MINUS
 Alias for BJ_KEY_OEM_MINUS.
 
#define BJ_KEY_PAGE_DOWN   BJ_KEY_NEXT
 Alias for BJ_KEY_NEXT.
 
#define BJ_KEY_PAGE_UP   BJ_KEY_PRIOR
 Alias for BJ_KEY_PRIOR.
 
#define BJ_KEY_PERIOD   BJ_KEY_OEM_PERIOD
 Alias for BJ_KEY_OEM_PERIOD.
 
#define BJ_KEY_PLUS   BJ_KEY_OEM_PLUS
 Alias for BJ_KEY_OEM_PLUS.
 
#define BJ_KEY_PRINT_SCREEN   BJ_KEY_SNAPSHOT
 Alias for BJ_KEY_SNAPSHOT.
 
#define BJ_KEY_RIGHT_ALT   BJ_KEY_RMENU
 Alias for BJ_KEY_RMENU.
 
#define BJ_KEY_RIGHT_BRACKET   BJ_KEY_OEM_6
 Alias for BJ_KEY_OEM_6.
 
#define BJ_KEY_RIGHT_CONTROL   BJ_KEY_RCONTROL
 Alias for BJ_KEY_RCONTROL.
 
#define BJ_KEY_RIGHT_OS   BJ_KEY_RWIN
 Alias for BJ_KEY_RWIN.
 
#define BJ_KEY_RIGHT_SHIFT   BJ_KEY_RSHIFT
 Alias for BJ_KEY_RSHIFT.
 
#define BJ_KEY_SEMICOLON   BJ_KEY_OEM_1
 Alias for BJ_KEY_OEM_1.
 
#define BJ_KEY_SLASH   BJ_KEY_OEM_2
 Alias for BJ_KEY_OEM_2.
 

Typedefs

typedef enum bj_key_t bj_key
 List of possible keys on a keyboard.
 
typedef enum bj_event_action_t bj_event_action
 Define event action types for keys or mouse buttons.
 
typedef struct bj_enter_event_t bj_enter_event
 Represent a mouse enter or leave event.
 
typedef struct bj_cursor_event_t bj_cursor_event
 Represent a mouse cursor movement event.
 
typedef struct bj_button_event_t bj_button_event
 Represent a mouse button event.
 
typedef struct bj_key_event_t bj_key_event
 Represent a keyboard key event.
 
typedef enum bj_event_type_t bj_event_type
 Identify the type of a generic event.
 
typedef struct bj_event_t bj_event
 Represent a generic window-related event.
 
typedef void(* bj_enter_callback_fn_t) (bj_window *, const bj_enter_event *, void *)
 Define the callback type for enter events.
 
typedef void(* bj_cursor_callback_fn_t) (bj_window *p_window, const bj_cursor_event *, void *)
 Define the callback type for cursor movement events.
 
typedef void(* bj_button_callback_fn_t) (bj_window *p_window, const bj_button_event *, void *)
 Define the callback type for mouse button events.
 
typedef void(* bj_key_callback_fn_t) (bj_window *p_window, const bj_key_event *, void *)
 Define the callback type for keyboard key events.
 

Enumerations

enum  bj_key_t {
  BJ_KEY_UNKNOWN = 0x00 , BJ_KEY_LBUTTON = 0x01 , BJ_KEY_RBUTTON = 0x02 , BJ_KEY_CANCEL = 0x03 ,
  BJ_KEY_MBUTTON = 0x04 , BJ_KEY_XBUTTON1 = 0x05 , BJ_KEY_XBUTTON2 = 0x06 , BJ_KEY_BACK = 0x08 ,
  BJ_KEY_TAB = 0x09 , BJ_KEY_CLEAR = 0x0C , BJ_KEY_RETURN = 0x0D , BJ_KEY_SHIFT = 0x10 ,
  BJ_KEY_CONTROL = 0x11 , BJ_KEY_MENU = 0x12 , BJ_KEY_PAUSE = 0x13 , BJ_KEY_CAPITAL = 0x14 ,
  BJ_KEY_KANA = 0x15 , BJ_KEY_IME_ON = 0x16 , BJ_KEY_JUNJA = 0x17 , BJ_KEY_FINAL = 0x18 ,
  BJ_KEY_KANJI = 0x19 , BJ_KEY_IME_OFF = 0x1A , BJ_KEY_ESCAPE = 0x1B , BJ_KEY_CONVERT = 0x1C ,
  BJ_KEY_NONCONVERT = 0x1D , BJ_KEY_ACCEPT = 0x1E , BJ_KEY_MODECHANGE = 0x1F , BJ_KEY_SPACE = 0x20 ,
  BJ_KEY_PRIOR = 0x21 , BJ_KEY_NEXT = 0x22 , BJ_KEY_END = 0x23 , BJ_KEY_HOME = 0x24 ,
  BJ_KEY_LEFT = 0x25 , BJ_KEY_UP = 0x26 , BJ_KEY_RIGHT = 0x27 , BJ_KEY_DOWN = 0x28 ,
  BJ_KEY_SELECT = 0x29 , BJ_KEY_PRINT = 0x2A , BJ_KEY_EXECUTE = 0x2B , BJ_KEY_SNAPSHOT = 0x2C ,
  BJ_KEY_INSERT = 0x2D , BJ_KEY_DELETE = 0x2E , BJ_KEY_HELP = 0x2F , BJ_KEY_0 = 0x30 ,
  BJ_KEY_1 = 0x31 , BJ_KEY_2 = 0x32 , BJ_KEY_3 = 0x33 , BJ_KEY_4 = 0x34 ,
  BJ_KEY_5 = 0x35 , BJ_KEY_6 = 0x36 , BJ_KEY_7 = 0x37 , BJ_KEY_8 = 0x38 ,
  BJ_KEY_9 = 0x39 , BJ_KEY_A = 0x41 , BJ_KEY_B = 0x42 , BJ_KEY_C = 0x43 ,
  BJ_KEY_D = 0x44 , BJ_KEY_E = 0x45 , BJ_KEY_F = 0x46 , BJ_KEY_G = 0x47 ,
  BJ_KEY_H = 0x48 , BJ_KEY_I = 0x49 , BJ_KEY_J = 0x4A , BJ_KEY_K = 0x4B ,
  BJ_KEY_L = 0x4C , BJ_KEY_M = 0x4D , BJ_KEY_N = 0x4E , BJ_KEY_O = 0x4F ,
  BJ_KEY_P = 0x50 , BJ_KEY_Q = 0x51 , BJ_KEY_R = 0x52 , BJ_KEY_S = 0x53 ,
  BJ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, BJ_KEY_CRSEL = 0xF7 , BJ_KEY_EXSEL = 0xF8 , BJ_KEY_EREOF = 0xF9 ,
  BJ_KEY_PLAY = 0xFA , BJ_KEY_ZOOM = 0xFB , BJ_KEY_NONAME = 0xFC , BJ_KEY_PA1 = 0xFD ,
  BJ_KEY_OEM_CLEAR = 0xFE
}
 List of possible keys on a keyboard. More...
 
enum  bj_event_action_t { BJ_RELEASE , BJ_PRESS , BJ_REPEAT }
 Define event action types for keys or mouse buttons. More...
 
enum  bj_event_type_t { BJ_EVENT_ENTER , BJ_EVENT_CURSOR , BJ_EVENT_KEY , BJ_EVENT_BUTTON }
 Identify the type of a generic event. More...
 

Functions

const char * bj_get_key_name (int key)
 Get the string name of a key.
 
bj_cursor_callback_fn_t bj_set_cursor_callback (bj_cursor_callback_fn_t p_callback, void *p_user_data)
 Set the global callback for cursor events.
 
bj_button_callback_fn_t bj_set_button_callback (bj_button_callback_fn_t p_callback, void *p_user_data)
 Set the global callback for mouse button events.
 
bj_key_callback_fn_t bj_set_key_callback (bj_key_callback_fn_t p_callback, void *p_user_data)
 Set the global callback for keyboard key events.
 
bj_enter_callback_fn_t bj_set_enter_callback (bj_enter_callback_fn_t p_callback, void *p_user_data)
 Set the global callback for mouse enter/leave events.
 
void bj_close_on_escape (bj_window *, const bj_key_event *, void *p_user_data)
 Handle the ESC key to close a window.
 
void bj_push_event (const bj_event *e)
 Push a custom event to the internal event queue.
 
void bj_push_key_event (bj_window *p_window, bj_event_action action, bj_key key, int scancode)
 Push a keyboard event into the event system.
 
void bj_push_cursor_event (bj_window *p_window, int x, int y)
 Push a cursor movement event.
 
void bj_push_button_event (bj_window *p_window, int button, bj_event_action action, int x, int y)
 Push a mouse button event.
 
void bj_push_enter_event (bj_window *p_window, bj_bool enter, int x, int y)
 Push an enter or leave window event.
 
void bj_dispatch_events (void)
 Poll and dispatch all pending events.
 
bj_bool bj_poll_events (bj_event *p_event)
 
void bj_dispatch_event (const bj_event *p_event)
 

Data Structure Documentation

◆ bj_enter_event_t

struct bj_enter_event_t
Data Fields
bj_bool enter BJ_TRUE if entering window, BJ_FALSE if leaving.
int x Cursor x position.
int y Cursor y position.

◆ bj_cursor_event_t

struct bj_cursor_event_t
Data Fields
int x Cursor x position.
int y Cursor y position.

◆ bj_button_event_t

struct bj_button_event_t
Data Fields
bj_event_action action Action (press/release)
int button Button identifier (e.g., BJ_BUTTON_LEFT)
int x Cursor x position.
int y Cursor y position.

◆ bj_key_event_t

struct bj_key_event_t
Data Fields
bj_event_action action Action (press/release/repeat)
bj_key key Key identifier.
int scancode Scancode (layout-independent)

◆ bj_event_t

struct bj_event_t

This union-based structure wraps all types of input events.

Data Fields
union bj_event_t.__unnamed0__ __unnamed__
bj_event_type type Type of event.
bj_window * window Target window.

◆ bj_event_t.__unnamed0__

union bj_event_t.__unnamed0__
Data Fields
bj_button_event button Button event data.
bj_cursor_event cursor Cursor event data.
bj_enter_event enter Enter/leave event data.
bj_key_event key Key event data.

Typedef Documentation

◆ bj_button_callback_fn_t

typedef void(* bj_button_callback_fn_t) (bj_window *p_window, const bj_button_event *, void *)

Called when a mouse button is pressed or released.

See also
bj_set_button_callback

◆ bj_cursor_callback_fn_t

typedef void(* bj_cursor_callback_fn_t) (bj_window *p_window, const bj_cursor_event *, void *)

Called when the cursor moves inside a window.

See also
bj_set_cursor_callback

◆ bj_enter_callback_fn_t

typedef void(* bj_enter_callback_fn_t) (bj_window *, const bj_enter_event *, void *)

Called when the cursor enters or exits a window.

See also
bj_set_enter_callback

◆ bj_event

typedef struct bj_event_t bj_event

This union-based structure wraps all types of input events.

◆ bj_key

typedef enum bj_key_t bj_key

The values are directly taken from the [VK codes in Microsoft API] (https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes) This also includes the annotated documentation of each key.

Even if all values from the abovementioned page are present in this enum, not all are used by Banjo and some are never returned by key events.

Values for 0-9 and A-Z keys directly directly correspond to their ASCII equivalent.

◆ bj_key_callback_fn_t

typedef void(* bj_key_callback_fn_t) (bj_window *p_window, const bj_key_event *, void *)

Called when a key is pressed, released, or repeated.

See also
bj_set_key_callback

Enumeration Type Documentation

◆ bj_event_action_t

Enumerator
BJ_RELEASE 

The key or button was released.

BJ_PRESS 

The key or button was pressed.

BJ_REPEAT 

The key is being held (repeats)

◆ bj_event_type_t

Enumerator
BJ_EVENT_ENTER 

Mouse enter/leave.

BJ_EVENT_CURSOR 

Mouse move.

BJ_EVENT_KEY 

Keyboard key.

BJ_EVENT_BUTTON 

Mouse button.

◆ bj_key_t

enum bj_key_t

The values are directly taken from the [VK codes in Microsoft API] (https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes) This also includes the annotated documentation of each key.

Even if all values from the abovementioned page are present in this enum, not all are used by Banjo and some are never returned by key events.

Values for 0-9 and A-Z keys directly directly correspond to their ASCII equivalent.

Enumerator
BJ_KEY_UNKNOWN 

No Button.

BJ_KEY_LBUTTON 

Left mouse button.

BJ_KEY_RBUTTON 

Right mouse button.

BJ_KEY_CANCEL 

Control-break processing.

BJ_KEY_MBUTTON 

Middle mouse button.

BJ_KEY_XBUTTON1 

X1 mouse button.

BJ_KEY_XBUTTON2 

X2 mouse button.

BJ_KEY_BACK 

Backspace key.

BJ_KEY_TAB 

Tab key.

BJ_KEY_CLEAR 

Clear key.

BJ_KEY_RETURN 

Enter key.

BJ_KEY_SHIFT 

Shift key.

BJ_KEY_CONTROL 

Ctrl key.

BJ_KEY_MENU 

Alt key.

BJ_KEY_PAUSE 

Pause key.

BJ_KEY_CAPITAL 

Caps lock key.

BJ_KEY_KANA 

IME Kana mode.

BJ_KEY_IME_ON 

IME On.

BJ_KEY_JUNJA 

IME Junja mode.

BJ_KEY_FINAL 

IME final mode.

BJ_KEY_KANJI 

IME Hanja mode.

BJ_KEY_IME_OFF 

IME Off.

BJ_KEY_ESCAPE 

Esc key.

BJ_KEY_CONVERT 

IME convert.

BJ_KEY_NONCONVERT 

IME nonconvert.

BJ_KEY_ACCEPT 

IME accept.

BJ_KEY_MODECHANGE 

IME mode change request.

BJ_KEY_SPACE 

Spacebar key.

BJ_KEY_PRIOR 

Page up key.

BJ_KEY_NEXT 

Page down key.

BJ_KEY_END 

End key.

BJ_KEY_HOME 

Home key.

BJ_KEY_LEFT 

Left arrow key.

BJ_KEY_UP 

Up arrow key.

BJ_KEY_RIGHT 

Right arrow key.

BJ_KEY_DOWN 

Down arrow key.

BJ_KEY_SELECT 

Select key.

BJ_KEY_PRINT 

Print key.

BJ_KEY_EXECUTE 

Execute key.

BJ_KEY_SNAPSHOT 

Print screen key.

BJ_KEY_INSERT 

Insert key.

BJ_KEY_DELETE 

Delete key.

BJ_KEY_HELP 

Help key.

BJ_KEY_0 

0 key

BJ_KEY_1 

1 key

BJ_KEY_2 

2 key

BJ_KEY_3 

3 key

BJ_KEY_4 

4 key

BJ_KEY_5 

5 key

BJ_KEY_6 

6 key

BJ_KEY_7 

7 key

BJ_KEY_8 

8 key

BJ_KEY_9 

9 key

BJ_KEY_A 

A key.

BJ_KEY_B 

B key.

BJ_KEY_C 

C key.

BJ_KEY_D 

D key.

BJ_KEY_E 

E key.

BJ_KEY_F 

F key.

BJ_KEY_G 

G key.

BJ_KEY_H 

H key.

BJ_KEY_I 

I key.

BJ_KEY_J 

J key.

BJ_KEY_K 

K key.

BJ_KEY_L 

L key.

BJ_KEY_M 

M key.

BJ_KEY_N 

N key.

BJ_KEY_O 

O key.

BJ_KEY_P 

P key.

BJ_KEY_Q 

Q key.

BJ_KEY_R 

R key.

BJ_KEY_S 

S key.

BJ_KEY_T 

T key.

BJ_KEY_U 

U key.

BJ_KEY_V 

V key.

BJ_KEY_W 

W key.

BJ_KEY_X 

X key.

BJ_KEY_Y 

Y key.

BJ_KEY_Z 

Z key.

BJ_KEY_LWIN 

Left Windows logo key.

BJ_KEY_RWIN 

Right Windows logo key.

BJ_KEY_APPS 

Application key.

BJ_KEY_SLEEP 

Computer Sleep key.

BJ_KEY_NUMPAD0 

Numeric keypad 0 key.

BJ_KEY_NUMPAD1 

Numeric keypad 1 key.

BJ_KEY_NUMPAD2 

Numeric keypad 2 key.

BJ_KEY_NUMPAD3 

Numeric keypad 3 key.

BJ_KEY_NUMPAD4 

Numeric keypad 4 key.

BJ_KEY_NUMPAD5 

Numeric keypad 5 key.

BJ_KEY_NUMPAD6 

Numeric keypad 6 key.

BJ_KEY_NUMPAD7 

Numeric keypad 7 key.

BJ_KEY_NUMPAD8 

Numeric keypad 8 key.

BJ_KEY_NUMPAD9 

Numeric keypad 9 key.

BJ_KEY_MULTIPLY 

Multiply key.

BJ_KEY_ADD 

Add key.

BJ_KEY_SEPARATOR 

Separator key.

BJ_KEY_SUBTRACT 

Subtract key.

BJ_KEY_DECIMAL 

Decimal key.

BJ_KEY_DIVIDE 

Divide key.

BJ_KEY_F1 

F1 key.

BJ_KEY_F2 

F2 key.

BJ_KEY_F3 

F3 key.

BJ_KEY_F4 

F4 key.

BJ_KEY_F5 

F5 key.

BJ_KEY_F6 

F6 key.

BJ_KEY_F7 

F7 key.

BJ_KEY_F8 

F8 key.

BJ_KEY_F9 

F9 key.

BJ_KEY_F10 

F10 key.

BJ_KEY_F11 

F11 key.

BJ_KEY_F12 

F12 key.

BJ_KEY_F13 

F13 key.

BJ_KEY_F14 

F14 key.

BJ_KEY_F15 

F15 key.

BJ_KEY_F16 

F16 key.

BJ_KEY_F17 

F17 key.

BJ_KEY_F18 

F18 key.

BJ_KEY_F19 

F19 key.

BJ_KEY_F20 

F20 key.

BJ_KEY_F21 

F21 key.

BJ_KEY_F22 

F22 key.

BJ_KEY_F23 

F23 key.

BJ_KEY_F24 

F24 key.

BJ_KEY_NUMLOCK 

Num lock key.

BJ_KEY_SCROLL 

Scroll lock key.

BJ_KEY_LSHIFT 

Left Shift key.

BJ_KEY_RSHIFT 

Right Shift key.

BJ_KEY_LCONTROL 

Left Ctrl key.

BJ_KEY_RCONTROL 

Right Ctrl key.

BJ_KEY_LMENU 

Left Alt key.

BJ_KEY_RMENU 

Right Alt key.

BJ_KEY_BROWSER_BACK 

Browser Back key.

BJ_KEY_BROWSER_FORWARD 

Browser Forward key.

BJ_KEY_BROWSER_REFRESH 

Browser Refresh key.

BJ_KEY_BROWSER_STOP 

Browser Stop key.

BJ_KEY_BROWSER_SEARCH 

Browser Search key.

BJ_KEY_BROWSER_FAVORITES 

Browser Favorites key.

BJ_KEY_BROWSER_HOME 

Browser Start and Home key.

BJ_KEY_VOLUME_MUTE 

Volume Mute key.

BJ_KEY_VOLUME_DOWN 

Volume Down key.

BJ_KEY_VOLUME_UP 

Volume Up key.

BJ_KEY_MEDIA_NEXT_TRACK 

Next Track key.

BJ_KEY_MEDIA_PREV_TRACK 

Previous Track key.

BJ_KEY_MEDIA_STOP 

Stop Media key.

BJ_KEY_MEDIA_PLAY_PAUSE 

Play/Pause Media key.

BJ_KEY_LAUNCH_MAIL 

Start Mail key.

BJ_KEY_LAUNCH_MEDIA_SELECT 

Select Media key.

BJ_KEY_LAUNCH_APP1 

Start Application 1 key.

BJ_KEY_LAUNCH_APP2 

Start Application 2 key.

BJ_KEY_OEM_1 

Used for miscellaneous characters; it can vary by keyboard.

For the US standard keyboard, the ;: key

BJ_KEY_OEM_PLUS 

For any country/region, the + key.

BJ_KEY_OEM_COMMA 

For any country/region, the , key.

BJ_KEY_OEM_MINUS 

For any country/region, the - key.

BJ_KEY_OEM_PERIOD 

For any country/region, the .

key

BJ_KEY_OEM_2 

Used for miscellaneous characters; it can vary by keyboard.

For the US standard keyboard, the /? key

BJ_KEY_OEM_3 

Used for miscellaneous characters; it can vary by keyboard.

For the US standard keyboard, the `~ key

BJ_KEY_OEM_4 

Used for miscellaneous characters; it can vary by keyboard.

For the US standard keyboard, the [{ key

BJ_KEY_OEM_5 

Used for miscellaneous characters; it can vary by keyboard.

For the US standard keyboard, the \| key

BJ_KEY_OEM_6 

Used for miscellaneous characters; it can vary by keyboard.

For the US standard keyboard, the ]} key

BJ_KEY_OEM_7 

Used for miscellaneous characters; it can vary by keyboard.

For the US standard keyboard, the '" key

BJ_KEY_OEM_8 

Used for miscellaneous characters; it can vary by keyboard.

BJ_KEY_OEM_102 

The <> keys on the US standard keyboard, or the \| key on the non-US 102-key keyboard.

BJ_KEY_PROCESSKEY 

IME PROCESS key.

BJ_KEY_PACKET 

Used to pass Unicode characters as if they were keystrokes.

The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP

BJ_KEY_ATTN 

Attn key.

BJ_KEY_CRSEL 

CrSel key.

BJ_KEY_EXSEL 

ExSel key.

BJ_KEY_EREOF 

Erase EOF key.

BJ_KEY_PLAY 

Play key.

BJ_KEY_ZOOM 

Zoom key.

BJ_KEY_NONAME 

Reserved.

BJ_KEY_PA1 

PA1 key.

BJ_KEY_OEM_CLEAR 

Clear key.

Function Documentation

◆ bj_close_on_escape()

void bj_close_on_escape ( bj_window * ,
const bj_key_event * ,
void * p_user_data )

This utility callback closes the window when BJ_KEY_ESCAPE is pressed. Can be passed directly to bj_set_key_callback.

See also
bj_key_callback_fn_t
bj_set_key_callback

◆ bj_dispatch_events()

void bj_dispatch_events ( void )

This function checks for new input events and invokes the appropriate registered callbacks.

See also
bj_set_cursor_callback
bj_set_button_callback
bj_set_key_callback
bj_set_enter_callback
Examples
bitmap_blit.c, drawing_2d.c, load_bmp.c, shaders.c, sprite_animation.c, and window.c.

◆ bj_get_key_name()

const char * bj_get_key_name ( int key)

Return a string representing the key code. The returned string omits the BJ_KEY_ prefix.

Parameters
keyThe bj_key value.
Returns
A null-terminated string owned by Banjo.
See also
bj_key

◆ bj_push_button_event()

void bj_push_button_event ( bj_window * p_window,
int button,
bj_event_action action,
int x,
int y )

Represents a mouse button press or release within a window.

Parameters
p_windowPointer to the window receiving the event.
buttonThe mouse button identifier.
actionThe action performed (press or release).
xThe x-coordinate of the cursor at the event.
yThe y-coordinate of the cursor at the event.

◆ bj_push_cursor_event()

void bj_push_cursor_event ( bj_window * p_window,
int x,
int y )

Indicates the cursor has moved within the specified window.

Parameters
p_windowPointer to the window receiving the event.
xThe new x-coordinate of the cursor.
yThe new y-coordinate of the cursor.

◆ bj_push_enter_event()

void bj_push_enter_event ( bj_window * p_window,
bj_bool enter,
int x,
int y )

Indicates whether the cursor entered or left the specified window.

Parameters
p_windowPointer to the window receiving the event.
enterBJ_TRUE if cursor entered the window, BJ_FALSE if left.
xThe x-coordinate of the cursor at the event.
yThe y-coordinate of the cursor at the event.

◆ bj_push_event()

void bj_push_event ( const bj_event * e)

Typically used by the platform backend to post low-level events into the event processing system.

Parameters
ePointer to the event to push.
Note
The event is copied internally and queued for later dispatch.

◆ bj_push_key_event()

void bj_push_key_event ( bj_window * p_window,
bj_event_action action,
bj_key key,
int scancode )

This function creates and queues a keyboard event reflecting a key press, release, or repeat.

Parameters
p_windowPointer to the window receiving the event.
actionThe key event action (press, release, repeat).
keyThe key code that triggered the event.
scancodeThe platform-specific scancode of the key.

◆ bj_set_button_callback()

bj_button_callback_fn_t bj_set_button_callback ( bj_button_callback_fn_t p_callback,
void * p_user_data )
Parameters
p_callbackThe new callback function
p_user_dataLocation to user-provided data.
Returns
The previously set callback, or NULL if none
See also
bj_button_callback_fn_t

◆ bj_set_cursor_callback()

bj_cursor_callback_fn_t bj_set_cursor_callback ( bj_cursor_callback_fn_t p_callback,
void * p_user_data )
Parameters
p_callbackThe new callback function
p_user_dataLocation to user-provided data.
Returns
The previously set callback, or NULL if none
See also
bj_cursor_callback_fn_t

◆ bj_set_enter_callback()

bj_enter_callback_fn_t bj_set_enter_callback ( bj_enter_callback_fn_t p_callback,
void * p_user_data )
Parameters
p_callbackThe new callback function
p_user_dataLocation to user-provided data.
Returns
The previously set callback, or NULL if none
See also
bj_enter_callback_fn_t

◆ bj_set_key_callback()

bj_key_callback_fn_t bj_set_key_callback ( bj_key_callback_fn_t p_callback,
void * p_user_data )
Parameters
p_callbackThe new callback function
p_user_dataLocation to user-provided data.
Returns
The previously set callback, or NULL if none
Key Repeat
If the window has the BJ_WINDOW_FLAG_KEY_REPEAT flag set, BJ_REPEAT actions will be sent when holding keys.
See also
bj_key_callback_fn_t
Examples
bitmap_blit.c, drawing_2d.c, load_bmp.c, shaders.c, sprite_animation.c, and window.c.