ObjFW  Check-in [55a1492876]

Overview
Comment:OFGameController: Handle analog triggers on Linux
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | gamecontroller
Files: files | file ages | folders
SHA3-256: 55a14928769f9e213e584bde1087ac110a67378bc926c8b91b5ee45c47601c4f
User & Date: js on 2024-05-09 15:24:10
Other Links: branch diff | manifest | tags
Context
2024-05-09
15:39
OFGameController: Change API for analog sticks check-in: 5547016712 user: js tags: gamecontroller
15:24
OFGameController: Handle analog triggers on Linux check-in: 55a1492876 user: js tags: gamecontroller
15:13
OFGameController: Handle D-Pad via ABS_HAT0[XY] check-in: 4fc79b14db user: js tags: gamecontroller
Changes

Modified src/platform/Linux/OFGameController.m from [f6f484278c] to [564dd9be04].

62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
	case BTN_X:
		return @"X";
	case BTN_Y:
		return @"Y";
	case BTN_Z:
		return @"Z";
	case BTN_TL:
		return @"TL";
	case BTN_TR:
		return @"TR";
	case BTN_TL2:
		return @"TL2";
	case BTN_TR2:
		return @"TR2";
	case BTN_SELECT:
		return @"Select";
	case BTN_START:
		return @"Start";
	case BTN_MODE:
		return @"Mode";
	case BTN_THUMBL:







|

|

|

|







62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
	case BTN_X:
		return @"X";
	case BTN_Y:
		return @"Y";
	case BTN_Z:
		return @"Z";
	case BTN_TL:
		return @"L";
	case BTN_TR:
		return @"R";
	case BTN_TL2:
		return @"ZL";
	case BTN_TR2:
		return @"ZR";
	case BTN_SELECT:
		return @"Select";
	case BTN_START:
		return @"Start";
	case BTN_MODE:
		return @"Mode";
	case BTN_THUMBL:
210
211
212
213
214
215
216





217
218
219
220
221
222
223
			if (OFBitSetIsSet(absBits, ABS_HAT0X) &&
			    OFBitSetIsSet(absBits, ABS_HAT0Y)) {
				[_buttons addObject: @"D-Pad Left"];
				[_buttons addObject: @"D-Pad Right"];
				[_buttons addObject: @"D-Pad Up"];
				[_buttons addObject: @"D-Pad Down"];
			}





		}

		[_buttons makeImmutable];
	} @catch (id e) {
		[self release];
		@throw e;
	}







>
>
>
>
>







210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
			if (OFBitSetIsSet(absBits, ABS_HAT0X) &&
			    OFBitSetIsSet(absBits, ABS_HAT0Y)) {
				[_buttons addObject: @"D-Pad Left"];
				[_buttons addObject: @"D-Pad Right"];
				[_buttons addObject: @"D-Pad Up"];
				[_buttons addObject: @"D-Pad Down"];
			}

			if (OFBitSetIsSet(absBits, ABS_Z))
				[_buttons addObject: @"ZL"];
			if (OFBitSetIsSet(absBits, ABS_RZ))
				[_buttons addObject: @"ZR"];
		}

		[_buttons makeImmutable];
	} @catch (id e) {
		[self release];
		@throw e;
	}
319
320
321
322
323
324
325












326
327
328
329
330
331
332
				} else {
					[_pressedButtons removeObject:
					    @"D-Pad Up"];
					[_pressedButtons removeObject:
					    @"D-Pad Down"];
				}
				break;












			}

			break;
		}
	}
}








>
>
>
>
>
>
>
>
>
>
>
>







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
				} else {
					[_pressedButtons removeObject:
					    @"D-Pad Up"];
					[_pressedButtons removeObject:
					    @"D-Pad Down"];
				}
				break;
			case ABS_Z:
				if (event.value > 0)
					[_pressedButtons addObject: @"ZL"];
				else
					[_pressedButtons removeObject: @"ZL"];
				break;
			case ABS_RZ:
				if (event.value > 0)
					[_pressedButtons addObject: @"ZR"];
				else
					[_pressedButtons removeObject: @"ZR"];
				break;
			}

			break;
		}
	}
}