MiMoEngine ASM: x86-64 MASM汇编+C混合架构游戏引擎
核心热路径(数学/内存/字符串/性能分析)用MASM汇编(SSE/AVX2) 外围系统(窗口/渲染/ECS/音频/UI/脚本)用C语言 含自研编辑器、VisualScript积木编程、中文渲染(glyph_atlas)
This commit is contained in:
commit
2d56cb3bc9
91 files changed
+9988
No files matched your search
@@ -0,0 +1,88 @@
|
||||
#pragma once
|
||||
|
||||
// ============================================================================
|
||||
// input.h - 输入管理 (键盘/鼠标/手柄)
|
||||
// ============================================================================
|
||||
|
||||
#include <Windows.h>
|
||||
#include <Xinput.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#pragma comment(lib, "xinput.lib")
|
||||
|
||||
// 键盘状态
|
||||
#define MAX_KEYS 256
|
||||
|
||||
// 鼠标按钮
|
||||
#define MOUSE_LEFT 0
|
||||
#define MOUSE_RIGHT 1
|
||||
#define MOUSE_MIDDLE 2
|
||||
|
||||
// 手柄按钮
|
||||
#define GAMEPAD_A XINPUT_GAMEPAD_A
|
||||
#define GAMEPAD_B XINPUT_GAMEPAD_B
|
||||
#define GAMEPAD_X XINPUT_GAMEPAD_X
|
||||
#define GAMEPAD_Y XINPUT_GAMEPAD_Y
|
||||
#define GAMEPAD_START XINPUT_GAMEPAD_START
|
||||
#define GAMEPAD_BACK XINPUT_GAMEPAD_BACK
|
||||
#define GAMEPAD_LB XINPUT_GAMEPAD_LEFT_SHOULDER
|
||||
#define GAMEPAD_RB XINPUT_GAMEPAD_RIGHT_SHOULDER
|
||||
#define GAMEPAD_LTHUMB XINPUT_GAMEPAD_LEFT_THUMB
|
||||
#define GAMEPAD_RTHUMB XINPUT_GAMEPAD_RIGHT_THUMB
|
||||
#define GAMEPAD_UP XINPUT_GAMEPAD_DPAD_UP
|
||||
#define GAMEPAD_DOWN XINPUT_GAMEPAD_DPAD_DOWN
|
||||
#define GAMEPAD_LEFT XINPUT_GAMEPAD_DPAD_LEFT
|
||||
#define GAMEPAD_RIGHT XINPUT_GAMEPAD_DPAD_RIGHT
|
||||
|
||||
typedef struct {
|
||||
int key_states[MAX_KEYS];
|
||||
int key_prev[MAX_KEYS];
|
||||
|
||||
int mouse_x, mouse_y;
|
||||
int mouse_dx, mouse_dy;
|
||||
int mouse_scroll;
|
||||
int mouse_buttons[3];
|
||||
int mouse_prev[3];
|
||||
|
||||
XINPUT_STATE gamepad_state;
|
||||
XINPUT_STATE gamepad_prev;
|
||||
int gamepad_connected;
|
||||
|
||||
float deadzone;
|
||||
} Input;
|
||||
|
||||
// 创建/销毁
|
||||
Input* input_create(void);
|
||||
void input_destroy(Input* input);
|
||||
|
||||
// 更新 (每帧调用)
|
||||
void input_update(Input* input);
|
||||
|
||||
// Win32 消息处理
|
||||
void input_process_key(Input* input, int key, int down);
|
||||
void input_process_mouse_move(Input* input, int x, int y);
|
||||
void input_process_mouse_button(Input* input, int button, int down);
|
||||
void input_process_mouse_wheel(Input* input, int delta);
|
||||
|
||||
// 键盘查询
|
||||
int input_key_down(Input* input, int key);
|
||||
int input_key_pressed(Input* input, int key);
|
||||
int input_key_released(Input* input, int key);
|
||||
|
||||
// 鼠标查询
|
||||
int input_mouse_button(Input* input, int button);
|
||||
int input_mouse_button_pressed(Input* input, int button);
|
||||
void input_get_mouse_pos(Input* input, int* x, int* y);
|
||||
void input_get_mouse_delta(Input* input, int* dx, int* dy);
|
||||
int input_get_mouse_scroll(Input* input);
|
||||
|
||||
// 手柄查询
|
||||
int input_gamepad_connected(Input* input);
|
||||
float input_gamepad_axis_lx(Input* input);
|
||||
float input_gamepad_axis_ly(Input* input);
|
||||
float input_gamepad_axis_rx(Input* input);
|
||||
float input_gamepad_axis_ry(Input* input);
|
||||
float input_gamepad_trigger_l(Input* input);
|
||||
float input_gamepad_trigger_r(Input* input);
|
||||
int input_gamepad_button(Input* input, uint16_t button);
|
||||
int input_gamepad_button_pressed(Input* input, uint16_t button);
|
||||
Reference in new issue
Block a user