Differences From Artifact [c449fe09b2]:
- File src/platform/NintendoDS/OFGameController.m — part of check-in [336ecd9bdc] at 2024-05-09 19:46:06 on branch gamecontroller — OFGameController: Support for pressure sensitivity (user: js, size: 3742) [annotate] [blame] [check-ins using]
To Artifact [4b17f6e4a3]:
- File
src/platform/NintendoDS/OFGameController.m
— part of check-in
[0f902d87eb]
at
2024-05-09 23:41:48
on branch gamecontroller
— OFGameController: Retrieve state explicitly
This avoids retrieving it multiple times when reading multiple things. (user: js, size: 3932) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
61 62 63 64 65 66 67 | - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)of_init { | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | 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 | - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)of_init { self = [super init]; @try { _pressedButtons = [[OFMutableSet alloc] initWithCapacity: 12]; [self retrieveState]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_pressedButtons release]; [super dealloc]; } - (void)retrieveState { uint32 keys; scanKeys(); keys = keysCurrent(); [_pressedButtons removeAllObjects]; if (keys & KEY_A) [_pressedButtons addObject: OFGameControllerButtonA]; if (keys & KEY_B) [_pressedButtons addObject: OFGameControllerButtonB]; if (keys & KEY_SELECT) [_pressedButtons addObject: OFGameControllerButtonSelect]; if (keys & KEY_START) [_pressedButtons addObject: OFGameControllerButtonStart]; if (keys & KEY_RIGHT) [_pressedButtons addObject: OFGameControllerButtonDPadRight]; if (keys & KEY_LEFT) [_pressedButtons addObject: OFGameControllerButtonDPadLeft]; if (keys & KEY_UP) [_pressedButtons addObject: OFGameControllerButtonDPadUp]; if (keys & KEY_DOWN) [_pressedButtons addObject: OFGameControllerButtonDPadDown]; if (keys & KEY_R) [_pressedButtons addObject: OFGameControllerButtonR]; if (keys & KEY_L) [_pressedButtons addObject: OFGameControllerButtonL]; if (keys & KEY_X) [_pressedButtons addObject: OFGameControllerButtonX]; if (keys & KEY_Y) [_pressedButtons addObject: OFGameControllerButtonY]; } - (OFString *)name { return @"Nintendo DS"; } - (OFSet OF_GENERIC(OFGameControllerButton) *)buttons { return [OFSet setWithObjects: OFGameControllerButtonA, OFGameControllerButtonB, OFGameControllerButtonSelect, OFGameControllerButtonStart, OFGameControllerButtonDPadRight, OFGameControllerButtonDPadLeft, OFGameControllerButtonDPadUp, OFGameControllerButtonDPadDown, OFGameControllerButtonR, OFGameControllerButtonL, OFGameControllerButtonX, OFGameControllerButtonY, nil]; } - (OFSet OF_GENERIC(OFGameControllerButton) *)pressedButtons { return [[_pressedButtons copy] autorelease]; } - (bool)hasLeftAnalogStick { return false; } |
︙ | ︙ |