Controller fixes.
Fix joystick dpad emulation diagonal direction. Always activate an action set by default.merge-requests/48/head
parent
5533a9d5b0
commit
f6b8068883
|
@ -91,6 +91,7 @@ enum EXTRA_GAMEPAD_BUTTONS {
|
||||||
|
|
||||||
#define JOY_ID_START 10
|
#define JOY_ID_START 10
|
||||||
#define STICK_DPAD 3
|
#define STICK_DPAD 3
|
||||||
|
#define DEADZONE_BUTTON_STICK 0.3
|
||||||
|
|
||||||
class Steam_Controller :
|
class Steam_Controller :
|
||||||
public ISteamController001,
|
public ISteamController001,
|
||||||
|
@ -332,9 +333,9 @@ bool Init(bool bExplicitlyCallRunFrame)
|
||||||
|
|
||||||
for (int i = 1; i < 5; ++i) {
|
for (int i = 1; i < 5; ++i) {
|
||||||
struct Controller_Action cont_action(i);
|
struct Controller_Action cont_action(i);
|
||||||
//Activate the action set if there is only one present.
|
//Activate the first action set.
|
||||||
//TODO: I don't know if one gets activated by default when there's more than one
|
//TODO: check exactly what decides which gets activated by default
|
||||||
if (action_handles.size() == 1) {
|
if (action_handles.size() >= 1) {
|
||||||
cont_action.activate_action_set(action_handles.begin()->second, controller_maps);
|
cont_action.activate_action_set(action_handles.begin()->second, controller_maps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,6 +523,7 @@ void ActivateActionSet( ControllerHandle_t controllerHandle, ControllerActionSet
|
||||||
|
|
||||||
ControllerActionSetHandle_t GetCurrentActionSet( ControllerHandle_t controllerHandle )
|
ControllerActionSetHandle_t GetCurrentActionSet( ControllerHandle_t controllerHandle )
|
||||||
{
|
{
|
||||||
|
//TODO: should return zero if no action set specifically activated with ActivateActionSet
|
||||||
PRINT_DEBUG("Steam_Controller::GetCurrentActionSet %llu\n", controllerHandle);
|
PRINT_DEBUG("Steam_Controller::GetCurrentActionSet %llu\n", controllerHandle);
|
||||||
auto controller = controllers.find(controllerHandle);
|
auto controller = controllers.find(controllerHandle);
|
||||||
if (controller == controllers.end()) return 0;
|
if (controller == controllers.end()) return 0;
|
||||||
|
@ -606,17 +608,31 @@ ControllerDigitalActionData_t GetDigitalActionData( ControllerHandle_t controlle
|
||||||
case BUTTON_STICK_LEFT_UP:
|
case BUTTON_STICK_LEFT_UP:
|
||||||
case BUTTON_STICK_LEFT_DOWN:
|
case BUTTON_STICK_LEFT_DOWN:
|
||||||
case BUTTON_STICK_LEFT_LEFT:
|
case BUTTON_STICK_LEFT_LEFT:
|
||||||
case BUTTON_STICK_LEFT_RIGHT:
|
case BUTTON_STICK_LEFT_RIGHT: {
|
||||||
pressed = GamepadStickLength(device, STICK_LEFT) > 0.1 &&
|
float x = 0, y = 0, len = GamepadStickLength(device, STICK_LEFT);
|
||||||
((int)GamepadStickDir(device, STICK_LEFT) == ((button - BUTTON_STICK_LEFT_UP) + 1));
|
GamepadStickNormXY(device, STICK_LEFT, &x, &y);
|
||||||
|
x *= len;
|
||||||
|
y *= len;
|
||||||
|
if (button == BUTTON_STICK_LEFT_UP) pressed = y > DEADZONE_BUTTON_STICK;
|
||||||
|
if (button == BUTTON_STICK_LEFT_DOWN) pressed = y < -DEADZONE_BUTTON_STICK;
|
||||||
|
if (button == BUTTON_STICK_LEFT_RIGHT) pressed = x > DEADZONE_BUTTON_STICK;
|
||||||
|
if (button == BUTTON_STICK_LEFT_LEFT) pressed = x < -DEADZONE_BUTTON_STICK;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case BUTTON_STICK_RIGHT_UP:
|
case BUTTON_STICK_RIGHT_UP:
|
||||||
case BUTTON_STICK_RIGHT_DOWN:
|
case BUTTON_STICK_RIGHT_DOWN:
|
||||||
case BUTTON_STICK_RIGHT_LEFT:
|
case BUTTON_STICK_RIGHT_LEFT:
|
||||||
case BUTTON_STICK_RIGHT_RIGHT:
|
case BUTTON_STICK_RIGHT_RIGHT: {
|
||||||
pressed = GamepadStickLength(device, STICK_RIGHT) > 0.1 &&
|
float x = 0, y = 0, len = GamepadStickLength(device, STICK_RIGHT);
|
||||||
((int)GamepadStickDir(device, STICK_RIGHT) == ((button - BUTTON_STICK_RIGHT_UP) + 1));
|
GamepadStickNormXY(device, STICK_RIGHT, &x, &y);
|
||||||
|
x *= len;
|
||||||
|
y *= len;
|
||||||
|
if (button == BUTTON_STICK_RIGHT_UP) pressed = y > DEADZONE_BUTTON_STICK;
|
||||||
|
if (button == BUTTON_STICK_RIGHT_DOWN) pressed = y < -DEADZONE_BUTTON_STICK;
|
||||||
|
if (button == BUTTON_STICK_RIGHT_RIGHT) pressed = x > DEADZONE_BUTTON_STICK;
|
||||||
|
if (button == BUTTON_STICK_RIGHT_LEFT) pressed = x < -DEADZONE_BUTTON_STICK;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue