Artifact 04826670236b3db0a10679530a12b84e05aa3086fa8f1f3e4df7d75aa36befe9:
- File
src/hid/OHEvdevPlayStationExtendedGamepad.m
— part of check-in
[998339ff24]
at
2024-06-09 11:43:49
on branch trunk
— OHGamepad: Move some elements to OHExtendedGamepad
This allows to have a profile for limited gamepads such as found on the
Nintendo DS rather than only having the raw profile for those. (user: js, size: 2670) [annotate] [blame] [check-ins using]
/* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "OHEvdevPlayStationExtendedGamepad.h" #import "OFDictionary.h" #import "OHGameControllerEmulatedTriggerButton.h" @implementation OHEvdevPlayStationExtendedGamepad - (OFDictionary OF_GENERIC(OFString *, OHGameControllerButton *) *)buttons { OFMutableDictionary *buttons = [[_rawProfile.buttons mutableCopy] autorelease]; [buttons setObject: self.leftTriggerButton forKey: @"L2"]; [buttons setObject: self.rightTriggerButton forKey: @"R2"]; [buttons makeImmutable]; return buttons; } - (OHGameControllerButton *)northButton { return [_rawProfile.buttons objectForKey: @"Triangle"]; } - (OHGameControllerButton *)southButton { return [_rawProfile.buttons objectForKey: @"Cross"]; } - (OHGameControllerButton *)westButton { return [_rawProfile.buttons objectForKey: @"Square"]; } - (OHGameControllerButton *)eastButton { return [_rawProfile.buttons objectForKey: @"Circle"]; } - (OHGameControllerButton *)leftShoulderButton { return [_rawProfile.buttons objectForKey: @"L1"]; } - (OHGameControllerButton *)rightShoulderButton { return [_rawProfile.buttons objectForKey: @"R1"]; } - (OHGameControllerButton *)leftTriggerButton { return [[[OHGameControllerEmulatedTriggerButton alloc] initWithName: @"L2" axis: [_rawProfile.axes objectForKey: @"Z"]] autorelease]; } - (OHGameControllerButton *)rightTriggerButton { return [[[OHGameControllerEmulatedTriggerButton alloc] initWithName: @"R2" axis: [_rawProfile.axes objectForKey: @"RZ"]] autorelease]; } - (OHGameControllerButton *)leftThumbstickButton { return [_rawProfile.buttons objectForKey: @"L3"]; } - (OHGameControllerButton *)rightThumbstickButton { return [_rawProfile.buttons objectForKey: @"R3"]; } - (OHGameControllerButton *)menuButton { return [_rawProfile.buttons objectForKey: @"Options"]; } - (OHGameControllerButton *)homeButton { return [_rawProfile.buttons objectForKey: @"PS"]; } @end