ObjFW  Check-in [32e67cf259]

Overview
Comment:tests/gamecontroller: Check for new controllers
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | gamecontroller
Files: files | file ages | folders
SHA3-256: 32e67cf25914ee5904ddc5e67b323feab614145ed39e105ec3b47fa55cd6ae5b
User & Date: js on 2024-05-20 01:36:43
Other Links: branch diff | manifest | tags
Context
2024-05-20
01:42
tests/gamecontroller: Clear screen when necessary check-in: 6a8f71e065 user: js tags: gamecontroller
01:36
tests/gamecontroller: Check for new controllers check-in: 32e67cf259 user: js tags: gamecontroller
01:17
OFGameController: Add support for Wii check-in: 918c9d077a user: js tags: gamecontroller
Changes

Modified tests/gamecontroller/GameControllerTests.m from [8fea7e2a6d] to [e40dd8a1f4].

18
19
20
21
22
23
24

25
26
27
28
29
30
31
 */

#include "config.h"

#import "OFApplication.h"
#import "OFArray.h"
#import "OFColor.h"

#import "OFGameController.h"
#import "OFNumber.h"
#import "OFSet.h"
#import "OFStdIOStream.h"
#import "OFThread.h"

#ifdef OF_WII







>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 */

#include "config.h"

#import "OFApplication.h"
#import "OFArray.h"
#import "OFColor.h"
#import "OFDate.h"
#import "OFGameController.h"
#import "OFNumber.h"
#import "OFSet.h"
#import "OFStdIOStream.h"
#import "OFThread.h"

#ifdef OF_WII
56
57
58
59
60
61
62




63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#if defined(OF_WII) || defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS)
# define red maroon
# define yellow olive
# define gray silver
#endif

@interface GameControllerTests: OFObject <OFApplicationDelegate>




@end

OF_APPLICATION_DELEGATE(GameControllerTests)

@implementation GameControllerTests
- (void)applicationDidFinishLaunching: (OFNotification *)notification
{
	OFArray *controllers;

#if defined(OF_WII)
	GXRModeObj *mode;
	void *nextFB;

	VIDEO_Init();

	mode = VIDEO_GetPreferredMode(NULL);







>
>
>
>







<
<







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
#if defined(OF_WII) || defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS)
# define red maroon
# define yellow olive
# define gray silver
#endif

@interface GameControllerTests: OFObject <OFApplicationDelegate>
{
	OFArray OF_GENERIC(OFGameController) *_controllers;
	OFDate *_lastControllersUpdate;
}
@end

OF_APPLICATION_DELEGATE(GameControllerTests)

@implementation GameControllerTests
- (void)applicationDidFinishLaunching: (OFNotification *)notification
{


#if defined(OF_WII)
	GXRModeObj *mode;
	void *nextFB;

	VIDEO_Init();

	mode = VIDEO_GetPreferredMode(NULL);
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
#elif defined(OF_NINTENDO_3DS)
	gfxInitDefault();
	atexit(gfxExit);

	consoleInit(GFX_TOP, NULL);
#endif

	controllers = [OFGameController controllers];

	[OFStdOut clear];

	for (;;) {
		void *pool = objc_autoreleasePoolPush();

#ifdef OF_WII



		/* Wii needs some time before controllers are found. */
		controllers = [OFGameController controllers];
#endif



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

		for (OFGameController *controller in controllers) {
			OFArray OF_GENERIC(OFGameControllerButton) *buttons =
			    controller.buttons.allObjects.sortedArray;
			size_t i = 0;

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








<
<





|
>
>
>
|
|
<
>
>



|







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
#elif defined(OF_NINTENDO_3DS)
	gfxInitDefault();
	atexit(gfxExit);

	consoleInit(GFX_TOP, NULL);
#endif



	[OFStdOut clear];

	for (;;) {
		void *pool = objc_autoreleasePoolPush();

		if (_lastControllersUpdate == nil ||
		    -[_lastControllersUpdate timeIntervalSinceNow] > 1) {
			[_controllers release];
			[_lastControllersUpdate release];

			_controllers = [[OFGameController controllers] retain];

			_lastControllersUpdate = [[OFDate alloc] init];
		}

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

		for (OFGameController *controller in _controllers) {
			OFArray OF_GENERIC(OFGameControllerButton) *buttons =
			    controller.buttons.allObjects.sortedArray;
			size_t i = 0;

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