ObjFW  Check-in [dd18e20cea]

Overview
Comment:OFGameController: Correctly handle unknown buttons
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | gamecontroller
Files: files | file ages | folders
SHA3-256: dd18e20ceae57925cc25e0ebf1dd7178ec1f0199ae88dc6e44cc42d527129dd0
User & Date: js on 2024-05-14 21:27:45
Other Links: branch diff | manifest | tags
Context
2024-05-14
21:39
OFGameController: Fix mapping for Sony DualSense check-in: 4c804d8fa7 user: js tags: gamecontroller
21:27
OFGameController: Correctly handle unknown buttons check-in: dd18e20cea user: js tags: gamecontroller
20:56
OFGameController: Try all XInput versions check-in: 6032aeea55 user: js tags: gamecontroller
Changes

Modified src/hid/platform/Linux/OFGameController.m from [91b0510999] to [0e451122ed].

395
396
397
398
399
400
401


402
403
404
405
406
407
408
409
410
411
412
413
414
415


416
417
418
419
420
421

422
423
424
425
426
427
428
}

- (void)retrieveState
{
	struct input_event event;

	for (;;) {


		errno = 0;

		if (read(_fd, &event, sizeof(event)) < (int)sizeof(event)) {
			if (errno == EWOULDBLOCK)
				return;

			@throw [OFReadFailedException
			    exceptionWithObject: self
				requestedLength: sizeof(event)
					  errNo: errno];
		}

		switch (event.type) {
		case EV_KEY:


			if (event.value)
				[_pressedButtons addObject: buttonToName(
				    event.code, _vendorID, _productID)];
			else
				[_pressedButtons removeObject: buttonToName(
				    event.code, _vendorID, _productID)];

			break;
		case EV_ABS:
			switch (event.code) {
			case ABS_X:
				_leftAnalogStickPosition.x = scale(event.value,
				    _leftAnalogStickMinX, _leftAnalogStickMaxX);
				break;







>
>














>
>
|
|
<
|
|
<
>







395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421

422
423

424
425
426
427
428
429
430
431
}

- (void)retrieveState
{
	struct input_event event;

	for (;;) {
		OFGameControllerButton button;

		errno = 0;

		if (read(_fd, &event, sizeof(event)) < (int)sizeof(event)) {
			if (errno == EWOULDBLOCK)
				return;

			@throw [OFReadFailedException
			    exceptionWithObject: self
				requestedLength: sizeof(event)
					  errNo: errno];
		}

		switch (event.type) {
		case EV_KEY:
			if ((button = buttonToName(event.code, _vendorID,
			    _productID)) != nil) {
				if (event.value)
					[_pressedButtons addObject: button];

				else
					[_pressedButtons removeObject: button];

			}
			break;
		case EV_ABS:
			switch (event.code) {
			case ABS_X:
				_leftAnalogStickPosition.x = scale(event.value,
				    _leftAnalogStickMinX, _leftAnalogStickMaxX);
				break;