Kohi Game Engine
|
This file contains everything having to do with input on deskop environments from keyboards and mice. Gamepads and touch controls will likely be handled separately at a future date. More...
#include "defines.h"
Go to the source code of this file.
Typedefs | |
typedef enum buttons | buttons |
Represents available mouse buttons. More... | |
typedef enum keys | keys |
Represents available keyboard keys. More... | |
Enumerations | |
enum | buttons { BUTTON_LEFT , BUTTON_RIGHT , BUTTON_MIDDLE , BUTTON_MAX_BUTTONS } |
Represents available mouse buttons. More... | |
enum | keys { KEY_BACKSPACE = 0x08 , KEY_ENTER = 0x0D , KEY_TAB = 0x09 , KEY_SHIFT = 0x10 , KEY_CONTROL = 0x11 , KEY_PAUSE = 0x13 , KEY_CAPITAL = 0x14 , KEY_ESCAPE = 0x1B , KEY_CONVERT = 0x1C , KEY_NONCONVERT = 0x1D , KEY_ACCEPT = 0x1E , KEY_MODECHANGE = 0x1F , KEY_SPACE = 0x20 , KEY_PAGEUP = 0x21 , KEY_PAGEDOWN = 0x22 , KEY_END = 0x23 , KEY_HOME = 0x24 , KEY_LEFT = 0x25 , KEY_UP = 0x26 , KEY_RIGHT = 0x27 , KEY_DOWN = 0x28 , KEY_SELECT = 0x29 , KEY_PRINT = 0x2A , KEY_EXECUTE = 0x2B , KEY_PRINTSCREEN = 0x2C , KEY_INSERT = 0x2D , KEY_DELETE = 0x2E , KEY_HELP = 0x2F , KEY_0 = 0x30 , KEY_1 = 0x31 , KEY_2 = 0x32 , KEY_3 = 0x33 , KEY_4 = 0x34 , KEY_5 = 0x35 , KEY_6 = 0x36 , KEY_7 = 0x37 , KEY_8 = 0x38 , KEY_9 = 0x39 , KEY_A = 0x41 , KEY_B = 0x42 , KEY_C = 0x43 , KEY_D = 0x44 , KEY_E = 0x45 , KEY_F = 0x46 , KEY_G = 0x47 , KEY_H = 0x48 , KEY_I = 0x49 , KEY_J = 0x4A , KEY_K = 0x4B , KEY_L = 0x4C , KEY_M = 0x4D , KEY_N = 0x4E , KEY_O = 0x4F , KEY_P = 0x50 , KEY_Q = 0x51 , KEY_R = 0x52 , KEY_S = 0x53 , KEY_T = 0x54 , KEY_U = 0x55 , KEY_V = 0x56 , KEY_W = 0x57 , KEY_X = 0x58 , KEY_Y = 0x59 , KEY_Z = 0x5A , KEY_LSUPER = 0x5B , KEY_RSUPER = 0x5C , KEY_APPS = 0x5D , KEY_SLEEP = 0x5F , KEY_NUMPAD0 = 0x60 , KEY_NUMPAD1 = 0x61 , KEY_NUMPAD2 = 0x62 , KEY_NUMPAD3 = 0x63 , KEY_NUMPAD4 = 0x64 , KEY_NUMPAD5 = 0x65 , KEY_NUMPAD6 = 0x66 , KEY_NUMPAD7 = 0x67 , KEY_NUMPAD8 = 0x68 , KEY_NUMPAD9 = 0x69 , KEY_MULTIPLY = 0x6A , KEY_ADD = 0x6B , KEY_SEPARATOR = 0x6C , KEY_SUBTRACT = 0x6D , KEY_DECIMAL = 0x6E , KEY_DIVIDE = 0x6F , KEY_F1 = 0x70 , KEY_F2 = 0x71 , KEY_F3 = 0x72 , KEY_F4 = 0x73 , KEY_F5 = 0x74 , KEY_F6 = 0x75 , KEY_F7 = 0x76 , KEY_F8 = 0x77 , KEY_F9 = 0x78 , KEY_F10 = 0x79 , KEY_F11 = 0x7A , KEY_F12 = 0x7B , KEY_F13 = 0x7C , KEY_F14 = 0x7D , KEY_F15 = 0x7E , KEY_F16 = 0x7F , KEY_F17 = 0x80 , KEY_F18 = 0x81 , KEY_F19 = 0x82 , KEY_F20 = 0x83 , KEY_F21 = 0x84 , KEY_F22 = 0x85 , KEY_F23 = 0x86 , KEY_F24 = 0x87 , KEY_NUMLOCK = 0x90 , KEY_SCROLL = 0x91 , KEY_NUMPAD_EQUAL = 0x92 , KEY_LSHIFT = 0xA0 , KEY_RSHIFT = 0xA1 , KEY_LCONTROL = 0xA2 , KEY_RCONTROL = 0xA3 , KEY_LALT = 0xA4 , KEY_RALT = 0xA5 , KEY_SEMICOLON = 0x3B , KEY_APOSTROPHE = 0xDE , KEY_QUOTE = KEY_APOSTROPHE , KEY_EQUAL = 0xBB , KEY_COMMA = 0xBC , KEY_MINUS = 0xBD , KEY_PERIOD = 0xBE , KEY_SLASH = 0xBF , KEY_GRAVE = 0xC0 , KEY_LBRACKET = 0xDB , KEY_PIPE = 0xDC , KEY_BACKSLASH = KEY_PIPE , KEY_RBRACKET = 0xDD , KEYS_MAX_KEYS = 0xFF } |
Represents available keyboard keys. More... | |
Functions | |
b8 | input_system_initialize (u64 *memory_requirement, void *state, void *config) |
Initializes the input system. Call twice; once to obtain memory requirement (passing state = 0), then a second time passing allocated memory to state. More... | |
void | input_system_shutdown (void *state) |
Shuts the input system down. More... | |
void | input_update (const struct frame_data *p_frame_data) |
Updates the input system every frame. More... | |
KAPI b8 | input_is_key_down (keys key) |
Indicates if the given key is currently pressed down. More... | |
KAPI b8 | input_is_key_up (keys key) |
Indicates if the given key is NOT currently pressed down. More... | |
KAPI b8 | input_was_key_down (keys key) |
Indicates if the given key was previously pressed down on the last frame. More... | |
KAPI b8 | input_was_key_up (keys key) |
Indicates if the given key was previously pressed down in the last frame. More... | |
void | input_process_key (keys key, b8 pressed) |
Sets the state for the given key. More... | |
KAPI b8 | input_is_button_down (buttons button) |
Indicates if the given mouse button is currently pressed. More... | |
KAPI b8 | input_is_button_up (buttons button) |
Indicates if the given mouse button is currently released. More... | |
KAPI b8 | input_was_button_down (buttons button) |
Indicates if the given mouse button was previously pressed in the last frame. More... | |
KAPI b8 | input_was_button_up (buttons button) |
Indicates if the given mouse button was previously released in the last frame. More... | |
KAPI b8 | input_is_button_dragging (buttons button) |
Indicates if the mouse is currently being dragged with the provided button being held down. More... | |
KAPI void | input_get_mouse_position (i32 *x, i32 *y) |
Obtains the current mouse position. More... | |
KAPI void | input_get_previous_mouse_position (i32 *x, i32 *y) |
Obtains the previous mouse position. More... | |
void | input_process_button (buttons button, b8 pressed) |
Sets the press state of the given mouse button. More... | |
void | input_process_mouse_move (i16 x, i16 y) |
Sets the current position of the mouse to the given x and y positions. Also updates the previous position beforehand. More... | |
void | input_process_mouse_wheel (i8 z_delta) |
Processes mouse wheel scrolling. More... | |
KAPI const char * | input_keycode_str (keys key) |
Returns a string representation of the provided key. Ex. "tab" for the tab key. More... | |
KAPI void | input_keymap_push (const struct keymap *map) |
Pushes a new keymap onto the keymap stack, making it the active keymap. A copy of the keymap is taken when pushing onto the stack. More... | |
KAPI b8 | input_keymap_pop (void) |
Attempts to pop the top-most keymap from the stack, if there is one. More... | |
This file contains everything having to do with input on deskop environments from keyboards and mice. Gamepads and touch controls will likely be handled separately at a future date.
enum buttons |
enum keys |
Represents available keyboard keys.
Obtains the current mouse position.
x | A pointer to hold the current mouse position on the x-axis. |
y | A pointer to hold the current mouse position on the y-axis. |
Obtains the previous mouse position.
x | A pointer to hold the previous mouse position on the x-axis. |
y | A pointer to hold the previous mouse position on the y-axis. |
Indicates if the given mouse button is currently pressed.
button | The button to check. |
Indicates if the mouse is currently being dragged with the provided button being held down.
button | The button to check. |
Indicates if the given mouse button is currently released.
button | The button to check. |
Indicates if the given key is currently pressed down.
key | They key to be checked. |
Indicates if the given key is NOT currently pressed down.
key | They key to be checked. |
Returns a string representation of the provided key. Ex. "tab" for the tab key.
key |
Attempts to pop the top-most keymap from the stack, if there is one.
Pushes a new keymap onto the keymap stack, making it the active keymap. A copy of the keymap is taken when pushing onto the stack.
map | A constant pointer to the keymap to be pushed. |
Sets the press state of the given mouse button.
button | The mouse button whose state to set. |
pressed | Indicates if the mouse button is currently pressed. |
Sets the state for the given key.
key | The key to be processed. |
pressed | Indicates whether the key is currently pressed. |
Sets the current position of the mouse to the given x and y positions. Also updates the previous position beforehand.
void input_process_mouse_wheel | ( | i8 | z_delta | ) |
Processes mouse wheel scrolling.
z_delta | The amount of scrolling which occurred on the z axis (mouse wheel) |
Initializes the input system. Call twice; once to obtain memory requirement (passing state = 0), then a second time passing allocated memory to state.
memory_requirement | The required size of the state memory. |
state | Either 0 or the allocated block of state memory. |
config | Ignored. |
void input_system_shutdown | ( | void * | state | ) |
Shuts the input system down.
state | A pointer to the system state. |
void input_update | ( | const struct frame_data * | p_frame_data | ) |
Updates the input system every frame.
p_frame_data | A constant pointer to the current frame's data. NOTE: Does not use system manager update because it must be called at end of a frame. |
Indicates if the given mouse button was previously pressed in the last frame.
button | The button to check. |
Indicates if the given mouse button was previously released in the last frame.
button | The button to check. |
Indicates if the given key was previously pressed down on the last frame.
key | They key to be checked. |