Overview
Comment: | OFGameController: Add support for Nintendo DS |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | gamecontroller |
Files: | files | file ages | folders |
SHA3-256: |
a7a6705d90ebdf08f45b94f6e48b4096 |
User & Date: | js on 2024-05-05 19:22:25 |
Other Links: | branch diff | manifest | tags |
Context
2024-05-05
| ||
19:56 | OFGameController: Rename axis to analog stick check-in: 498a91a2a4 user: js tags: gamecontroller | |
19:22 | OFGameController: Add support for Nintendo DS check-in: a7a6705d90 user: js tags: gamecontroller | |
18:59 | Add OFGameController check-in: a0f4283e81 user: js tags: gamecontroller | |
Changes
Modified src/OFGameController.m from [07a9f043f8] to [fafb3475e1].
︙ | ︙ | |||
19 20 21 22 23 24 25 | #include "config.h" #import "OFGameController.h" #import "OFOutOfRangeException.h" | > > | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #include "config.h" #import "OFGameController.h" #import "OFOutOfRangeException.h" #if defined(OF_NINTENDO_DS) # include "platform/NintendoDS/OFGameController.m" #elif defined(F_NINTENDO_3DS) # include "platform/Nintendo3DS/OFGameController.m" #else @implementation OFGameController @dynamic buttons, pressedButtons, numAxes; + (size_t)numControllers { return 0; |
︙ | ︙ |
Name change from src/platform/3DS/OFGameController.m to src/platform/Nintendo3DS/OFGameController.m.
︙ | ︙ |
Added src/platform/NintendoDS/OFGameController.m version [1ef9eba7af].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /* * 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 "OFGameController.h" #import "OFSet.h" #import "OFOutOfRangeException.h" #define asm __asm__ #include <nds.h> #undef asm @interface OFGameController () - (instancetype)of_init OF_METHOD_FAMILY(init); @end static OFGameController *controller; static void initController(void) { controller = [[OFGameController alloc] of_init]; } @implementation OFGameController + (size_t)numControllers { return 1; } + (OFGameController *)controllerWithIndex: (size_t)index { static OFOnceControl onceControl = OFOnceControlInitValue; if (index > 0) @throw [OFOutOfRangeException exception]; OFOnce(&onceControl, initController); return [[controller retain] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)of_init { return [super init]; } - (OFSet *)buttons { return [OFSet setWithObjects: @"A", @"B", @"Select", @"Start", @"D-Pad Right", @"D-Pad Left", @"D-Pad Up", @"D-Pad Down", @"R", @"L", @"X", @"Y", nil]; } - (OFSet *)pressedButtons { OFMutableSet *pressedButtons = [OFMutableSet setWithCapacity: 12]; uint32 keys; scanKeys(); keys = keysCurrent(); if (keys & KEY_A) [pressedButtons addObject: @"A"]; if (keys & KEY_B) [pressedButtons addObject: @"A"]; if (keys & KEY_SELECT) [pressedButtons addObject: @"Select"]; if (keys & KEY_START) [pressedButtons addObject: @"Start"]; if (keys & KEY_RIGHT) [pressedButtons addObject: @"D-Pad Right"]; if (keys & KEY_LEFT) [pressedButtons addObject: @"D-Pad Left"]; if (keys & KEY_UP) [pressedButtons addObject: @"D-Pad Up"]; if (keys & KEY_DOWN) [pressedButtons addObject: @"D-Pad Down"]; if (keys & KEY_R) [pressedButtons addObject: @"R"]; if (keys & KEY_L) [pressedButtons addObject: @"L"]; if (keys & KEY_X) [pressedButtons addObject: @"X"]; if (keys & KEY_Y) [pressedButtons addObject: @"Y"]; [pressedButtons makeImmutable]; return pressedButtons; } - (size_t)numAxes { return 0; } - (OFPoint)positionOfAxisWithIndex: (size_t)index { @throw [OFOutOfRangeException exception]; } @end |
Modified src/test/OTAppDelegate.m from [da9bf57bcb] to [2b12d71a47].
︙ | ︙ | |||
319 320 321 322 323 324 325 | WPAD_ScanPads(); if (WPAD_ButtonsDown(0) & WPAD_BUTTON_A) break; VIDEO_WaitVSync(); } | | < < < < < < < < < < < > > > > | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | WPAD_ScanPads(); if (WPAD_ButtonsDown(0) & WPAD_BUTTON_A) break; VIDEO_WaitVSync(); } #elif 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 controllerWithIndex: 0]; if ([controller.pressedButtons containsObject: @"A"]) break; # if defined(OF_NINTENDO_DS) swiWaitForVBlank(); # elif defined(OF_NINTENDO_3DS) gspWaitForVBlank(); # endif objc_autoreleasePoolPop(pool); } #elif defined(OF_NINTENDO_SWITCH) [OFStdOut setForegroundColor: [OFColor silver]]; [OFStdOut writeLine: @"Press A to continue"]; while (appletMainLoop()) { |
︙ | ︙ |