Overview
Comment: | ObjFWHID: Add support for Stadia controller |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
67c7e7c8ae36e276850f080f2a5b73d5 |
User & Date: | js on 2024-06-09 01:59:45 |
Other Links: | manifest | tags |
Context
2024-06-09
| ||
02:13 | OHEvdevGameController: Add button map for Joy-Cons check-in: 081c229439 user: js tags: trunk | |
01:59 | ObjFWHID: Add support for Stadia controller check-in: 67c7e7c8ae user: js tags: trunk | |
01:34 | ObjFWHID: Add support for DualShock 4 via evdev check-in: 5fe4c8c1bf user: js tags: trunk | |
Changes
Modified src/hid/Makefile from [60012a06af] to [2701f58cde].
︙ | ︙ | |||
20 21 22 23 24 25 26 | ${USE_SRCS_NINTENDO_3DS} \ ${USE_SRCS_NINTENDO_DS} \ ${USE_SRCS_XINPUT} SRCS_EVDEV = OHEvdevDualSense.m \ OHEvdevDualShock4.m \ OHEvdevGameController.m \ OHEvdevGamepad.m \ | | > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ${USE_SRCS_NINTENDO_3DS} \ ${USE_SRCS_NINTENDO_DS} \ ${USE_SRCS_XINPUT} SRCS_EVDEV = OHEvdevDualSense.m \ OHEvdevDualShock4.m \ OHEvdevGameController.m \ OHEvdevGamepad.m \ OHEvdevPlayStationGamepad.m \ OHEvdevStadiaGamepad.m SRCS_NINTENDO_3DS = OHNintendo3DSGameController.m \ OHNintendo3DSGamepad.m SRCS_NINTENDO_DS = OHNintendoDSGameController.m SRCS_XINPUT = OHXInputGameController.m \ OHXInputGamepad.m INCLUDES := ${SRCS:.m=.h} \ |
︙ | ︙ |
Modified src/hid/OHEvdevGameController.m from [453f7a0173] to [a742844fc7].
︙ | ︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #import "OFFileManager.h" #import "OFLocale.h" #import "OFNumber.h" #import "OHEvdevDualSense.h" #import "OHEvdevDualShock4.h" #import "OHEvdevGamepad.h" #import "OHGameControllerAxis.h" #import "OHGameControllerButton.h" #import "OHGameControllerProfile.h" #include <sys/ioctl.h> #include <linux/input.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 "OHEvdevDualSense.h" #import "OHEvdevDualShock4.h" #import "OHEvdevGamepad.h" #import "OHEvdevStadiaGamepad.h" #import "OHGameControllerAxis.h" #import "OHGameControllerButton.h" #import "OHGameControllerProfile.h" #include <sys/ioctl.h> #include <linux/input.h> |
︙ | ︙ | |||
119 120 121 122 123 124 125 126 127 128 129 130 131 132 | if (vendorID == OHVendorIDSony && productID == OHProductIDDualSense) if (button == BTN_SELECT) return @"Create"; if (vendorID == OHVendorIDSony && productID == OHProductIDDualShock4) if (button == BTN_SELECT) return @"Share"; switch (button) { case BTN_A: return @"A"; case BTN_B: return @"B"; case BTN_C: | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | if (vendorID == OHVendorIDSony && productID == OHProductIDDualSense) if (button == BTN_SELECT) return @"Create"; if (vendorID == OHVendorIDSony && productID == OHProductIDDualShock4) if (button == BTN_SELECT) return @"Share"; if (vendorID == OHVendorIDGoogle && productID == OHProductIDStadiaController) { switch (button) { case BTN_TL: return @"L1"; case BTN_TR: return @"R1"; case BTN_TRIGGER_HAPPY4: return @"L2"; case BTN_TRIGGER_HAPPY3: return @"R2"; case BTN_THUMBL: return @"L3"; case BTN_THUMBR: return @"R3"; case BTN_START: return @"Menu"; case BTN_SELECT: return @"Options"; case BTN_MODE: return @"Stadia"; case BTN_TRIGGER_HAPPY1: return @"Assistant"; case BTN_TRIGGER_HAPPY2: return @"Capture"; } } switch (button) { case BTN_A: return @"A"; case BTN_B: return @"B"; case BTN_C: |
︙ | ︙ | |||
642 643 644 645 646 647 648 649 650 651 652 653 654 655 | if (_vendorID == OHVendorIDSony && _productID == OHProductIDDualSense) return [[[OHEvdevDualSense alloc] initWithController: self] autorelease]; else if (_vendorID == OHVendorIDSony && _productID == OHProductIDDualShock4) return [[[OHEvdevDualShock4 alloc] initWithController: self] autorelease]; else return [[[OHEvdevGamepad alloc] initWithController: self] autorelease]; } @catch (OFInvalidArgumentException *e) { return nil; } | > > > > | 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 | if (_vendorID == OHVendorIDSony && _productID == OHProductIDDualSense) return [[[OHEvdevDualSense alloc] initWithController: self] autorelease]; else if (_vendorID == OHVendorIDSony && _productID == OHProductIDDualShock4) return [[[OHEvdevDualShock4 alloc] initWithController: self] autorelease]; else if (_vendorID == OHVendorIDGoogle && _productID == OHProductIDStadiaController) return [[[OHEvdevStadiaGamepad alloc] initWithController: self] autorelease]; else return [[[OHEvdevGamepad alloc] initWithController: self] autorelease]; } @catch (OFInvalidArgumentException *e) { return nil; } |
︙ | ︙ |
Modified src/hid/OHEvdevPlayStationGamepad.m from [c89b2d0c0b] to [66dec8d718].
︙ | ︙ | |||
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | return [_rawProfile.buttons objectForKey: @"Circle"]; } - (OHGameControllerButton *)leftShoulderButton { return [_rawProfile.buttons objectForKey: @"L1"]; } - (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]; } | > > > > > < < < < < | 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 | 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 { |
︙ | ︙ |
Added src/hid/OHEvdevStadiaGamepad.h version [0e795b0f7a].
> > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 "OHEvdevGamepad.h" OF_ASSUME_NONNULL_BEGIN @interface OHEvdevStadiaGamepad: OHEvdevGamepad @end OF_ASSUME_NONNULL_END |
Added src/hid/OHEvdevStadiaGamepad.m version [5fd88a7d3a].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /* * 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 "OHEvdevStadiaGamepad.h" #import "OFDictionary.h" #import "OHGameControllerAxis.h" #import "OHGameControllerDirectionalPad.h" #import "OHGameControllerEmulatedTriggerButton.h" @implementation OHEvdevStadiaGamepad - (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; } - (OFDictionary OF_GENERIC(OFString *, OHGameControllerAxis *) *)axes { OFMutableDictionary *axes = [[_rawProfile.axes mutableCopy] autorelease]; [axes removeObjectForKey: @"X"]; [axes removeObjectForKey: @"Y"]; [axes removeObjectForKey: @"Z"]; [axes removeObjectForKey: @"RZ"]; [axes removeObjectForKey: @"Gas"]; [axes removeObjectForKey: @"Brake"]; [axes removeObjectForKey: @"HAT0X"]; [axes removeObjectForKey: @"HAT0Y"]; [axes makeImmutable]; return axes; } - (OHGameControllerButton *)leftShoulderButton { return [_rawProfile.buttons objectForKey: @"L1"]; } - (OHGameControllerButton *)rightShoulderButton { return [_rawProfile.buttons objectForKey: @"R1"]; } - (OHGameControllerButton *)leftTriggerButton { OHGameControllerAxis *axis = [_rawProfile.axes objectForKey: @"Brake"]; return [[[OHGameControllerEmulatedTriggerButton alloc] initWithName: @"L2" axis: axis] autorelease]; } - (OHGameControllerButton *)rightTriggerButton { return [[[OHGameControllerEmulatedTriggerButton alloc] initWithName: @"R2" axis: [_rawProfile.axes objectForKey: @"Gas"]] autorelease]; } - (OHGameControllerButton *)leftThumbstickButton { return [_rawProfile.buttons objectForKey: @"L3"]; } - (OHGameControllerButton *)rightThumbstickButton { return [_rawProfile.buttons objectForKey: @"R3"]; } - (OHGameControllerButton *)menuButton { return [_rawProfile.buttons objectForKey: @"Menu"]; } - (OHGameControllerButton *)optionsButton { return [_rawProfile.buttons objectForKey: @"Options"]; } - (OHGameControllerButton *)homeButton { return [_rawProfile.buttons objectForKey: @"Stadia"]; } - (OHGameControllerDirectionalPad *)rightThumbstick { OHGameControllerAxis *xAxis = [_rawProfile.axes objectForKey: @"Z"]; OHGameControllerAxis *yAxis = [_rawProfile.axes objectForKey: @"RZ"]; return [[[OHGameControllerDirectionalPad alloc] initWithName: @"Right Thumbstick" xAxis: xAxis yAxis: yAxis] autorelease]; } @end |
Modified src/hid/OHGameController.h from [6042a397f5] to [62dbcc3482].
︙ | ︙ | |||
96 97 98 99 100 101 102 103 104 105 106 107 108 109 | - (void)retrieveState; @end #ifdef __cplusplus extern "C" { #endif extern const uint16_t OHVendorIDSony; extern const uint16_t OHProductIDDualShock4; extern const uint16_t OHProductIDDualSense; #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END | > > | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | - (void)retrieveState; @end #ifdef __cplusplus extern "C" { #endif extern const uint16_t OHVendorIDSony; extern const uint16_t OHVendorIDGoogle; extern const uint16_t OHProductIDDualShock4; extern const uint16_t OHProductIDDualSense; extern const uint16_t OHProductIDStadiaController; #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END |
Modified src/hid/OHGameController.m from [f186a4854f] to [7219963e3b].
︙ | ︙ | |||
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | # import "OHNintendoDSGameController.h" #endif #ifdef OF_NINTENDO_3DS # import "OHNintendo3DSGameController.h" #endif const uint16_t OHVendorIDSony = 0x054C; const uint16_t OHProductIDDualShock4 = 0x09CC; const uint16_t OHProductIDDualSense = 0x0CE6; @implementation OHGameController @dynamic name, rawProfile; + (OFArray OF_GENERIC(OHGameController *) *)controllers { #if defined(OF_LINUX) && defined(OF_HAVE_FILES) | > > | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | # import "OHNintendoDSGameController.h" #endif #ifdef OF_NINTENDO_3DS # import "OHNintendo3DSGameController.h" #endif const uint16_t OHVendorIDSony = 0x054C; const uint16_t OHVendorIDGoogle = 0x18D1; const uint16_t OHProductIDDualShock4 = 0x09CC; const uint16_t OHProductIDDualSense = 0x0CE6; const uint16_t OHProductIDStadiaController = 0x9400; @implementation OHGameController @dynamic name, rawProfile; + (OFArray OF_GENERIC(OHGameController *) *)controllers { #if defined(OF_LINUX) && defined(OF_HAVE_FILES) |
︙ | ︙ |