WVR_GetInputDeviceCapability¶
-
WVR_EXPORT int32_t WVR_GetInputDeviceCapability(WVR_DeviceType type, WVR_InputType inputType)
Function to get the Input Device Capability for WVR_InputType.
- Return
- int32_t, bitmask for WVR_InputId. A value of -1 means an error has occured.
- Version
- API Level 1
- Parameters
type
: Indicate what device to get the capability. (refer to WVR_DeviceType)inputType
: One of WVR_InputType.
How to use¶
Here is an example for the function:
static const std::map<WVR_InputId, const char*> table {
{WVR_InputId_0, "System"},
{WVR_InputId_1, "Menu"},
{WVR_InputId_2, "Grip"},
{WVR_InputId_3, "DPad Left"},
{WVR_InputId_4, "DPad Up"},
{WVR_InputId_5, "DPad Right"},
{WVR_InputId_6, "DPad Down"},
{WVR_InputId_7, "Volume Up"},
{WVR_InputId_8, "Volume Down"},
{WVR_InputId_9, "Digtal Trigger"},
{WVR_InputId_16, "Touchpad"},
{WVR_InputId_17, "Trigger"},
};
// Check what input types the controller supports.
// It will return bitmask for WVR_InputType.
uint32_t right_ctl_button = WVR_GetInputDeviceCapability(WVR_DeviceType_Controller_Right, WVR_InputType_Button);
uint32_t right_ctl_touch = WVR_GetInputDeviceCapability(WVR_DeviceType_Controller_Right, WVR_InputType_Touch);
uint32_t right_ctl_analog = WVR_GetInputDeviceCapability(WVR_DeviceType_Controller_Right, WVR_InputType_Analog);
// Check what kind of buttons the controller supports.
// If supported, check if button state is pressed or not pressed.
for (int i = WVR_InputId_0; i < WVR_InputId_Max; i++) {
if (right_ctl_button & (1 << i)) {
if (WVR_GetInputButtonState(WVR_DeviceType_Controller_Right, static_cast<WVR_InputId>(i))) {
LOGI("%s is pressed", table.at(static_cast<WVR_InputId>(i)));
}
}
}
// Check what kind of touch the controller supports.
// If supported, check if touch state is touched or untouched.
for (int i = WVR_InputId_0; i < WVR_InputId_Max; i++) {
if (right_ctl_touch & (1 << i)) {
if (WVR_GetInputTouchState(WVR_DeviceType_Controller_Right, static_cast<WVR_InputId>(i))) {
LOGI("%s is touchedd", table.at(static_cast<WVR_InputId>(i)));
}
}
}
// Check what kind of analog input the controller supports.
// If supported, print the analog axis value.
for (int i = WVR_InputId_0; i < WVR_InputId_Max; i++) {
if (right_ctl_analog & (1 << i)) {
WVR_Axis_t axis = WVR_GetInputAnalogAxis(WVR_DeviceType_Controller_Right, static_cast<WVR_InputId>(i));
LOGI("%s axis : x= %f, y= %f", table.at(static_cast<WVR_InputId>(i)), axis.x, axis.y);
}
}
How to use bitmask?
- There are 3 types of WVR_InputType: Button, Analog ,and Touch.
- Use the WVR_GetInputDeviceCapability function to check what kind of InputType controller is supported.
- Button:
- WVR_GetInputDeviceCapability(WVR_DeviceType_Controller_Right, WVR_InputType_Button);
If the bitmask shows:
- right_ctl_button: 0000000000000011 0000000000000010
On 1, 16, 17 bits = 1 , the right controller supports a menu button, trigger and touchpad.
- Touch:
- WVR_GetInputDeviceCapability(WVR_DeviceType_Controller_Right, WVR_InputType_Touch);
If the bitmask shows:
- right_ctl_touch: 0000000000000011 0000000000000010
On 1, 16, 17 bits = 1 , the right controller supports a menu button, trigger and touchpad support touch capability.
Analog:
- WVR_GetInputDeviceCapability(WVR_DeviceType_Controller_Right, WVR_InputType_Analog);
If the bitmask shows:
- right_ctl_analog: 0000000000000011 0000000000000000
On 1, 16, 17 bits = 1 , the right controller supports a menu button, trigger and touchpad support analog capability.
- enum
WVR_InputType
¶Input type for the input id.
Values:
WVR_InputType_Button
= 1<<0¶Button input type
WVR_InputType_Touch
= 1<<1¶Touch input type
WVR_InputType_Analog
= 1<<2¶Analog input type
- enum
WVR_InputId
¶The input id of the device.
Values:
WVR_InputId_0
= 0¶
WVR_InputId_1
= 1¶
WVR_InputId_2
= 2¶
WVR_InputId_3
= 3¶
WVR_InputId_4
= 4¶
WVR_InputId_5
= 5¶
WVR_InputId_6
= 6¶
WVR_InputId_7
= 7¶
WVR_InputId_8
= 8¶
WVR_InputId_9
= 9¶
WVR_InputId_10
= 10¶
WVR_InputId_11
= 11¶
WVR_InputId_12
= 12¶
WVR_InputId_13
= 13¶
WVR_InputId_14
= 14¶
WVR_InputId_15
= 15¶
WVR_InputId_16
= 16¶
WVR_InputId_17
= 17¶
WVR_InputId_18
= 18¶
WVR_InputId_19
= 19¶
WVR_InputId_Alias1_System
= WVR_InputId_0¶System button.
WVR_InputId_Alias1_Menu
= WVR_InputId_1¶Menu button.
WVR_InputId_Alias1_Grip
= WVR_InputId_2¶Grip button.
WVR_InputId_Alias1_DPad_Left
= WVR_InputId_3¶A physical DPad_Left button, or simulated by pressing the left part of the touchpad.
WVR_InputId_Alias1_DPad_Up
= WVR_InputId_4¶A physical DPad_Up button, or simulated by pressing the top part of the touchpad.
WVR_InputId_Alias1_DPad_Right
= WVR_InputId_5¶A physical DPad_Right button, or simulated by pressing the right part of the touchpad.
WVR_InputId_Alias1_DPad_Down
= WVR_InputId_6¶A physical DPad_Down button, or simulated by pressing the bottom part of the touchpad.
WVR_InputId_Alias1_Volume_Up
= WVR_InputId_7¶Volume_Up button.
WVR_InputId_Alias1_Volume_Down
= WVR_InputId_8¶Volume_Down button.
WVR_InputId_Alias1_Bumper
= WVR_InputId_9¶Bumper button.
WVR_InputId_Alias1_A
= WVR_InputId_10¶A button.
WVR_InputId_Alias1_B
= WVR_InputId_11¶B button.
WVR_InputId_Alias1_X
= WVR_InputId_12¶X button.
WVR_InputId_Alias1_Y
= WVR_InputId_13¶Y button.
WVR_InputId_Alias1_Back
= WVR_InputId_14¶Hmd Back button
WVR_InputId_Alias1_Enter
= WVR_InputId_15¶Hmd Enter button
WVR_InputId_Alias1_Touchpad
= WVR_InputId_16¶Touchpad input device.
WVR_InputId_Alias1_Trigger
= WVR_InputId_17¶Trigger input device.
WVR_InputId_Alias1_Thumbstick
= WVR_InputId_18¶Thumbstick input device.
WVR_InputId_Alias1_Parking
= WVR_InputId_19¶Parking input device.
WVR_InputId_Max
= 32¶