载入中...
搜索中...
未找到
eve::joystick::sdl::Pad类 参考

SDL joystick/gamepad backend (GameController + optional haptic rumble). 更多...

#include <Pad.h>

类 eve::joystick::sdl::Pad 继承关系图:
eve::joystick::Pad

Public 成员函数

 Pad (int id)
 Creates a closed pad with the given engine id.
 
 Pad (int id, int joyindex)
 Creates a pad and opens SDL device joyindex.
 
 ~Pad () override
 Closes SDL handles and stops rumble.
 
bool open (int deviceindex) override
 Opens the device by SDL joystick device index.
 
void close () override
 Closes joystick and gamecontroller handles.
 
bool isConnected () const override
 True while the underlying device is still connected.
 
std::string getName () const override
 Human-readable device name from the OS/driver.
 
int getAxisCount () const override
 Number of raw joystick axes.
 
int getButtonCount () const override
 Number of raw joystick buttons.
 
int getHatCount () const override
 Number of hat (D-pad) controls.
 
float getAxis (int axisindex) const override
 Normalized axis value in [-1, 1] for a raw axis index.
 
std::vector< float > getAxes () const override
 Snapshot of all raw axis values.
 
std::string getHat (int hatindex) const override
 Hat direction string for a hat index (see class brief).
 
bool isDown (int button) const override
 True if the raw button index is currently pressed.
 
bool isDown (const std::vector< int > &buttons) const override
 True if the raw button index is currently pressed.
 
bool openGamepad (int deviceindex) override
 Opens the device as an SDL GameController.
 
bool isGamepad () const override
 True when a GameController mapping is active for this pad.
 
float getGamepadAxis (const std::string &axis) const override
 Named gamepad axis value (SDL GameController axis string).
 
bool isGamepadDown (const std::string &button) const override
 True if the named gamepad button is pressed.
 
bool isGamepadDown (const std::vector< std::string > &buttons) const override
 True if the named gamepad button is pressed.
 
std::string getGamepadMappingString () const override
 Current SDL GameController mapping string for this device.
 
void * getHandle () const override
 Native handle (SDL_Joystick* / implementation-defined).
 
std::string getGUID () const override
 Stable GUID string for mapping lookup.
 
int getInstanceID () const override
 SDL instance id that stays unique while the device is open.
 
int getID () const override
 Engine-side stable pad id assigned at construction.
 
void getDeviceInfo (int &vendorID, int &productID, int &productVersion) const override
 USB/HID vendor, product, and version ids when available.
 
bool isVibrationSupported () override
 True when haptic/rumble output is available.
 
bool setVibration (float left, float right, float duration=-1.0f) override
 Starts rumble; duration < 0 means until stopped.
 
bool setVibration () override
 Starts rumble; duration < 0 means until stopped.
 
void getVibration (float &left, float &right) override
 Reads the last requested left/right rumble strengths.
 

详细描述

SDL joystick/gamepad backend (GameController + optional haptic rumble).

在文件 Pad.h 第 13 行定义.

构造及析构函数说明

◆ Pad() [1/2]

eve::joystick::sdl::Pad::Pad ( int  id)
explicit

Creates a closed pad with the given engine id.

在文件 Pad.cpp 第 33 行定义.

◆ Pad() [2/2]

eve::joystick::sdl::Pad::Pad ( int  id,
int  joyindex 
)

Creates a pad and opens SDL device joyindex.

在文件 Pad.cpp 第 35 行定义.

引用了 open().

◆ ~Pad()

eve::joystick::sdl::Pad::~Pad ( )
overridevirtual

Closes SDL handles and stops rumble.

重载 eve::joystick::Pad .

在文件 Pad.cpp 第 39 行定义.

引用了 close().

成员函数说明

◆ close()

void eve::joystick::sdl::Pad::close ( )
overridevirtual

Closes joystick and gamecontroller handles.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 65 行定义.

被这些函数引用 open() , 以及 ~Pad().

◆ getAxes()

std::vector< float > eve::joystick::sdl::Pad::getAxes ( ) const
overridevirtual

Snapshot of all raw axis values.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 102 行定义.

引用了 eve::joystick::clampAxis(), count, getAxisCount() , 以及 isConnected().

◆ getAxis()

float eve::joystick::sdl::Pad::getAxis ( int  axisindex) const
overridevirtual

Normalized axis value in [-1, 1] for a raw axis index.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 97 行定义.

引用了 eve::joystick::clampAxis(), getAxisCount() , 以及 isConnected().

◆ getAxisCount()

int eve::joystick::sdl::Pad::getAxisCount ( ) const
overridevirtual

Number of raw joystick axes.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 85 行定义.

引用了 isConnected().

被这些函数引用 getAxes() , 以及 getAxis().

◆ getButtonCount()

int eve::joystick::sdl::Pad::getButtonCount ( ) const
overridevirtual

Number of raw joystick buttons.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 89 行定义.

引用了 isConnected().

被这些函数引用 isDown().

◆ getDeviceInfo()

void eve::joystick::sdl::Pad::getDeviceInfo ( int &  vendorID,
int &  productID,
int &  productVersion 
) const
overridevirtual

USB/HID vendor, product, and version ids when available.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 202 行定义.

◆ getGamepadAxis()

float eve::joystick::sdl::Pad::getGamepadAxis ( const std::string &  axis) const
overridevirtual

