IOS7: Trigger joystick presses only once for buttons A and B
All buttons and triggers on MFi game controllers are pressure sensitive which means that when pressing buttons the registered valueChangedHandler function is called multiple times providing updates on the pressure value the button is pressed with. This causes multiple kInputJoystickButtonDown events to be sent to the EventManager. In adventure games the pressure value is not relevant and could cause problems for the user that it triggers multiple presses on e.g. the B button which often is mapped to the right mouse button. In some games a click on the right mouse button changes what action that should be performed. Keep track on if the joystick buttons A or B (often mapped as left and right mouse buttons) are being pressed. If the button is already pressed do not add a new event until the button isn't pressed anymore. To not interfere with any open dialog, don't send key events while the keyboard is visible.
This commit is contained in:
parent
8a2a6aa197
commit
b2b2d2cf9f
1 changed files with 24 additions and 1 deletions
|
@ -117,7 +117,30 @@
|
|||
}
|
||||
|
||||
- (void)handleJoystickButtonAction:(int)button isPressed:(bool)pressed {
|
||||
[view addEvent:InternalEvent(pressed ? kInputJoystickButtonDown : kInputJoystickButtonUp, button, 0)];
|
||||
bool addEvent = true;
|
||||
if (button == Common::JOYSTICK_BUTTON_A) {
|
||||
if (_firstButtonPressed) {
|
||||
if (pressed) {
|
||||
addEvent = false;
|
||||
}
|
||||
}
|
||||
_firstButtonPressed = pressed;
|
||||
} else if (button == Common::JOYSTICK_BUTTON_B) {
|
||||
if (_secondButtonPressed) {
|
||||
if (pressed) {
|
||||
addEvent = false;
|
||||
}
|
||||
}
|
||||
_secondButtonPressed = pressed;
|
||||
}
|
||||
// Do not send button presses if keyboard is shown because if e.g.
|
||||
// the "Do you want to quit?" dialog is shown the wait for user
|
||||
// input will end (treating the button push as a mouse click) while
|
||||
// the user tried to select the "y" or "n" character on the tvOS
|
||||
// keyboard.
|
||||
if (addEvent && ![view isKeyboardShown]) {
|
||||
[view addEvent:InternalEvent(pressed ? kInputJoystickButtonDown : kInputJoystickButtonUp, button, 0)];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue