Comment: | OFGameController: Add support for Wii |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | gamecontroller |
Files: | files | file ages | folders |
SHA3-256: |
918c9d077aaf2bff63790b7a09832b02 |
User & Date: | js on 2024-05-20 01:17:43 |
Other Links: | branch diff | manifest | tags |
2024-05-20
| ||
01:36 | tests/gamecontroller: Check for new controllers check-in: 32e67cf259 user: js tags: gamecontroller | |
01:17 | OFGameController: Add support for Wii check-in: 918c9d077a user: js tags: gamecontroller | |
2024-05-19
| ||
14:18 | Make game controller tests work on Nintendo DS check-in: ca175fe9db user: js tags: gamecontroller | |
Modified .fossil-settings/ignore-glob from [6d33fb85c7] to [affe6beb0b].
︙ | ︙ | |||
13 14 15 16 17 18 19 | *.so *.so.* */.deps .deps .git aclocal.m4 autom4te.cache | < > > > | 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 | *.so *.so.* */.deps .deps .git aclocal.m4 autom4te.cache buildsys.mk config.h config.h.in config.log config.status configure docs extra.mk generators/library/gen_libraries generators/unicode/gen_tables src/Info.plist src/bridge/Info.plist src/hid/Info.plist src/hid/ObjFWHID.oc src/libobjfw.* src/objfw-defs.h src/runtime/Info.plist src/runtime/libobjfwrt.* src/test/libobjfwtest.a src/tls/Info.plist src/tls/libobjfwtls.* tests/DerivedData tests/EBOOT.PBP tests/Info.plist tests/PARAM.SFO tests/big_dictionary_msgpack_gz.m tests/boot.dol tests/gamecontroller/boot.dol tests/gamecontroller/gamecontroller_tests tests/gamecontroller/gamecontroller_tests.3dsx tests/gamecontroller/gamecontroller_tests.arm9 tests/gamecontroller/gamecontroller_tests.nds tests/iOS.xcodeproj/*.pbxuser tests/iOS.xcodeproj/project.xcworkspace tests/iOS.xcodeproj/xcuserdata |
︙ | ︙ |
Modified configure.ac from [32f42f29d4] to [9f1df4bb0d].
︙ | ︙ | |||
168 169 170 171 172 173 174 | flags="-mrvl -mcpu=750 -meabi -mhard-float" OBJCFLAGS="$OBJCFLAGS $flags" OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags" CPPFLAGS="$CPPFLAGS -DGEKKO -I$DEVKITPRO/libogc/include" OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DGEKKO -I\$DEVKITPRO/libogc/include" LDFLAGS="$LDFLAGS -mrvl -mcpu=750 -meabi -mhard-float" LIBS="$LIBS -L$DEVKITPRO/libogc/lib/wii -lfat -logc" | | | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | flags="-mrvl -mcpu=750 -meabi -mhard-float" OBJCFLAGS="$OBJCFLAGS $flags" OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flags" CPPFLAGS="$CPPFLAGS -DGEKKO -I$DEVKITPRO/libogc/include" OBJFW_CPPFLAGS="$OBJFW_CPPFLAGS -DGEKKO -I\$DEVKITPRO/libogc/include" LDFLAGS="$LDFLAGS -mrvl -mcpu=750 -meabi -mhard-float" LIBS="$LIBS -L$DEVKITPRO/libogc/lib/wii -lfat -logc" HID_LIBS="$HID_LIBS -lwiiuse -lbte" enable_shared="no" enable_threads="no" # TODO with_tls="no" AC_DEFINE(OF_WII, 1, [Whether we are compiling for Wii]) AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map']) ]) |
︙ | ︙ | |||
434 435 436 437 438 439 440 | AS_IF([test x"$build_framework" = x"yes"], [ TESTS_LIBS="-framework ObjFW \${RUNTIME_FRAMEWORK_LIBS} $TESTS_LIBS" TESTS_LIBS="-framework ObjFWHID $TESTS_LIBS" TESTS_LIBS="-F../src -F../src/runtime -F../src/hid $TESTS_LIBS" ], [ TESTS_LIBS="-L../src/runtime \${RUNTIME_LIBS} $TESTS_LIBS" | > | | 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | AS_IF([test x"$build_framework" = x"yes"], [ TESTS_LIBS="-framework ObjFW \${RUNTIME_FRAMEWORK_LIBS} $TESTS_LIBS" TESTS_LIBS="-framework ObjFWHID $TESTS_LIBS" TESTS_LIBS="-F../src -F../src/runtime -F../src/hid $TESTS_LIBS" ], [ TESTS_LIBS="-L../src/runtime \${RUNTIME_LIBS} $TESTS_LIBS" TESTS_LIBS="-L../src -lobjfw $TESTS_LIBS" TESTS_LIBS="-L../src/hid -lobjfwhid $HID_LIBS $TESTS_LIBS" ]) AC_ARG_ENABLE(static, AS_HELP_STRING([--enable-static], [build static library])) AS_IF([test x"$enable_shared" = x"no"], [ enable_static="yes" ]) AS_IF([test x"$enable_static" = x"yes"], [ |
︙ | ︙ | |||
2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 | AC_SUBST(AS, $OBJC) AC_SUBST(ASFLAGS) AC_SUBST(DEP_ASFLAGS, '${DEP_OBJCFLAGS}') AC_SUBST(OBJFW_CPPFLAGS) AC_SUBST(OBJFW_OBJCFLAGS) AC_SUBST(TESTS_LIBS) AC_CONFIG_FILES([ buildsys.mk extra.mk src/Info.plist src/hid/Info.plist tests/Info.plist utils/objfw-config ]) AC_CONFIG_HEADERS([config.h src/objfw-defs.h]) AC_OUTPUT AS_IF([test x"$old_compiler" = x"yes"], [ | > > | 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 | AC_SUBST(AS, $OBJC) AC_SUBST(ASFLAGS) AC_SUBST(DEP_ASFLAGS, '${DEP_OBJCFLAGS}') AC_SUBST(OBJFW_CPPFLAGS) AC_SUBST(OBJFW_OBJCFLAGS) AC_SUBST(HID_LIBS) AC_SUBST(TESTS_LIBS) AC_CONFIG_FILES([ buildsys.mk extra.mk src/Info.plist src/hid/Info.plist src/hid/ObjFWHID.oc tests/Info.plist utils/objfw-config ]) AC_CONFIG_HEADERS([config.h src/objfw-defs.h]) AC_OUTPUT AS_IF([test x"$old_compiler" = x"yes"], [ |
︙ | ︙ |
Modified extra.mk.in from [2ce4f6d10c] to [ee60b335fa].
︙ | ︙ | |||
41 42 43 44 45 46 47 48 49 50 51 52 53 54 | ENCODINGS_A = @ENCODINGS_A@ ENCODINGS_LIB_A = @ENCODINGS_LIB_A@ ENCODINGS_SRCS = @ENCODINGS_SRCS@ EXCEPTIONS_A = @EXCEPTIONS_A@ EXCEPTIONS_LIB_A = @EXCEPTIONS_LIB_A@ FORWARDING_A = @FORWARDING_A@ FORWARDING_LIB_A = @FORWARDING_LIB_A@ LIBBASES_M = @LIBBASES_M@ LIBOBJFWHID_DEP = @LIBOBJFWHID_DEP@ LIBOBJFWHID_DEP_LVL2 = @LIBOBJFWHID_DEP_LVL2@ LIBOBJFWRT_DEP = @LIBOBJFWRT_DEP@ LIBOBJFWRT_DEP_LVL2 = @LIBOBJFWRT_DEP_LVL2@ LIBOBJFW_DEP = @LIBOBJFW_DEP@ LIBOBJFW_DEP_LVL2 = @LIBOBJFW_DEP_LVL2@ | > | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | ENCODINGS_A = @ENCODINGS_A@ ENCODINGS_LIB_A = @ENCODINGS_LIB_A@ ENCODINGS_SRCS = @ENCODINGS_SRCS@ EXCEPTIONS_A = @EXCEPTIONS_A@ EXCEPTIONS_LIB_A = @EXCEPTIONS_LIB_A@ FORWARDING_A = @FORWARDING_A@ FORWARDING_LIB_A = @FORWARDING_LIB_A@ HID_LIBS = @HID_LIBS@ LIBBASES_M = @LIBBASES_M@ LIBOBJFWHID_DEP = @LIBOBJFWHID_DEP@ LIBOBJFWHID_DEP_LVL2 = @LIBOBJFWHID_DEP_LVL2@ LIBOBJFWRT_DEP = @LIBOBJFWRT_DEP@ LIBOBJFWRT_DEP_LVL2 = @LIBOBJFWRT_DEP_LVL2@ LIBOBJFW_DEP = @LIBOBJFW_DEP@ LIBOBJFW_DEP_LVL2 = @LIBOBJFW_DEP_LVL2@ |
︙ | ︙ |
Modified src/hid/OFEvdevGameController.h from [8ab70e7289] to [251f0edbf4].
︙ | ︙ | |||
23 24 25 26 27 28 29 | @interface OFEvdevGameController: OFGameController { OFString *_path; int _fd; uint16_t _vendorID, _productID; OFString *_name; | > | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | @interface OFEvdevGameController: OFGameController { OFString *_path; int _fd; uint16_t _vendorID, _productID; OFString *_name; OFMutableSet OF_GENERIC(OFGameControllerButton) *_buttons; OFMutableSet OF_GENERIC(OFGameControllerButton) *_pressedButtons; bool _hasLeftAnalogStick, _hasRightAnalogStick; bool _hasLeftTriggerPressure, _hasRightTriggerPressure; unsigned int _leftTriggerPressureBit, _rightTriggerPressureBit; OFPoint _leftAnalogStickPosition, _rightAnalogStickPosition; float _leftTriggerPressure, _rightTriggerPressure; int32_t _leftAnalogStickMinX, _leftAnalogStickMaxX; int32_t _leftAnalogStickMinY, _leftAnalogStickMaxY; |
︙ | ︙ |
Modified src/hid/OFEvdevGameController.m from [7e2448fb2d] to [3ddc2d6279].
︙ | ︙ | |||
237 238 239 240 241 242 243 | [controllers makeImmutable]; objc_autoreleasePoolPop(pool); return controllers; } | < < < < < | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | [controllers makeImmutable]; objc_autoreleasePoolPop(pool); return controllers; } - (instancetype)of_initWithPath: (OFString *)path { self = [super init]; @try { OFStringEncoding encoding = [OFLocale encoding]; unsigned long evBits[OFRoundUpToPowerOf2(OF_ULONG_BIT, |
︙ | ︙ |
Modified src/hid/OFGameController.h from [933ce242f6] to [377e60382e].
︙ | ︙ | |||
69 70 71 72 73 74 75 | * * @ref OFGameControllerZButton * * @ref OFGameControllerCPadUpButton * * @ref OFGameControllerCPadDownButton * * @ref OFGameControllerCPadLeftButton * * @ref OFGameControllerCPadRightButton * * @ref OFGameControllerSLButton * * @ref OFGameControllerSRButton | | | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | * * @ref OFGameControllerZButton * * @ref OFGameControllerCPadUpButton * * @ref OFGameControllerCPadDownButton * * @ref OFGameControllerCPadLeftButton * * @ref OFGameControllerCPadRightButton * * @ref OFGameControllerSLButton * * @ref OFGameControllerSRButton * * @ref OFGameControllerAssistantButton */ typedef OFConstantString *OFGameControllerButton; #ifdef __cplusplus extern "C" { #endif /** |
︙ | ︙ | |||
227 228 229 230 231 232 233 | extern const OFGameControllerButton OFGameControllerSLButton; /** * @brief The SR button on a game controller. */ extern const OFGameControllerButton OFGameControllerSRButton; | < < < < < | 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | extern const OFGameControllerButton OFGameControllerSLButton; /** * @brief The SR button on a game controller. */ extern const OFGameControllerButton OFGameControllerSRButton; /** * @brief The Assistant button on a game controller. */ extern const OFGameControllerButton OFGameControllerAssistantButton; #ifdef __cplusplus } #endif |
︙ | ︙ |
Modified src/hid/OFGameController.m from [70e6c920ca] to [6850544fb5].
︙ | ︙ | |||
26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #if defined(OF_LINUX) && defined(OF_HAVE_FILES) # include "OFEvdevGameController.h" #endif #ifdef OF_WINDOWS # include "OFXInputGameController.h" #endif #ifdef OF_NINTENDO_DS # include "OFNintendoDSGameController.h" #endif #ifdef OF_NINTENDO_3DS # include "OFNintendo3DSGameController.h" #endif | > > > | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #if defined(OF_LINUX) && defined(OF_HAVE_FILES) # include "OFEvdevGameController.h" #endif #ifdef OF_WINDOWS # include "OFXInputGameController.h" #endif #ifdef OF_WII # include "OFWiiGameController.h" #endif #ifdef OF_NINTENDO_DS # include "OFNintendoDSGameController.h" #endif #ifdef OF_NINTENDO_3DS # include "OFNintendo3DSGameController.h" #endif |
︙ | ︙ | |||
67 68 69 70 71 72 73 | const OFGameControllerButton OFGameControllerZButton = @"Z"; const OFGameControllerButton OFGameControllerCPadUpButton = @"C-Pad Up"; const OFGameControllerButton OFGameControllerCPadDownButton = @"C-Pad Down"; const OFGameControllerButton OFGameControllerCPadLeftButton = @"C-Pad Left"; const OFGameControllerButton OFGameControllerCPadRightButton = @"C-Pad Right"; const OFGameControllerButton OFGameControllerSLButton = @"SL"; const OFGameControllerButton OFGameControllerSRButton = @"SR"; | < > > | 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 | const OFGameControllerButton OFGameControllerZButton = @"Z"; const OFGameControllerButton OFGameControllerCPadUpButton = @"C-Pad Up"; const OFGameControllerButton OFGameControllerCPadDownButton = @"C-Pad Down"; const OFGameControllerButton OFGameControllerCPadLeftButton = @"C-Pad Left"; const OFGameControllerButton OFGameControllerCPadRightButton = @"C-Pad Right"; const OFGameControllerButton OFGameControllerSLButton = @"SL"; const OFGameControllerButton OFGameControllerSRButton = @"SR"; const OFGameControllerButton OFGameControllerAssistantButton = @"Assistant"; @implementation OFGameController @dynamic name, buttons, pressedButtons, hasLeftAnalogStick; @dynamic leftAnalogStickPosition, hasRightAnalogStick, rightAnalogStickPosition; + (OFArray OF_GENERIC(OFGameController *) *)controllers { #if defined(OF_LINUX) && defined(OF_HAVE_FILES) return [OFEvdevGameController controllers]; #elif defined(OF_WINDOWS) return [OFXInputGameController controllers]; #elif defined(OF_WII) return [OFWiiGameController controllers]; #elif defined(OF_NINTENDO_DS) return [OFNintendoDSGameController controllers]; #elif defined(OF_NINTENDO_3DS) return [OFNintendo3DSGameController controllers]; #else return [OFArray array]; #endif |
︙ | ︙ | |||
144 145 146 147 148 149 150 151 152 153 154 155 156 | #if defined(OF_LINUX) && defined(OF_HAVE_FILES) # include "OFEvdevGameController.m" #endif #ifdef OF_WINDOWS # include "OFXInputGameController.m" #endif #ifdef OF_NINTENDO_DS # include "OFNintendoDSGameController.m" #endif #ifdef OF_NINTENDO_3DS # include "OFNintendo3DSGameController.m" #endif | > > > | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | #if defined(OF_LINUX) && defined(OF_HAVE_FILES) # include "OFEvdevGameController.m" #endif #ifdef OF_WINDOWS # include "OFXInputGameController.m" #endif #ifdef OF_WII # include "OFWiiGameController.m" #endif #ifdef OF_NINTENDO_DS # include "OFNintendoDSGameController.m" #endif #ifdef OF_NINTENDO_3DS # include "OFNintendo3DSGameController.m" #endif |
Modified src/hid/OFNintendo3DSGameController.h from [54f724ec89] to [143c577afb].
︙ | ︙ | |||
19 20 21 22 23 24 25 | #import "OFGameController.h" OF_ASSUME_NONNULL_BEGIN @interface OFNintendo3DSGameController: OFGameController { | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 | #import "OFGameController.h" OF_ASSUME_NONNULL_BEGIN @interface OFNintendo3DSGameController: OFGameController { OFMutableSet OF_GENERIC(OFGameControllerButton) *_pressedButtons; OFPoint _leftAnalogStickPosition; } @end OF_ASSUME_NONNULL_END |
Modified src/hid/OFNintendo3DSGameController.m from [c19a2f1b59] to [5dde4675ee].
︙ | ︙ | |||
27 28 29 30 31 32 33 | #define id id_3ds #include <3ds.h> #undef id static OFArray OF_GENERIC(OFGameController *) *controllers; | > > | | | > > > > < < < < < < < < | | 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 | #define id id_3ds #include <3ds.h> #undef id static OFArray OF_GENERIC(OFGameController *) *controllers; @implementation OFNintendo3DSGameController @synthesize leftAnalogStickPosition = _leftAnalogStickPosition; + (void)initialize { void *pool; if (self != [OFNintendo3DSGameController class]) return; pool = objc_autoreleasePoolPush(); controllers = [[OFArray alloc] initWithObject: [[[OFNintendo3DSGameController alloc] init] autorelease]]; objc_autoreleasePoolPop(pool); } + (OFArray OF_GENERIC(OFGameController *) *)controllers { return controllers; } - (instancetype)init { self = [super init]; @try { |
︙ | ︙ |
Modified src/hid/OFNintendoDSGameController.h from [b8a00a7023] to [a3f594eb12].
︙ | ︙ | |||
19 20 21 22 23 24 25 | #import "OFGameController.h" OF_ASSUME_NONNULL_BEGIN @interface OFNintendoDSGameController: OFGameController { | | | 19 20 21 22 23 24 25 26 27 28 29 30 | #import "OFGameController.h" OF_ASSUME_NONNULL_BEGIN @interface OFNintendoDSGameController: OFGameController { OFMutableSet OF_GENERIC(OFGameControllerButton) *_pressedButtons; } @end OF_ASSUME_NONNULL_END |
Modified src/hid/OFNintendoDSGameController.m from [ca22ee2dc5] to [76ee0663ed].
︙ | ︙ | |||
27 28 29 30 31 32 33 | #define asm __asm__ #include <nds.h> #undef asm static OFArray OF_GENERIC(OFGameController *) *controllers; | | | | > > > > < < < < < < | | 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 | #define asm __asm__ #include <nds.h> #undef asm static OFArray OF_GENERIC(OFGameController *) *controllers; @implementation OFNintendoDSGameController + (void)initialize { void *pool; if (self != [OFNintendoDSGameController class]) return; pool = objc_autoreleasePoolPush(); controllers = [[OFArray alloc] initWithObject: [[[OFNintendoDSGameController alloc] init] autorelease]]; objc_autoreleasePoolPop(pool); } + (OFArray OF_GENERIC(OFGameController *) *)controllers { return controllers; } - (instancetype)init { self = [super init]; @try { |
︙ | ︙ |
Added src/hid/OFWiiGameController.h version [d872d533c3].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /* * 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 "OFGameController.h" OF_ASSUME_NONNULL_BEGIN @interface OFWiiGameController: OFGameController { int32_t _index; uint32_t _type; OFMutableSet OF_GENERIC(OFGameControllerButton) *_pressedButtons; OFPoint _leftAnalogStickPosition; } - (instancetype)of_initWithIndex: (int32_t)index type: (uint32_t)type OF_METHOD_FAMILY(init); @end OF_ASSUME_NONNULL_END |
Added src/hid/OFWiiGameController.m version [30f9adda3d].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | /* * 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 "OFWiiGameController.h" #import "OFMutableSet.h" #import "OFInitializationFailedException.h" #import "OFNotImplementedException.h" #import "OFReadFailedException.h" #define asm __asm__ #include <wiiuse/wpad.h> #undef asm static float scale(float value, float min, float max, float center) { if (value < min) value = min; if (value > max) value = max; if (value >= center) return (value - center) / (max - center); else return (value - center) / (center - min); } @implementation OFWiiGameController + (void)initialize { if (self != [OFWiiGameController class]) return; if (WPAD_Init() != WPAD_ERR_NONE) @throw [OFInitializationFailedException exceptionWithClass: self]; } + (OFArray OF_GENERIC(OFGameController *) *)controllers { OFMutableArray *controllers = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); for (int32_t i = 0; i < WPAD_MAX_WIIMOTES; i++) { uint32_t type; if (WPAD_Probe(i, &type) == WPAD_ERR_NONE && (type == WPAD_EXP_NONE || type == WPAD_EXP_NUNCHUK)) [controllers addObject: [[[OFWiiGameController alloc] of_initWithIndex: i type: type] autorelease]]; } [controllers makeImmutable]; objc_autoreleasePoolPop(pool); return controllers; } - (instancetype)of_initWithIndex: (int32_t)index type: (uint32_t)type { self = [super init]; @try { _index = index; _type = type; _pressedButtons = [[OFMutableSet alloc] initWithCapacity: 13]; [self retrieveState]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_pressedButtons release]; [super dealloc]; } - (void)retrieveState { WPADData *data; if (WPAD_ReadPending(_index, NULL) < WPAD_ERR_NONE) @throw [OFReadFailedException exceptionWithObject: self requestedLength: sizeof(WPADData) errNo: 0]; data = WPAD_Data(_index); [_pressedButtons removeAllObjects]; if (data->btns_h & WPAD_BUTTON_A) [_pressedButtons addObject: OFGameControllerEastButton]; if (data->btns_h & WPAD_BUTTON_B) [_pressedButtons addObject: OFGameControllerRightTriggerButton]; if (data->btns_h & WPAD_BUTTON_1) [_pressedButtons addObject: OFGameControllerWestButton]; if (data->btns_h & WPAD_BUTTON_2) [_pressedButtons addObject: OFGameControllerSouthButton]; if (data->btns_h & WPAD_BUTTON_UP) [_pressedButtons addObject: OFGameControllerDPadUpButton]; if (data->btns_h & WPAD_BUTTON_DOWN) [_pressedButtons addObject: OFGameControllerDPadDownButton]; if (data->btns_h & WPAD_BUTTON_LEFT) [_pressedButtons addObject: OFGameControllerDPadLeftButton]; if (data->btns_h & WPAD_BUTTON_RIGHT) [_pressedButtons addObject: OFGameControllerDPadRightButton]; if (data->btns_h & WPAD_BUTTON_PLUS) [_pressedButtons addObject: OFGameControllerStartButton]; if (data->btns_h & WPAD_BUTTON_MINUS) [_pressedButtons addObject: OFGameControllerSelectButton]; if (data->btns_h & WPAD_BUTTON_HOME) [_pressedButtons addObject: OFGameControllerHomeButton]; if (_type == WPAD_EXP_NUNCHUK) { joystick_t *js; if (data->btns_h & WPAD_NUNCHUK_BUTTON_C) [_pressedButtons addObject: OFGameControllerLeftShoulderButton]; if (data->btns_h & WPAD_NUNCHUK_BUTTON_Z) [_pressedButtons addObject: OFGameControllerLeftTriggerButton]; js = &data->exp.nunchuk.js; _leftAnalogStickPosition = OFMakePoint( scale(js->pos.x, js->min.x, js->max.x, js->center.x), -scale(js->pos.y, js->min.y, js->max.y, js->center.y)); } } - (OFString *)name { if (_type == WPAD_EXP_NUNCHUK) return @"Wiimote with Nunchuk"; return @"Wiimote"; } - (OFSet OF_GENERIC(OFGameControllerButton) *)buttons { OFMutableSet *buttons = [OFMutableSet setWithCapacity: 13]; [buttons addObject: OFGameControllerSouthButton]; [buttons addObject: OFGameControllerRightTriggerButton]; [buttons addObject: OFGameControllerWestButton]; [buttons addObject: OFGameControllerEastButton]; [buttons addObject: OFGameControllerDPadUpButton]; [buttons addObject: OFGameControllerDPadDownButton]; [buttons addObject: OFGameControllerDPadLeftButton]; [buttons addObject: OFGameControllerDPadRightButton]; [buttons addObject: OFGameControllerStartButton]; [buttons addObject: OFGameControllerSelectButton]; [buttons addObject: OFGameControllerHomeButton]; if (_type == WPAD_EXP_NUNCHUK) { [buttons addObject: OFGameControllerLeftShoulderButton]; [buttons addObject: OFGameControllerLeftTriggerButton]; } [buttons makeImmutable]; return buttons; } - (OFSet OF_GENERIC(OFGameControllerButton) *)pressedButtons { return [[_pressedButtons copy] autorelease]; } - (bool)hasLeftAnalogStick { return (_type == WPAD_EXP_NUNCHUK); } - (bool)hasRightAnalogStick { return false; } - (OFPoint)leftAnalogStickPosition { if (_type != WPAD_EXP_NUNCHUK) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; return _leftAnalogStickPosition; } @end |
Modified src/hid/OFXInputGameController.h from [523c04abd7] to [393b179dcd].
︙ | ︙ | |||
21 22 23 24 25 26 27 | OF_ASSUME_NONNULL_BEGIN @interface OFXInputGameController: OFGameController { DWORD _index; OFNumber *_Nullable _vendorID, *_Nullable productID; | | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | OF_ASSUME_NONNULL_BEGIN @interface OFXInputGameController: OFGameController { DWORD _index; OFNumber *_Nullable _vendorID, *_Nullable productID; OFMutableSet OF_GENERIC(OFGameControllerButton) *_pressedButtons; OFPoint _leftAnalogStickPosition, _rightAnalogStickPosition; float _leftTriggerPressure, _rightTriggerPressure; } - (instancetype)of_initWithIndex: (DWORD)index OF_METHOD_FAMILY(init); @end |
︙ | ︙ |
Modified src/hid/OFXInputGameController.m from [a152c52018] to [18e5d09447].
︙ | ︙ | |||
101 102 103 104 105 106 107 | } [controllers makeImmutable]; return controllers; } | < < < < < | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | } [controllers makeImmutable]; return controllers; } - (instancetype)of_initWithIndex: (DWORD)index { self = [super init]; @try { XINPUT_STATE state = { 0 }; |
︙ | ︙ |
Renamed and modified src/hid/ObjFWHID.oc [cd98cf700e] to src/hid/ObjFWHID.oc.in [517988d4e5].
1 | package_format 1 | | | | | 1 2 3 4 | package_format 1 LIBS="-lobjfwhid @HID_LIBS@ $LIBS" FRAMEWORK_LIBS="-framework ObjFWHID @HID_LIBS@ $FRAMEWORK_LIBS" STATIC_LIBS="${libdir}/libobjfwhid.a @HID_LIBS@ $STATIC_LIBS" |
Modified src/test/OTAppDelegate.m from [3474e8e70a] to [c350ebfc99].
︙ | ︙ | |||
37 38 39 40 41 42 43 | #ifdef OF_IOS # include <CoreFoundation/CoreFoundation.h> #endif #ifdef OF_WII # define asm __asm__ # include <gccore.h> | < | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #ifdef OF_IOS # include <CoreFoundation/CoreFoundation.h> #endif #ifdef OF_WII # define asm __asm__ # include <gccore.h> # undef asm #endif #ifdef OF_NINTENDO_DS # define asm __asm__ # include <nds.h> # undef asm |
︙ | ︙ | |||
120 121 122 123 124 125 126 | CFRelease(resourcesURL); #elif defined(OF_WII) GXRModeObj *mode; void *nextFB; VIDEO_Init(); | < | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | CFRelease(resourcesURL); #elif defined(OF_WII) GXRModeObj *mode; void *nextFB; VIDEO_Init(); mode = VIDEO_GetPreferredMode(NULL); nextFB = MEM_K0_TO_K1(SYS_AllocateFramebuffer(mode)); VIDEO_Configure(mode); VIDEO_SetNextFramebuffer(nextFB); VIDEO_SetBlack(FALSE); VIDEO_Flush(); |
︙ | ︙ | |||
309 310 311 312 313 314 315 | if (description != nil) [OFStdOut writeLine: description]; break; } if (status == StatusFailed) { | < < < < < < < < < < < < | > > | > > | 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | if (description != nil) [OFStdOut writeLine: description]; break; } if (status == StatusFailed) { #if defined(OF_WII) || defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS) [OFStdOut setForegroundColor: [OFColor silver]]; [OFStdOut writeLine: @"Press A to continue"]; for (;;) { void *pool = objc_autoreleasePoolPush(); OFGameController *controller = [[OFGameController controllers] objectAtIndex: 0]; [controller retrieveState]; if ([controller.pressedButtons containsObject: OFGameControllerEastButton]) break; # if defined(OF_WII) VIDEO_WaitVSync(); # elif defined(OF_NINTENDO_DS) swiWaitForVBlank(); # elif defined(OF_NINTENDO_3DS) gspWaitForVBlank(); # endif objc_autoreleasePoolPop(pool); } #elif defined(OF_NINTENDO_SWITCH) |
︙ | ︙ | |||
594 595 596 597 598 599 600 | #endif [OFStdOut writeFormat: @"%zu", numSkipped]; [OFStdOut setForegroundColor: [OFColor purple]]; [OFStdOut writeFormat: @" test%s skipped\n", (numSkipped != 1 ? "s" : "")]; [OFStdOut reset]; | | > | > > > > > > | > > > | > > > > > < | < < < < < < < < < | < < < < < < < < < > > | 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 | #endif [OFStdOut writeFormat: @"%zu", numSkipped]; [OFStdOut setForegroundColor: [OFColor purple]]; [OFStdOut writeFormat: @" test%s skipped\n", (numSkipped != 1 ? "s" : "")]; [OFStdOut reset]; #if defined(OF_WII) || defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS) [OFStdOut setForegroundColor: [OFColor silver]]; # ifdef OF_WII [OFStdOut writeLine: @"Press Home button to exit"]; # else [OFStdOut writeLine: @"Press Start button to exit"]; # endif for (;;) { void *pool = objc_autoreleasePoolPush(); OFGameController *controller = [[OFGameController controllers] objectAtIndex: 0]; [controller retrieveState]; # ifdef OF_WII if ([controller.pressedButtons containsObject: OFGameControllerHomeButton]) # else if ([controller.pressedButtons containsObject: OFGameControllerStartButton]) # endif break; # if defined(OF_WII) VIDEO_WaitVSync(); # elif defined(OF_NINTENDO_DS) swiWaitForVBlank(); # elif defined(OF_NINTENDO_3DS) gspWaitForVBlank(); # endif objc_autoreleasePoolPop(pool); } #elif defined(OF_NINTENDO_SWITCH) while (appletMainLoop()) updateConsole(true); consoleExit(NULL); #endif [OFApplication terminateWithStatus: (int)numFailed]; } @end |
Modified tests/Makefile from [1858d93af6] to [2dc3d62f3a].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | include ../extra.mk SUBDIRS = ${TESTPLUGIN} \ ${SUBPROCESS} \ gamecontroller \ ${OBJC_SYNC} \ terminal CLEAN = EBOOT.PBP \ boot.dol \ ${PROG_NOINST}.arm9 \ ${PROG_NOINST}.nds \ ${PROG_NOINST}.nro \ ${PROG_NOINST}.rpx \ big_dictionary_msgpack_gz.m \ testfile_bin.m \ testfile_ini.m | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | include ../extra.mk SUBDIRS = ${TESTPLUGIN} \ ${SUBPROCESS} \ gamecontroller \ ${OBJC_SYNC} \ terminal CLEAN = EBOOT.PBP \ boot.dol \ ${PROG_NOINST}.3dsx \ ${PROG_NOINST}.arm9 \ ${PROG_NOINST}.nds \ ${PROG_NOINST}.nro \ ${PROG_NOINST}.rpx \ big_dictionary_msgpack_gz.m \ testfile_bin.m \ testfile_ini.m |
︙ | ︙ |
Modified tests/gamecontroller/GameControllerTests.m from [e818d4f2e1] to [8fea7e2a6d].
︙ | ︙ | |||
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 | #import "OFArray.h" #import "OFColor.h" #import "OFGameController.h" #import "OFNumber.h" #import "OFSet.h" #import "OFStdIOStream.h" #import "OFThread.h" #ifdef OF_NINTENDO_DS # define asm __asm__ # include <nds.h> # undef asm # define BUTTONS_PER_LINE 2 #endif #ifdef OF_NINTENDO_3DS /* Newer versions of libctru started using id as a parameter name. */ # define id id_3ds # include <3ds.h> # undef id # define BUTTONS_PER_LINE 3 #endif #ifndef BUTTONS_PER_LINE # define BUTTONS_PER_LINE 5 #endif | > > > > > > | > > > > > > > > > > > > > > > > > > > | > > > > > | 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 | #import "OFArray.h" #import "OFColor.h" #import "OFGameController.h" #import "OFNumber.h" #import "OFSet.h" #import "OFStdIOStream.h" #import "OFThread.h" #ifdef OF_WII # define asm __asm__ # include <gccore.h> # undef asm #endif #ifdef OF_NINTENDO_DS # define asm __asm__ # include <nds.h> # undef asm # define BUTTONS_PER_LINE 2 #endif #ifdef OF_NINTENDO_3DS /* Newer versions of libctru started using id as a parameter name. */ # define id id_3ds # include <3ds.h> # undef id # define BUTTONS_PER_LINE 3 #endif #ifndef BUTTONS_PER_LINE # define BUTTONS_PER_LINE 5 #endif #if defined(OF_WII) || defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS) # define red maroon # define yellow olive # define gray silver #endif @interface GameControllerTests: OFObject <OFApplicationDelegate> @end OF_APPLICATION_DELEGATE(GameControllerTests) @implementation GameControllerTests - (void)applicationDidFinishLaunching: (OFNotification *)notification { OFArray *controllers; #if defined(OF_WII) GXRModeObj *mode; void *nextFB; VIDEO_Init(); mode = VIDEO_GetPreferredMode(NULL); nextFB = MEM_K0_TO_K1(SYS_AllocateFramebuffer(mode)); VIDEO_Configure(mode); VIDEO_SetNextFramebuffer(nextFB); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if (mode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); CON_InitEx(mode, 2, 2, mode->fbWidth - 4, mode->xfbHeight - 4); VIDEO_ClearFrameBuffer(mode, nextFB, COLOR_BLACK); #elif defined(OF_NINTENDO_DS) consoleDemoInit(); #elif defined(OF_NINTENDO_3DS) gfxInitDefault(); atexit(gfxExit); consoleInit(GFX_TOP, NULL); #endif controllers = [OFGameController controllers]; [OFStdOut clear]; for (;;) { void *pool = objc_autoreleasePoolPush(); #ifdef OF_WII /* Wii needs some time before controllers are found. */ controllers = [OFGameController controllers]; #endif [OFStdOut setCursorPosition: OFMakePoint(0, 0)]; for (OFGameController *controller in controllers) { OFArray OF_GENERIC(OFGameControllerButton) *buttons = controller.buttons.allObjects.sortedArray; size_t i = 0; |
︙ | ︙ |
Modified tests/gamecontroller/Makefile from [933ce281d6] to [1986e83bf3].
1 2 3 4 5 6 7 8 9 | include ../../extra.mk PROG_NOINST = gamecontroller_tests${PROG_SUFFIX} SRCS = GameControllerTests.m include ../../buildsys.mk .PHONY: run run: | > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | include ../../extra.mk CLEAN = boot.dol \ ${PROG_NOINST}.3dsx \ ${PROG_NOINST}.arm9 \ ${PROG_NOINST}.ndsd \ PROG_NOINST = gamecontroller_tests${PROG_SUFFIX} SRCS = GameControllerTests.m include ../../buildsys.mk .PHONY: run run: |
︙ | ︙ | |||
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 | rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ rm -f libobjfwhid.so.${OBJFWHID_LIB_MAJOR}; \ rm -f libobjfwhid.so.${OBJFWHID_LIB_MAJOR_MINOR}; \ rm -f objfwhid${OBJFWHID_LIB_MAJOR}.dll; \ rm -f libobjfwhid.${OBJFWHID_LIB_MAJOR}.dylib; \ exit $$EXIT ${PROG_NOINST}: ${LIBOBJFW_DEP_LVL2} ${LIBOBJFWRT_DEP_LVL2} \ ${LIBOBJFWHID_DEP_LVL2} ${PROG_NOINST}.3dsx: ${PROG_NOINST} 3dsxtool $< $@ ${PROG_NOINST}.arm9: ${PROG_NOINST} arm-none-eabi-objcopy -O binary $< $@ ${PROG_NOINST}.nds: ${PROG_NOINST}.arm9 ndstool -c $@ -9 ${PROG_NOINST} CPPFLAGS += -I../../src \ -I../../src/exceptions \ -I../../src/hid \ -I../../src/runtime \ -I../.. \ -DOBJFWHID_LOCAL_INCLUDES | > > > | | 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 | rm -f libobjfwrt.${OBJFWRT_LIB_MAJOR}.dylib; \ rm -f libobjfwhid.so.${OBJFWHID_LIB_MAJOR}; \ rm -f libobjfwhid.so.${OBJFWHID_LIB_MAJOR_MINOR}; \ rm -f objfwhid${OBJFWHID_LIB_MAJOR}.dll; \ rm -f libobjfwhid.${OBJFWHID_LIB_MAJOR}.dylib; \ exit $$EXIT boot.dol: ${PROG_NOINST} elf2dol ${PROG_NOINST} $@ ${PROG_NOINST}: ${LIBOBJFW_DEP_LVL2} ${LIBOBJFWRT_DEP_LVL2} \ ${LIBOBJFWHID_DEP_LVL2} ${PROG_NOINST}.3dsx: ${PROG_NOINST} 3dsxtool $< $@ ${PROG_NOINST}.arm9: ${PROG_NOINST} arm-none-eabi-objcopy -O binary $< $@ ${PROG_NOINST}.nds: ${PROG_NOINST}.arm9 ndstool -c $@ -9 ${PROG_NOINST} CPPFLAGS += -I../../src \ -I../../src/exceptions \ -I../../src/hid \ -I../../src/runtime \ -I../.. \ -DOBJFWHID_LOCAL_INCLUDES LIBS := -L../../src/hid -lobjfwhid ${HID_LIBS} \ -L../../src -lobjfw \ -L../../src/runtime ${RUNTIME_LIBS} \ ${LIBS} LD = ${OBJC} |