Overview
Comment: | ObjFWHID: Add profile for extended N64 controller |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
cb71b05d78bbf8cdd2f16957afecedff |
User & Date: | js on 2024-06-18 22:13:14 |
Other Links: | manifest | tags |
Context
2024-06-18
| ||
22:15 | OHN64Controller: Rename C-Pad to C-Buttons check-in: be7f15e75f user: js tags: trunk | |
22:13 | ObjFWHID: Add profile for extended N64 controller check-in: cb71b05d78 user: js tags: trunk | |
2024-06-17
| ||
21:13 | Remove trailing whitespaces check-in: b18c1fd0ea user: js tags: trunk | |
Changes
Modified src/hid/Makefile from [e11835f6dd] to [9ac3135daf].
︙ | ︙ | |||
23 24 25 26 27 28 29 30 31 32 33 34 35 36 | ObjFWHID.h SRCS += OHDualSenseGamepad.m \ OHDualShock4Gamepad.m \ OHEmulatedGameControllerAxis.m \ OHEmulatedGameControllerButton.m \ OHEmulatedGameControllerTriggerButton.m \ OHStadiaGamepad.m \ OHXboxGamepad.m \ ${USE_SRCS_EVDEV} \ ${USE_SRCS_NINTENDO_3DS} \ ${USE_SRCS_NINTENDO_DS} \ ${USE_SRCS_NINTENDO_SWITCH} \ ${USE_SRCS_WII} \ | > > | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ObjFWHID.h SRCS += OHDualSenseGamepad.m \ OHDualShock4Gamepad.m \ OHEmulatedGameControllerAxis.m \ OHEmulatedGameControllerButton.m \ OHEmulatedGameControllerTriggerButton.m \ OHExtendedN64Controller.m \ OHN64Controller.m \ OHStadiaGamepad.m \ OHXboxGamepad.m \ ${USE_SRCS_EVDEV} \ ${USE_SRCS_NINTENDO_3DS} \ ${USE_SRCS_NINTENDO_DS} \ ${USE_SRCS_NINTENDO_SWITCH} \ ${USE_SRCS_WII} \ |
︙ | ︙ |
Modified src/hid/OHEvdevGameController.m from [758671613d] to [7e3c50d414].
︙ | ︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #import "OFFileManager.h" #import "OFLocale.h" #import "OFNumber.h" #import "OHDualSenseGamepad.h" #import "OHDualShock4Gamepad.h" #import "OHEvdevExtendedGamepad.h" #import "OHGameControllerAxis+Private.h" #import "OHGameControllerAxis.h" #import "OHGameControllerButton.h" #import "OHGameControllerProfile.h" #import "OHStadiaGamepad.h" #include <sys/ioctl.h> | > | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #import "OFFileManager.h" #import "OFLocale.h" #import "OFNumber.h" #import "OHDualSenseGamepad.h" #import "OHDualShock4Gamepad.h" #import "OHEvdevExtendedGamepad.h" #import "OHExtendedN64Controller.h" #import "OHGameControllerAxis+Private.h" #import "OHGameControllerAxis.h" #import "OHGameControllerButton.h" #import "OHGameControllerProfile.h" #import "OHStadiaGamepad.h" #include <sys/ioctl.h> |
︙ | ︙ | |||
199 200 201 202 203 204 205 206 207 208 209 210 211 212 | if (_vendorID == OHVendorIDSony && _productID == OHProductIDDualSense) _profile = [[OHDualSenseGamepad alloc] init]; else if (_vendorID == OHVendorIDSony && _productID == OHProductIDDualShock4) _profile = [[OHDualShock4Gamepad alloc] init]; else if (_vendorID == OHVendorIDGoogle && _productID == OHProductIDStadiaController) _profile = [[OHStadiaGamepad alloc] init]; else _profile = [[OHEvdevExtendedGamepad alloc] initWithKeyBits: _keyBits evBits: _evBits | > > > | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | if (_vendorID == OHVendorIDSony && _productID == OHProductIDDualSense) _profile = [[OHDualSenseGamepad alloc] init]; else if (_vendorID == OHVendorIDSony && _productID == OHProductIDDualShock4) _profile = [[OHDualShock4Gamepad alloc] init]; else if (_vendorID == OHVendorIDNintendo && _productID == OHProductIDN64Controller) _profile = [[OHExtendedN64Controller alloc] init]; else if (_vendorID == OHVendorIDGoogle && _productID == OHProductIDStadiaController) _profile = [[OHStadiaGamepad alloc] init]; else _profile = [[OHEvdevExtendedGamepad alloc] initWithKeyBits: _keyBits evBits: _evBits |
︙ | ︙ |
Modified src/hid/OHEvdevGameControllerProfile.m from [9b605a4be7] to [566139f646].
︙ | ︙ | |||
69 70 71 72 73 74 75 | case BTN_MODE: return @"Home"; case BTN_TL: return @"SL"; case BTN_TL2: return @"SR"; } | < < < < < < < < < < < < < < < < < < < < < < < < | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | case BTN_MODE: return @"Home"; case BTN_TL: return @"SL"; case BTN_TL2: return @"SR"; } } switch (button) { case BTN_A: return @"A"; case BTN_B: return @"B"; |
︙ | ︙ |
Added src/hid/OHExtendedN64Controller.h version [1d023dc5ed].
> > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * 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/>. */ #import "OHN64Controller.h" OF_ASSUME_NONNULL_BEGIN @interface OHExtendedN64Controller: OHN64Controller @end OF_ASSUME_NONNULL_END |
Added src/hid/OHExtendedN64Controller.m version [3611333b7c].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | /* * 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 "OHExtendedN64Controller.h" #import "OFDictionary.h" #import "OHGameControllerButton.h" #if defined(OF_LINUX) && defined(OF_HAVE_FILES) # include <linux/input.h> #endif static OFString *const buttonNames[] = { @"ZR", @"Home", @"Capture" }; static const size_t numButtons = sizeof(buttonNames) / sizeof(*buttonNames); @implementation OHExtendedN64Controller - (instancetype)init { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); OFMutableDictionary *buttons = [[_buttons mutableCopy] autorelease]; for (size_t i = 0; i < numButtons; i++) { OHGameControllerButton *button = [[[OHGameControllerButton alloc] initWithName: buttonNames[i]] autorelease]; [buttons setObject: button forKey: buttonNames[i]]; } [buttons makeImmutable]; [_buttons release]; _buttons = [buttons retain]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } #if defined(OF_LINUX) && defined(OF_HAVE_FILES) - (OHGameControllerButton *)oh_buttonForEvdevButton: (uint16_t)button { switch (button) { case BTN_TR2: return [_buttons objectForKey: @"ZR"]; case BTN_MODE: return [_buttons objectForKey: @"Home"]; case BTN_Z: return [_buttons objectForKey: @"Capture"]; } return [super oh_buttonForEvdevButton: button]; } #endif @end |
Added src/hid/OHN64Controller.h version [635752411f].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | /* * 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/>. */ #import "OHGameControllerProfile.h" #if defined(OF_LINUX) && defined(OF_HAVE_FILES) # import "OHEvdevGameController.h" #endif OF_ASSUME_NONNULL_BEGIN @interface OHN64Controller: OFObject <OHGameControllerProfile #if defined(OF_LINUX) && defined(OF_HAVE_FILES) , OHEvdevMapping #endif > { OFDictionary OF_GENERIC(OFString *, OHGameControllerButton *) *_buttons; OFDictionary OF_GENERIC(OFString *, OHGameControllerDirectionalPad *) *_directionalPads; } @end OF_ASSUME_NONNULL_END |
Added src/hid/OHN64Controller.m version [fae6195d95].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | /* * 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 "OHN64Controller.h" #import "OFDictionary.h" #import "OHGameControllerAxis.h" #import "OHGameControllerButton.h" #import "OHGameControllerDirectionalPad.h" #if defined(OF_LINUX) && defined(OF_HAVE_FILES) # include <linux/input.h> #endif static OFString *const buttonNames[] = { @"A", @"B", @"L", @"R", @"Z", @"Start" }; static const size_t numButtons = sizeof(buttonNames) / sizeof(*buttonNames); @implementation OHN64Controller @synthesize buttons = _buttons, directionalPads = _directionalPads; - (instancetype)init { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); OFMutableDictionary *buttons = [OFMutableDictionary dictionaryWithCapacity: numButtons]; OFMutableDictionary *directionalPads; OHGameControllerAxis *xAxis, *yAxis; OHGameControllerDirectionalPad *directionalPad; OHGameControllerButton *up, *down, *left, *right; for (size_t i = 0; i < numButtons; i++) { OHGameControllerButton *button = [[[OHGameControllerButton alloc] initWithName: buttonNames[i]] autorelease]; [buttons setObject: button forKey: buttonNames[i]]; } [buttons makeImmutable]; _buttons = [buttons retain]; directionalPads = [OFMutableDictionary dictionaryWithCapacity: 3]; xAxis = [[[OHGameControllerAxis alloc] initWithName: @"X"] autorelease]; yAxis = [[[OHGameControllerAxis alloc] initWithName: @"Y"] autorelease]; directionalPad = [[[OHGameControllerDirectionalPad alloc] initWithName: @"Thumbstick" xAxis: xAxis yAxis: yAxis] autorelease]; [directionalPads setObject: directionalPad forKey: @"Thumbstick"]; xAxis = [[[OHGameControllerAxis alloc] initWithName: @"D-Pad X"] autorelease]; yAxis = [[[OHGameControllerAxis alloc] initWithName: @"D-Pad Y"] autorelease]; directionalPad = [[[OHGameControllerDirectionalPad alloc] initWithName: @"D-Pad" xAxis: xAxis yAxis: yAxis] autorelease]; [directionalPads setObject: directionalPad forKey: @"D-Pad"]; up = [[[OHGameControllerButton alloc] initWithName: @"C-Pad Up"] autorelease]; down = [[[OHGameControllerButton alloc] initWithName: @"C-Pad Down"] autorelease]; left = [[[OHGameControllerButton alloc] initWithName: @"C-Pad Left"] autorelease]; right = [[[OHGameControllerButton alloc] initWithName: @"C-Pad Right"] autorelease]; directionalPad = [[[OHGameControllerDirectionalPad alloc] initWithName: @"C-Pad" up: up down: down left: left right: right] autorelease]; [directionalPads setObject: directionalPad forKey: @"C-Pad"]; [directionalPads makeImmutable]; _directionalPads = [directionalPads retain]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_buttons release]; [_directionalPads release]; [super dealloc]; } - (OFDictionary OF_GENERIC(OFString *, OHGameControllerAxis *) *)axes { return [OFDictionary dictionary]; } #if defined(OF_LINUX) && defined(OF_HAVE_FILES) - (OHGameControllerButton *)oh_buttonForEvdevButton: (uint16_t)button { switch (button) { case BTN_A: return [_buttons objectForKey: @"A"]; case BTN_B: return [_buttons objectForKey: @"B"]; case BTN_TL2: return [_buttons objectForKey: @"Z"]; case BTN_SELECT: return [[_directionalPads objectForKey: @"C-Pad"] up]; case BTN_X: return [[_directionalPads objectForKey: @"C-Pad"] down]; case BTN_Y: return [[_directionalPads objectForKey: @"C-Pad"] left]; case BTN_C: return [[_directionalPads objectForKey: @"C-Pad"] right]; case BTN_TL: return [_buttons objectForKey: @"L"]; case BTN_TR: return [_buttons objectForKey: @"R"]; case BTN_START: return [_buttons objectForKey: @"Start"]; } return nil; } - (OHGameControllerAxis *)oh_axisForEvdevAxis: (uint16_t)axis { switch (axis) { case ABS_X: return [[_directionalPads objectForKey: @"Thumbstick"] xAxis]; case ABS_Y: return [[_directionalPads objectForKey: @"Thumbstick"] yAxis]; case ABS_HAT0X: return [[_directionalPads objectForKey: @"D-Pad"] xAxis]; case ABS_HAT0Y: return [[_directionalPads objectForKey: @"D-Pad"] yAxis]; } return nil; } #endif @end |