ObjFW  Check-in [f333689336]

Overview
Comment:Rename OHGameController{Mapping -> Profile}
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f3336893369a3c245ba7f09aa8e9a58cf132a7017b6c061730d41d189bea853c
User & Date: js on 2024-06-03 19:45:53
Other Links: manifest | tags
Context
2024-06-03
19:53
Compile OHEvdevGameController separately check-in: 82da883fa6 user: js tags: trunk
19:45
Rename OHGameController{Mapping -> Profile} check-in: f333689336 user: js tags: trunk
19:39
ObjFWHID: Change prefix to OH check-in: afae3291bf user: js tags: trunk
Changes

Modified src/hid/Makefile from [044fff7e3a] to [3c44019c78].

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
LIB_PATCH = ${OBJFWHID_LIB_PATCH}

SRCS = OHGameController.m		\
       OHGameControllerAxis.m		\
       OHGameControllerButton.m		\
       OHGameControllerDirectionalPad.m	\
       OHGameControllerElement.m	\
       OHGameControllerMapping.m

INCLUDES := ${SRCS:.m=.h}	\
	    ObjFWHID.h

SRCS += OHGameControllerEmulatedAxis.m		\
	OHGameControllerEmulatedButton.m








|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
LIB_PATCH = ${OBJFWHID_LIB_PATCH}

SRCS = OHGameController.m		\
       OHGameControllerAxis.m		\
       OHGameControllerButton.m		\
       OHGameControllerDirectionalPad.m	\
       OHGameControllerElement.m	\
       OHGameControllerProfile.m

INCLUDES := ${SRCS:.m=.h}	\
	    ObjFWHID.h

SRCS += OHGameControllerEmulatedAxis.m		\
	OHGameControllerEmulatedButton.m

Modified src/hid/OHEvdevGameController.h from [80bc5a0e55] to [95f3f59293].

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
 * <https://www.gnu.org/licenses/>.
 */

#import "OHGameController.h"

OF_ASSUME_NONNULL_BEGIN

@class OHGameControllerMapping;

@interface OHEvdevGameController: OHGameController
{
	OFString *_path;
	int _fd;
	bool _discardUntilReport;
	unsigned long *_evBits, *_keyBits, *_absBits;
	uint16_t _vendorID, _productID;
	OFString *_name;
	OHGameControllerMapping *_mapping;
}

- (instancetype)of_initWithPath: (OFString *)path OF_METHOD_FAMILY(init);
- (void)of_pollState;
@end

OF_ASSUME_NONNULL_END







|









|







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
 * <https://www.gnu.org/licenses/>.
 */

#import "OHGameController.h"

OF_ASSUME_NONNULL_BEGIN

@class OHGameControllerProfile;

@interface OHEvdevGameController: OHGameController
{
	OFString *_path;
	int _fd;
	bool _discardUntilReport;
	unsigned long *_evBits, *_keyBits, *_absBits;
	uint16_t _vendorID, _productID;
	OFString *_name;
	OHGameControllerProfile *_rawProfile;
}

- (instancetype)of_initWithPath: (OFString *)path OF_METHOD_FAMILY(init);
- (void)of_pollState;
@end

OF_ASSUME_NONNULL_END

Modified src/hid/OHEvdevGameController.m from [a90f4bebdd] to [4225244e9f].

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
#import "OFDictionary.h"
#import "OFFileManager.h"
#import "OFLocale.h"
#import "OFNumber.h"

#import "OHGameControllerAxis.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerMapping.h"

#include <sys/ioctl.h>
#include <linux/input.h>

#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFOpenItemFailedException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"

@interface OHEvdevGameControllerAxis: OHGameControllerAxis
{
@public
	int32_t _minValue, _maxValue;
}
@end

@interface OHEvdevGameControllerMapping: OHGameControllerMapping
- (instancetype)of_initWithButtons: (OFDictionary *)buttons
			      axes: (OFDictionary *)axes OF_METHOD_FAMILY(init);
@end

static const uint16_t buttonIDs[] = {
	BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_TL2,
	BTN_TR2, BTN_SELECT, BTN_START, BTN_MODE, BTN_THUMBL, BTN_THUMBR,







|

















|







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
#import "OFDictionary.h"
#import "OFFileManager.h"
#import "OFLocale.h"
#import "OFNumber.h"

#import "OHGameControllerAxis.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerProfile.h"

#include <sys/ioctl.h>
#include <linux/input.h>

#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFOpenItemFailedException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"

@interface OHEvdevGameControllerAxis: OHGameControllerAxis
{
@public
	int32_t _minValue, _maxValue;
}
@end

@interface OHEvdevGameControllerProfile: OHGameControllerProfile
- (instancetype)of_initWithButtons: (OFDictionary *)buttons
			      axes: (OFDictionary *)axes OF_METHOD_FAMILY(init);
@end

static const uint16_t buttonIDs[] = {
	BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_TL2,
	BTN_TR2, BTN_SELECT, BTN_START, BTN_MODE, BTN_THUMBL, BTN_THUMBR,
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
	if (value > max)
		value = max;

	return ((value - min) / (max - min) * 2) - 1;
}

@implementation OHEvdevGameController
@synthesize name = _name, unmappedMapping = _mapping;

+ (OFArray OF_GENERIC(OHGameController *) *)controllers
{
	OFMutableArray *controllers = [OFMutableArray array];
	void *pool = objc_autoreleasePoolPush();

	for (OFString *device in [[OFFileManager defaultManager]







|







263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
	if (value > max)
		value = max;

	return ((value - min) / (max - min) * 2) - 1;
}

@implementation OHEvdevGameController
@synthesize name = _name, rawProfile = _rawProfile;

+ (OFArray OF_GENERIC(OHGameController *) *)controllers
{
	OFMutableArray *controllers = [OFMutableArray array];
	void *pool = objc_autoreleasePoolPush();

	for (OFString *device in [[OFFileManager defaultManager]
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424

					[axes setObject: axis forKey: axisName];
				}
			}
		}
		[axes makeImmutable];

		_mapping = [[OHEvdevGameControllerMapping alloc]
		    of_initWithButtons: buttons
				  axes: axes];

		[self of_pollState];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {







|







410
411
412
413
414
415
416
417
418
419
420
421
422
423
424

					[axes setObject: axis forKey: axisName];
				}
			}
		}
		[axes makeImmutable];

		_rawProfile = [[OHEvdevGameControllerProfile alloc]
		    of_initWithButtons: buttons
				  axes: axes];

		[self of_pollState];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
		close(_fd);

	OFFreeMemory(_evBits);
	OFFreeMemory(_keyBits);
	OFFreeMemory(_absBits);

	[_name release];
	[_mapping release];

	[super dealloc];
}

- (OFNumber *)vendorID
{
	return [OFNumber numberWithUnsignedShort: _vendorID];







|







437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
		close(_fd);

	OFFreeMemory(_evBits);
	OFFreeMemory(_keyBits);
	OFFreeMemory(_absBits);

	[_name release];
	[_rawProfile release];

	[super dealloc];
}

- (OFNumber *)vendorID
{
	return [OFNumber numberWithUnsignedShort: _vendorID];
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
		if (!OFBitSetIsSet(_keyBits, buttonIDs[i]))
			continue;

		name = buttonToName(buttonIDs[i]);
		if (name == nil)
			continue;

		button = [_mapping.buttons objectForKey: name];
		if (button == nil)
			continue;

		if (OFBitSetIsSet(keyState, buttonIDs[i]))
			button.value = 1.f;
		else
			button.value = 0.f;







|







475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
		if (!OFBitSetIsSet(_keyBits, buttonIDs[i]))
			continue;

		name = buttonToName(buttonIDs[i]);
		if (name == nil)
			continue;

		button = [_rawProfile.buttons objectForKey: name];
		if (button == nil)
			continue;

		if (OFBitSetIsSet(keyState, buttonIDs[i]))
			button.value = 1.f;
		else
			button.value = 0.f;
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
				continue;

			name = axisToName(axisIDs[i]);
			if (name == nil)
				continue;

			axis = (OHEvdevGameControllerAxis *)
			    [_mapping.axes objectForKey: name];
			if (axis == nil)
				continue;

			if (ioctl(_fd, EVIOCGABS(axisIDs[i]), &info) == -1)
				@throw [OFReadFailedException
				    exceptionWithObject: self
					requestedLength: sizeof(info)







|







500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
				continue;

			name = axisToName(axisIDs[i]);
			if (name == nil)
				continue;

			axis = (OHEvdevGameControllerAxis *)
			    [_rawProfile.axes objectForKey: name];
			if (axis == nil)
				continue;

			if (ioctl(_fd, EVIOCGABS(axisIDs[i]), &info) == -1)
				@throw [OFReadFailedException
				    exceptionWithObject: self
					requestedLength: sizeof(info)
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
			}
			break;
		case EV_KEY:
			name = buttonToName(event.code);
			if (name == nil)
				continue;

			button = [_mapping.buttons objectForKey: name];
			if (button == nil)
				continue;

			if (event.value)
				button.value = 1.f;
			else
				button.value = 0.f;

			break;
		case EV_ABS:
			name = axisToName(event.code);
			if (name == nil)
				continue;

			axis = (OHEvdevGameControllerAxis *)
			    [_mapping.axes objectForKey: name];
			if (axis == nil)
				continue;

			axis.value = scale(event.value,
			   axis->_minValue, axis->_maxValue);

			break;







|















|







561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
			}
			break;
		case EV_KEY:
			name = buttonToName(event.code);
			if (name == nil)
				continue;

			button = [_rawProfile.buttons objectForKey: name];
			if (button == nil)
				continue;

			if (event.value)
				button.value = 1.f;
			else
				button.value = 0.f;

			break;
		case EV_ABS:
			name = axisToName(event.code);
			if (name == nil)
				continue;

			axis = (OHEvdevGameControllerAxis *)
			    [_rawProfile.axes objectForKey: name];
			if (axis == nil)
				continue;

			axis.value = scale(event.value,
			   axis->_minValue, axis->_maxValue);

			break;
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
	return OFOrderedSame;
}
@end

@implementation OHEvdevGameControllerAxis
@end

@implementation OHEvdevGameControllerMapping
- (instancetype)of_initWithButtons: (OFDictionary *)buttons
			      axes: (OFDictionary *)axes
{
	self = [super init];

	@try {
		_buttons = [buttons retain];







|







614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
	return OFOrderedSame;
}
@end

@implementation OHEvdevGameControllerAxis
@end

@implementation OHEvdevGameControllerProfile
- (instancetype)of_initWithButtons: (OFDictionary *)buttons
			      axes: (OFDictionary *)axes
{
	self = [super init];

	@try {
		_buttons = [buttons retain];

Modified src/hid/OHGameController.h from [5ae1f17798] to [f4bfdcdd03].

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43




44
45
46
47
48
49
50
# endif
#endif

OF_ASSUME_NONNULL_BEGIN

@class OFArray OF_GENERIC(ObjectType);
@class OFNumber;
@class OHGameControllerMapping;

/**
 * @class OHGameController OHGameController.h ObjFWHID/OHGameController.h
 *
 * @brief A class for reading state from a game controller.
 */
@interface OHGameController: OFObject




#ifdef OF_HAVE_CLASS_PROPERTIES
@property (class, readonly, nonatomic)
    OFArray <OHGameController *> *controllers;
#endif

/**
 * @brief The name of the controller.







|







>
>
>
>







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
# endif
#endif

OF_ASSUME_NONNULL_BEGIN

@class OFArray OF_GENERIC(ObjectType);
@class OFNumber;
@class OHGameControllerProfile;

/**
 * @class OHGameController OHGameController.h ObjFWHID/OHGameController.h
 *
 * @brief A class for reading state from a game controller.
 */
@interface OHGameController: OFObject
{
	OF_RESERVE_IVARS(OHGameController, 4)
}

#ifdef OF_HAVE_CLASS_PROPERTIES
@property (class, readonly, nonatomic)
    OFArray <OHGameController *> *controllers;
#endif

/**
 * @brief The name of the controller.
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

/**
 * @brief The product ID of the controller or `nil` if unavailable.
 */
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFNumber *productID;

/**
 * @brief An unmapped mapping for the game controller, meaning no remapping is
 *	  being performed.
 */
@property (readonly, nonatomic) OHGameControllerMapping *unmappedMapping;

/**
 * @brief Returns the available controllers.
 *
 * @return The available controllers
 */
+ (OFArray OF_GENERIC(OHGameController *) *)controllers;







|


|







62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

/**
 * @brief The product ID of the controller or `nil` if unavailable.
 */
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFNumber *productID;

/**
 * @brief The raw profile for the game controller, meaning no remapping is
 *	  being performed.
 */
@property (readonly, nonatomic) OHGameControllerProfile *rawProfile;

/**
 * @brief Returns the available controllers.
 *
 * @return The available controllers
 */
+ (OFArray OF_GENERIC(OHGameController *) *)controllers;

Modified src/hid/OHGameController.m from [b33f3a4512] to [981f445f69].

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#import "OFSet.h"

#if defined(OF_LINUX) && defined(OF_HAVE_FILES)
# include "OHEvdevGameController.h"
#endif

@implementation OHGameController
@dynamic name, unmappedMapping;

+ (OFArray OF_GENERIC(OHGameController *) *)controllers
{
#if defined(OF_LINUX) && defined(OF_HAVE_FILES)
	return [OHEvdevGameController controllers];
#else
	return [OFArray array];







|







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#import "OFSet.h"

#if defined(OF_LINUX) && defined(OF_HAVE_FILES)
# include "OHEvdevGameController.h"
#endif

@implementation OHGameController
@dynamic name, rawProfile;

+ (OFArray OF_GENERIC(OHGameController *) *)controllers
{
#if defined(OF_LINUX) && defined(OF_HAVE_FILES)
	return [OHEvdevGameController controllers];
#else
	return [OFArray array];

Renamed and modified src/hid/OHGameControllerMapping.h [c9756630f5] to src/hid/OHGameControllerProfile.h [4820b1c9dc].

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

@class OFDictionary OF_GENERIC(KeyType, ObjectType);
@class OHGameControllerAxis;
@class OHGameControllerButton;
@class OHGameControllerDirectionalPad;

/**
 * @class OHGameControllerMapping \
 *	  OHGameControllerMapping.h ObjFWHID/OHGameControllerMapping.h
 *
 * @brief A mapping for a @ref OHGameController.
 */
@interface OHGameControllerMapping: OFObject
{
	OFDictionary OF_GENERIC(OFString *, OHGameControllerButton *) *_buttons;
	OFDictionary OF_GENERIC(OFString *, OHGameControllerAxis *) *_axes;
	OFDictionary OF_GENERIC(OFString *, OHGameControllerDirectionalPad *)
	    *_directionalPads;
	OF_RESERVE_IVARS(OHGameControllerMapping, 4)
}

/**
 * @brief A map of all button names to their @ref OHGameControllerButton.
 */
@property (readonly, nonatomic)
    OFDictionary OF_GENERIC(OFString *, OHGameControllerButton *) *buttons;







|
|

|

|





|







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

@class OFDictionary OF_GENERIC(KeyType, ObjectType);
@class OHGameControllerAxis;
@class OHGameControllerButton;
@class OHGameControllerDirectionalPad;

/**
 * @class OHGameControllerProfile \
 *	  OHGameControllerProfile.h ObjFWHID/OHGameControllerProfile.h
 *
 * @brief A profile for a @ref OHGameController.
 */
@interface OHGameControllerProfile: OFObject
{
	OFDictionary OF_GENERIC(OFString *, OHGameControllerButton *) *_buttons;
	OFDictionary OF_GENERIC(OFString *, OHGameControllerAxis *) *_axes;
	OFDictionary OF_GENERIC(OFString *, OHGameControllerDirectionalPad *)
	    *_directionalPads;
	OF_RESERVE_IVARS(OHGameControllerProfile, 4)
}

/**
 * @brief A map of all button names to their @ref OHGameControllerButton.
 */
@property (readonly, nonatomic)
    OFDictionary OF_GENERIC(OFString *, OHGameControllerButton *) *buttons;

Renamed and modified src/hid/OHGameControllerMapping.m [f68efd6f5e] to src/hid/OHGameControllerProfile.m [e824f05e06].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 * 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 "OHGameControllerMapping.h"
#import "OFDictionary.h"

@implementation OHGameControllerMapping: OFObject
@synthesize buttons = _buttons, axes = _axes;
@synthesize directionalPads = _directionalPads;

- (void)dealloc
{
	[_buttons release];
	[_axes release];







|


|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 * 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 "OHGameControllerProfile.h"
#import "OFDictionary.h"

@implementation OHGameControllerProfile: OFObject
@synthesize buttons = _buttons, axes = _axes;
@synthesize directionalPads = _directionalPads;

- (void)dealloc
{
	[_buttons release];
	[_axes release];

Modified src/test/OTAppDelegate.m from [c2558fe049] to [d24b6ba652].

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#import "OFThread.h"
#import "OFValue.h"

#import "OTTestCase.h"

#import "OHGameController.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerMapping.h"

#import "OTAssertionFailedException.h"
#import "OTTestSkippedException.h"

#ifdef OF_IOS
# include <CoreFoundation/CoreFoundation.h>
#endif







|







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#import "OFThread.h"
#import "OFValue.h"

#import "OTTestCase.h"

#import "OHGameController.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerProfile.h"

#import "OTAssertionFailedException.h"
#import "OTTestSkippedException.h"

#ifdef OF_IOS
# include <CoreFoundation/CoreFoundation.h>
#endif
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
		[OFStdOut writeLine: @"Press A to continue"];

		for (;;) {
			void *pool = objc_autoreleasePoolPush();
			OHGameController *controller =
			    [[OHGameController controllers] objectAtIndex: 0];
			OHGameControllerButton *button =
			    [controller.unmappedMapping.buttons
			    objectForKey: @"A"];

			[controller retrieveState];

			if (button.pressed)
				break;

			[OFThread waitForVerticalBlank];







<
|







284
285
286
287
288
289
290

291
292
293
294
295
296
297
298
		[OFStdOut writeLine: @"Press A to continue"];

		for (;;) {
			void *pool = objc_autoreleasePoolPush();
			OHGameController *controller =
			    [[OHGameController controllers] objectAtIndex: 0];
			OHGameControllerButton *button =

			    [controller.rawProfile.buttons objectForKey: @"A"];

			[controller retrieveState];

			if (button.pressed)
				break;

			[OFThread waitForVerticalBlank];
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565

	for (;;) {
		void *pool = objc_autoreleasePoolPush();
		OHGameController *controller =
		    [[OHGameController controllers] objectAtIndex: 0];
		OHGameControllerButton *button =
# ifdef OF_WII
		    [controller.unmappedMapping.buttons objectForKey: @"Home"];
# else
		    [controller.unmappedMapping.buttons objectForKey: @"Start"];
# endif

		[controller retrieveState];

		if (button.pressed)
			break;








|

|







548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564

	for (;;) {
		void *pool = objc_autoreleasePoolPush();
		OHGameController *controller =
		    [[OHGameController controllers] objectAtIndex: 0];
		OHGameControllerButton *button =
# ifdef OF_WII
		    [controller.rawProfile.buttons objectForKey: @"Home"];
# else
		    [controller.rawProfile.buttons objectForKey: @"Start"];
# endif

		[controller retrieveState];

		if (button.pressed)
			break;

Modified tests/gamecontroller/GameControllerTests.m from [f7c9148fed] to [049667648c].

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#import "OFNumber.h"
#import "OFStdIOStream.h"
#import "OFThread.h"

#import "OHGameController.h"
#import "OHGameControllerAxis.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerMapping.h"

#import "OFReadFailedException.h"

#if defined(OF_NINTENDO_DS)
static size_t buttonsPerLine = 2;
#elif defined(OF_NINTENDO_3DS)
static size_t buttonsPerLine = 3;







|







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#import "OFNumber.h"
#import "OFStdIOStream.h"
#import "OFThread.h"

#import "OHGameController.h"
#import "OHGameControllerAxis.h"
#import "OHGameControllerButton.h"
#import "OHGameControllerProfile.h"

#import "OFReadFailedException.h"

#if defined(OF_NINTENDO_DS)
static size_t buttonsPerLine = 2;
#elif defined(OF_NINTENDO_3DS)
static size_t buttonsPerLine = 3;
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

			[OFStdOut clear];
		}

		[OFStdOut setCursorPosition: OFMakePoint(0, 0)];

		for (OHGameController *controller in _controllers) {
			OHGameControllerMapping *mapping =
			    controller.unmappedMapping;
			OFArray OF_GENERIC(OFString *) *buttons =
			    mapping.buttons.allKeys.sortedArray;
			OFArray OF_GENERIC(OFString *) *axes =
			    mapping.axes.allKeys.sortedArray;
			size_t i;

			[OFStdOut setForegroundColor: [OFColor green]];
			[OFStdOut writeString: controller.description];

			@try {
				[controller retrieveState];
			} @catch (OFReadFailedException *e) {
				[OFStdOut setForegroundColor: [OFColor red]];
				[OFStdOut writeFormat: @"\n%@", e.description];
				continue;
			}

			i = 0;
			for (OFString *name in buttons) {
				OHGameControllerButton *button =
				    [mapping.buttons objectForKey: name];

				if (i == 0)
					[OFStdOut writeString: @"\n"];

				if (button.value == 1)
					[OFStdOut setForegroundColor:
					    [OFColor red]];







|
|

|

|
















|







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

			[OFStdOut clear];
		}

		[OFStdOut setCursorPosition: OFMakePoint(0, 0)];

		for (OHGameController *controller in _controllers) {
			OHGameControllerProfile *profile =
			    controller.rawProfile;
			OFArray OF_GENERIC(OFString *) *buttons =
			    profile.buttons.allKeys.sortedArray;
			OFArray OF_GENERIC(OFString *) *axes =
			    profile.axes.allKeys.sortedArray;
			size_t i;

			[OFStdOut setForegroundColor: [OFColor green]];
			[OFStdOut writeString: controller.description];

			@try {
				[controller retrieveState];
			} @catch (OFReadFailedException *e) {
				[OFStdOut setForegroundColor: [OFColor red]];
				[OFStdOut writeFormat: @"\n%@", e.description];
				continue;
			}

			i = 0;
			for (OFString *name in buttons) {
				OHGameControllerButton *button =
				    [profile.buttons objectForKey: name];

				if (i == 0)
					[OFStdOut writeString: @"\n"];

				if (button.value == 1)
					[OFStdOut setForegroundColor:
					    [OFColor red]];
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
			}
			[OFStdOut setForegroundColor: [OFColor gray]];
			[OFStdOut writeString: @"\n"];

			i = 0;
			for (OFString *name in axes) {
				OHGameControllerAxis *axis =
				    [mapping.axes objectForKey: name];

				if (i == 0)
					[OFStdOut writeString: @"\n"];

				[OFStdOut writeFormat: @"%@: %5.2f ",
						       name, axis.value];








|







132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
			}
			[OFStdOut setForegroundColor: [OFColor gray]];
			[OFStdOut writeString: @"\n"];

			i = 0;
			for (OFString *name in axes) {
				OHGameControllerAxis *axis =
				    [profile.axes objectForKey: name];

				if (i == 0)
					[OFStdOut writeString: @"\n"];

				[OFStdOut writeFormat: @"%@: %5.2f ",
						       name, axis.value];