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

One connected (or previously connected) joystick / gamepad device. Gamepad axis/button names follow SDL GameController strings (e.g. "leftx", "a", "dpup"). Hat directions: c/u/d/l/r/lu/ld/ru/rd. 更多...

#include <Pad.h>

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

Public 成员函数

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

详细描述

One connected (or previously connected) joystick / gamepad device. Gamepad axis/button names follow SDL GameController strings (e.g. "leftx", "a", "dpup"). Hat directions: c/u/d/l/r/lu/ld/ru/rd.

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

构造及析构函数说明

◆ ~Pad()

virtual eve::joystick::Pad::~Pad ( )
virtualdefault

Releases device handles; safe to call when already closed.

被 eve::joystick::sdl::Pad 重载.

成员函数说明

◆ close()

virtual void eve::joystick::Pad::close ( )
pure virtual

Closes joystick and gamecontroller handles.

在 eve::joystick::sdl::Pad 内被实现.

◆ getAxes()

virtual std::vector< float > eve::joystick::Pad::getAxes ( ) const
pure virtual

Snapshot of all raw axis values.

在 eve::joystick::sdl::Pad 内被实现.

◆ getAxis()

virtual float eve::joystick::Pad::getAxis ( int  axisindex) const
pure virtual

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

在 eve::joystick::sdl::Pad 内被实现.

◆ getAxisCount()

virtual int eve::joystick::Pad::getAxisCount ( ) const
pure virtual

Number of raw joystick axes.

在 eve::joystick::sdl::Pad 内被实现.

◆ getButtonCount()

virtual int eve::joystick::Pad::getButtonCount ( ) const
pure virtual

Number of raw joystick buttons.

在 eve::joystick::sdl::Pad 内被实现.

◆ getDeviceInfo()

virtual void eve::joystick::Pad::getDeviceInfo ( int &  vendorID,
int &  productID,
int &  productVersion 
) const
pure virtual

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

在 eve::joystick::sdl::Pad 内被实现.

◆ getGamepadAxis()

virtual float eve::joystick::Pad::getGamepadAxis ( const std::string &  axis) const
pure virtual

Named gamepad axis value (SDL GameController axis string).

在 eve::joystick::sdl::Pad 内被实现.

◆ getGamepadMappingString()

virtual std::string eve::joystick::Pad::getGamepadMappingString ( ) const
pure virtual

Current SDL GameController mapping string for this device.

在 eve::joystick::sdl::Pad 内被实现.

◆ getGUID()

virtual std::string eve::joystick::Pad::getGUID ( ) const
pure virtual

Stable GUID string for mapping lookup.

在 eve::joystick::sdl::Pad 内被实现.

◆ getHandle()

virtual void * eve::joystick::Pad::getHandle ( ) const
pure virtual

Native handle (SDL_Joystick* / implementation-defined).

在 eve::joystick::sdl::Pad 内被实现.

◆ getHat()

virtual std::string eve::joystick::Pad::getHat ( int  hatindex) const
pure virtual

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

在 eve::joystick::sdl::Pad 内被实现.

◆ getHatCount()

virtual int eve::joystick::Pad::getHatCount ( ) const
pure virtual

Number of hat (D-pad) controls.

在 eve::joystick::sdl::Pad 内被实现.

◆ getID()

virtual int eve::joystick::Pad::getID ( ) const
pure virtual

Engine-side stable pad id assigned at construction.

在 eve::joystick::sdl::Pad 内被实现.

◆ getInstanceID()

virtual int eve::joystick::Pad::getInstanceID ( ) const
pure virtual

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

在 eve::joystick::sdl::Pad 内被实现.

◆ getName()

virtual std::string eve::joystick::Pad::getName ( ) const
pure virtual

Human-readable device name from the OS/driver.

在 eve::joystick::sdl::Pad 内被实现.

◆ getVibration()

virtual void eve::joystick::Pad::getVibration ( float &  left,
float &  right 
)
pure virtual

Reads the last requested left/right rumble strengths.

在 eve::joystick::sdl::Pad 内被实现.

◆ isConnected()

virtual bool eve::joystick::Pad::isConnected ( ) const
pure virtual

True while the underlying device is still connected.

在 eve::joystick::sdl::Pad 内被实现.

◆ isDown() [1/2]

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

True if any of the raw button indices is currently pressed.

在 eve::joystick::sdl::Pad 内被实现.

◆ isDown() [2/2]

virtual bool eve::joystick::Pad::isDown ( int  button) const
pure virtual

True if the raw button index is currently pressed.

在 eve::joystick::sdl::Pad 内被实现.

◆ isGamepad()

virtual bool eve::joystick::Pad::isGamepad ( ) const
pure virtual

True when a GameController mapping is active for this pad.

在 eve::joystick::sdl::Pad 内被实现.

◆ isGamepadDown() [1/2]

virtual bool eve::joystick::Pad::isGamepadDown ( const std::string &  button) const
pure virtual

True if the named gamepad button is pressed.

在 eve::joystick::sdl::Pad 内被实现.

◆ isGamepadDown() [2/2]

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

True if any of the named gamepad buttons is pressed.

在 eve::joystick::sdl::Pad 内被实现.

◆ isVibrationSupported()

virtual bool eve::joystick::Pad::isVibrationSupported ( )
pure virtual

True when haptic/rumble output is available.

在 eve::joystick::sdl::Pad 内被实现.

◆ open()

virtual bool eve::joystick::Pad::open ( int  deviceindex)
pure virtual

Opens the device by SDL joystick device index.

返回
false on failure.

在 eve::joystick::sdl::Pad 内被实现.

◆ openGamepad()

virtual bool eve::joystick::Pad::openGamepad ( int  deviceindex)
pure virtual

Opens the device as an SDL GameController.

返回
false on failure.

在 eve::joystick::sdl::Pad 内被实现.

◆ setVibration() [1/2]

virtual bool eve::joystick::Pad::setVibration ( )
pure virtual

Stops active rumble.

在 eve::joystick::sdl::Pad 内被实现.

◆ setVibration() [2/2]

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

Starts rumble; duration < 0 means until stopped.

返回
false if unsupported.

在 eve::joystick::sdl::Pad 内被实现.


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