Untitled
Loading...
Searching...
No Matches
input.c File Reference
#include <SDL2/SDL.h>
#include <SDL2/SDL_events.h>
#include <SDL2/SDL_mouse.h>
#include <SDL2/SDL_render.h>
#include <SDL2/SDL_scancode.h>
#include <SDL2/SDL_timer.h>
#include <SDL2/SDL_video.h>
#include "core/acceleration.h"
#include "core/engine_types.h"
#include "ui/fonts.h"
#include "core/shaders.h"
#include "utilities/types.h"
#include "load/init.h"
#include "core/input.h"
#include "utilities/utilities.h"
#include "core/camera.h"
#include "audio/audio.h"
#include "editor/editor.h"
#include "load/load.h"
#include "ui/ui.h"

Go to the source code of this file.

Functions

void handle_ui_selection_event ()
void handle_held_events ()
 Processes UI events for persistent state if the LMB has not been released.
void process_sdl_event (SDL_Event event)
 Processes a deferred SDL_Event after the physics loop accumulator.
void process_input (SDL_Window **window, SDL_Event *event_queue, int *event_queue_count, SDL_Event *sdl_queue, int *sdl_queue_count, float physics_dt)
 Receives input from SDL in a while loop, pushes th events onto queues to be consumed at the end of the rendering frame.

Variables

float cooldown_time = 0.0f
float cooldown_interval = 0.1f

Function Documentation

◆ handle_ui_selection_event()

◆ handle_held_events()

void handle_held_events ( )

Processes UI events for persistent state if the LMB has not been released.

Definition at line 97 of file input.c.

References handle_held_events(), handle_ui_selection_event(), and LMB_HELD.

Referenced by handle_held_events(), and main().

◆ process_sdl_event()

void process_sdl_event ( SDL_Event event)

Processes a deferred SDL_Event after the physics loop accumulator.

Parameters
eventThe event to process.

Definition at line 107 of file input.c.

References ReflectionProbe::aabb, MeshNode::asset_instance, EditorSettings::asset_instance_menu_open, AUDIO_EMITTERS, EditorSettings::audio_menu_open, Globals::audio_portals, SceneData::audio_probe_volumes, SceneData::bvh_nodes, calculate_aabb_bounds(), cam, CAM_POS, CAST_VEC, AABB::center, Vector::count, EDITOR_APORTAL_SIZE, EditorSettings::editor_mode, EDITOR_SETTINGS, AABB::extents, Camera::forward, GLOBALS, handle_ui_event(), handle_ui_selection_event(), hit, RayHit::hit, HIT_NONE, EditorSettings::light_menu_open, SceneData::lighting_probe_volumes, Globals::lights, LMB_HELD, EditorSettings::lprobe_menu_open, M_PI, SubMesh::material, MAX_AUDIO_EMITTERS, MENU_AINST, MENU_AUDIO, MENU_LIGHT, MENU_LPROBE, MENU_MN, menu_names, MeshNode::mesh, RayHit::mesh_node_idx, EditorSettings::mesh_node_menu_open, Globals::mesh_nodes, Globals::meshes, MOUSE_X, MOUSE_Y, NK_CTX, NUKLEAR_HOVERED, ProbeVolume::obb, EditorSettings::opening_menu, Camera::pitch, AudioEmitter::pos, AudioPortal::pos, Light::pos, process_sdl_event(), ray_intersects_aabb_with_point(), ray_intersects_obb_with_point(), raycast_scene(), SceneData::reflection_probes, running, Globals::scene_data, EditorSettings::selected_asset_instance_id, EditorSettings::selected_audio_emitter_id, EditorSettings::selected_audio_portal_id, EditorSettings::selected_audio_probe_volume_id, EditorSettings::selected_light_id, EditorSettings::selected_lighting_probe_volume_id, EditorSettings::selected_material_mn_id, EditorSettings::selected_mn_id, EditorSettings::selected_r_probe, EditorSettings::selected_sm_id, EditorSettings::SELMODE, SELMODE_AEM, SELMODE_APORTAL, SELMODE_APV, SELMODE_ASSETINSTANCE, SELMODE_ENTITY, SELMODE_LIGHT, SELMODE_LPV, SELMODE_MN, SELMODE_RPROBE, SELMODE_TEXTBOX, SELMODE_UIELEMENT, Mesh::submeshes, vec3_length(), vec3_sub(), wrap_angle_pi(), vec3::x, vec3::y, Camera::yaw, and vec3::z.

Referenced by main(), and process_sdl_event().

◆ process_input()

void process_input ( SDL_Window ** window,
SDL_Event * event_queue,
int * event_queue_count,
SDL_Event * sdl_queue,
int * sdl_queue_count,
float physics_dt )

Receives input from SDL in a while loop, pushes th events onto queues to be consumed at the end of the rendering frame.

Also processes keyboard events.

Parameters
windowThe SDL_Window object
event_queueThe queue for SDL_Events that are not keyboard events that must be consumed once every render frame. For Nuklear.
event_queue_countThe queue count for SDL.
sdl_queueThe queue for SDL_Events that are not keyboard events that must be consumed once every render frame.
physics_dtHow much the cooldown for buttons must decrease (avoids double inputs).

Definition at line 411 of file input.c.

References apply_velocity(), EditorSettings::audio_menu_open, cam, Player::cam, Camera::cam_data, CamData::cam_pos, cooldown_interval, cooldown_time, dt, EditorSettings::editor_menu_open, EDITOR_SETTINGS, GLOBALS, Globals::keyboard_locked, Skeleton::left_leg, EditorSettings::lprobe_menu_open, EditorSettings::main_menu_open, MAX_NUKLEAR_EVENTS, MAX_SDL_EVENTS, MOUSE_X, MOUSE_Y, Skeleton::neck, Skeleton::neck_height, Globals::noclip, Player::noclip, PhysicsComponent::old_vel, Camera::on_ground, Player::pc, perform_newest_redo(), perform_newest_undo(), Camera::pitch, player, Player::pos, process_input(), reset_skeleton(), resolve_collisions(), Skeleton::right_leg, Camera::roll, Spring::rotation, running, EditorSettings::selection_menu_open, SHADERS_INIT(), Player::skeleton, spawn_point, Player::sprinting, toggle_performance_overlay(), EditorSettings::ui_menu_open, update_body_from_legs(), update_skeleton(), vec3_add(), vec3_scale(), vec4_to_vec3(), PhysicsComponent::vel, window, EditorSettings::wireframe_toggled, vec3::x, vec4::x, vec3::y, vec4::y, Camera::yaw, vec3::z, and vec4::z.

Referenced by main(), and process_input().

Variable Documentation

◆ cooldown_time

float cooldown_time = 0.0f

Definition at line 406 of file input.c.

Referenced by process_input().

◆ cooldown_interval

float cooldown_interval = 0.1f

Definition at line 407 of file input.c.

Referenced by process_input().