Graphics v0.0.0
A simple abstraction layer for the modern graphics APIs.
|
游戏手柄. 更多...
#include <Gamepad.h>
Public 类型 | |
enum class | Thumb { left , right } |
手柄摇杆. | |
enum class | Trigger { Trigger::left , Trigger::right } |
手柄线性按键. 更多... | |
enum class | Button : uint8_t { A = 0 , B = 1 , X = 2 , Y = 3 , LeftBumper = 4 , RightBumper = 5 , Back = 6 , Start = 7 , Guide = 8 , LeftThumb = 9 , RightThumb = 10 , DPAD_Up = 11 , DPAD_Right = 12 , DPAD_Down = 13 , DPAD_Left = 14 , Cross = A , Circle = B , Square = X , Triangle = Y } |
手柄按键. | |
using | handle_type = unsigned short |
Public 成员函数 | |
Gamepad (handle_type handle=0) | |
默认构造函数. | |
~Gamepad () | |
默认析构函数. | |
void | update () |
更新数据. | |
Vector2f | get (Thumb thumb) const noexcept |
获取摇杆数据. 更多... | |
Vector2f | get_raw (Thumb thumb) const noexcept |
获取原始摇杆数据. 更多... | |
float | get (Trigger trigger) const noexcept |
获取线性按键力度. 更多... | |
float | get_raw (Trigger trigger) const noexcept |
获取原始线性按键数据. 更多... | |
bool | get (Button button) const noexcept |
获取按键状态. 更多... | |
void | set_vibration (float leftSpeed, float rightSpeed) |
设置震动反馈. 更多... | |
std::string_view | get_name () const |
获取设备名称. 人类可读的, UTF-8 编码. | |
bool | is_connected () const |
检查手柄是否处于连接状态. 更多... | |
bool | load_mappings_db (const std::filesystem::path &path) |
加载 SDL 按键映射数据库. 更多... | |
bool | operator== (const Gamepad &) const |
静态 Public 成员函数 | |
static void | init () |
static void | deinit () |
游戏手柄.
获取手柄的按键状态, 摇杆数据和设备名称.
|
noexcept |
获取按键状态.
button | 按键. |
|
noexcept |
获取摇杆数据.
thumb | 摇杆. |
|
noexcept |
获取线性按键力度.
trigger | 线性按键. |
|
noexcept |
获取原始摇杆数据.
thumb | 摇杆. |
|
noexcept |
获取原始线性按键数据.
trigger | 线性按键. |
bool Gamepad::is_connected | ( | ) | const |
检查手柄是否处于连接状态.
bool Gamepad::load_mappings_db | ( | const std::filesystem::path & | path | ) |
加载 SDL 按键映射数据库.
path | 数据库文件地址. |
void Gamepad::set_vibration | ( | float | leftSpeed, |
float | rightSpeed | ||
) |
设置震动反馈.
leftSpeed | 左马达转速. |
rightSpeed | 右马达转速. |