Named gamepad axis value (SDL GameController axis string).

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 147 行定义.

引用了 eve::joystick::clampAxis(), isConnected(), isGamepad() , 以及 value.

◆ getGamepadMappingString()

std::string eve::joystick::sdl::Pad::getGamepadMappingString ( ) const
overridevirtual

Current SDL GameController mapping string for this device.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 169 行定义.

◆ getGUID()

std::string eve::joystick::sdl::Pad::getGUID ( ) const
overridevirtual

Stable GUID string for mapping lookup.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 190 行定义.

◆ getHandle()

void * eve::joystick::sdl::Pad::getHandle ( ) const
overridevirtual

Native handle (SDL_Joystick* / implementation-defined).

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 186 行定义.

◆ getHat()

std::string eve::joystick::sdl::Pad::getHat ( int  hatindex) const
overridevirtual

Hat direction string for a hat index (see class brief).

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 112 行定义.

引用了 getHatCount() , 以及 isConnected().

◆ getHatCount()

int eve::joystick::sdl::Pad::getHatCount ( ) const
overridevirtual

Number of hat (D-pad) controls.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 93 行定义.

引用了 isConnected().

被这些函数引用 getHat().

◆ getID()

int eve::joystick::sdl::Pad::getID ( ) const
overridevirtual

Engine-side stable pad id assigned at construction.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 198 行定义.

◆ getInstanceID()

int eve::joystick::sdl::Pad::getInstanceID ( ) const
overridevirtual

SDL instance id that stays unique while the device is open.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 194 行定义.

◆ getName()

std::string eve::joystick::sdl::Pad::getName ( ) const
overridevirtual

Human-readable device name from the OS/driver.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 81 行定义.

◆ getVibration()

void eve::joystick::sdl::Pad::getVibration ( float &  left,
float &  right 
)
overridevirtual

Reads the last requested left/right rumble strengths.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 322 行定义.

引用了 left, right, SDL_TICKS_PASSED , 以及 setVibration().

◆ isConnected()

bool eve::joystick::sdl::Pad::isConnected ( ) const
overridevirtual

True while the underlying device is still connected.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 77 行定义.

被这些函数引用 getAxes(), getAxis(), getAxisCount(), getButtonCount(), getGamepadAxis(), getHat(), getHatCount(), isDown(), isGamepadDown() , 以及 open().

◆ isDown() [1/2]

bool eve::joystick::sdl::Pad::isDown ( const std::vector< int > &  buttons) const
overridevirtual

True if the raw button index is currently pressed.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 121 行定义.

引用了 getButtonCount() , 以及 isConnected().

◆ isDown() [2/2]

bool eve::joystick::sdl::Pad::isDown ( int  button) const
overridevirtual

True if the raw button index is currently pressed.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 117 行定义.

引用了 isDown().

被这些函数引用 isDown().

◆ isGamepad()

bool eve::joystick::sdl::Pad::isGamepad ( ) const
overridevirtual

True when a GameController mapping is active for this pad.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 143 行定义.

被这些函数引用 getGamepadAxis(), isGamepadDown(), isVibrationSupported(), openGamepad() , 以及 setVibration().

◆ isGamepadDown() [1/2]

bool eve::joystick::sdl::Pad::isGamepadDown ( const std::string &  button) const
overridevirtual

True if the named gamepad button is pressed.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 155 行定义.

引用了 isGamepadDown().

被这些函数引用 isGamepadDown().

◆ isGamepadDown() [2/2]

bool eve::joystick::sdl::Pad::isGamepadDown ( const std::vector< std::string > &  buttons) const
overridevirtual

True if the named gamepad button is pressed.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 159 行定义.

引用了 isConnected(), isGamepad() , 以及 name.

◆ isVibrationSupported()

bool eve::joystick::sdl::Pad::isVibrationSupported ( )
overridevirtual

True when haptic/rumble output is available.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 231 行定义.

引用了 isGamepad().

◆ open()

bool eve::joystick::sdl::Pad::open ( int  deviceindex)
overridevirtual

Opens the device by SDL joystick device index.

返回
false on failure.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 43 行定义.

引用了 close(), isConnected() , 以及 openGamepad().

被这些函数引用 Pad().

◆ openGamepad()

bool eve::joystick::sdl::Pad::openGamepad ( int  deviceindex)
overridevirtual

Opens the device as an SDL GameController.

返回
false on failure.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 131 行定义.

引用了 isGamepad().

被这些函数引用 open().

◆ setVibration() [1/2]

bool eve::joystick::sdl::Pad::setVibration ( )
overridevirtual

Starts rumble; duration < 0 means until stopped.

返回
false if unsupported.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 314 行定义.

被这些函数引用 getVibration() , 以及 setVibration().

◆ setVibration() [2/2]

bool eve::joystick::sdl::Pad::setVibration ( float  left,
float  right,
float  duration = -1.0f 
)
overridevirtual

Starts rumble; duration < 0 means until stopped.

返回
false if unsupported.

实现了 eve::joystick::Pad.

在文件 Pad.cpp 第 253 行定义.

引用了 duration, isGamepad(), left, length, right, setVibration() , 以及 strength.


该类的文档由以下文件生成:
  • src/modules/joystick/sdl/Pad.h
  • src/modules/joystick/sdl/Pad.cpp