ObjFW  Check-in [ca175fe9db]

Overview
Comment:Make game controller tests work on Nintendo DS
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | gamecontroller
Files: files | file ages | folders
SHA3-256: ca175fe9db0c03efc530824e89c83ff3131851d4cc9624a4a75aeac1ceb87a00
User & Date: js on 2024-05-19 14:18:11
Other Links: branch diff | manifest | tags
Context
2024-05-20
01:17
OFGameController: Add support for Wii check-in: 918c9d077a user: js tags: gamecontroller
2024-05-19
14:18
Make game controller tests work on Nintendo DS check-in: ca175fe9db user: js tags: gamecontroller
00:21
OFGameController: Fix analog stick on 3DS check-in: 551a37ad2e user: js tags: gamecontroller
Changes

Modified .fossil-settings/ignore-glob from [72aeb66fdd] to [6d33fb85c7].

41
42
43
44
45
46
47


48
49
50
51
52
53
54
tests/DerivedData
tests/EBOOT.PBP
tests/Info.plist
tests/PARAM.SFO
tests/big_dictionary_msgpack_gz.m
tests/gamecontroller/gamecontroller_tests
tests/gamecontroller/gamecontroller_tests.3dsx


tests/iOS.xcodeproj/*.pbxuser
tests/iOS.xcodeproj/project.xcworkspace
tests/iOS.xcodeproj/xcuserdata
tests/objc_sync/objc_sync
tests/plugin/Info.plist
tests/subprocess/subprocess
tests/terminal/terminal_tests







>
>







41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
tests/DerivedData
tests/EBOOT.PBP
tests/Info.plist
tests/PARAM.SFO
tests/big_dictionary_msgpack_gz.m
tests/gamecontroller/gamecontroller_tests
tests/gamecontroller/gamecontroller_tests.3dsx
tests/gamecontroller/gamecontroller_tests.arm9
tests/gamecontroller/gamecontroller_tests.nds
tests/iOS.xcodeproj/*.pbxuser
tests/iOS.xcodeproj/project.xcworkspace
tests/iOS.xcodeproj/xcuserdata
tests/objc_sync/objc_sync
tests/plugin/Info.plist
tests/subprocess/subprocess
tests/terminal/terminal_tests

Modified tests/gamecontroller/GameControllerTests.m from [5f6bd34a27] to [e818d4f2e1].

23
24
25
26
27
28
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
62
63
64


65
66
67
68
69
70
71
#import "OFArray.h"
#import "OFColor.h"
#import "OFGameController.h"
#import "OFNumber.h"
#import "OFSet.h"
#import "OFStdIOStream.h"
#import "OFThread.h"








#ifdef OF_NINTENDO_3DS
/* Newer versions of libctru started using id as a parameter name. */
# define id id_3ds
# include <3ds.h>
# undef id
# define BUTTONS_PER_LINE 3
#endif

#ifndef BUTTONS_PER_LINE
# define BUTTONS_PER_LINE 5
#endif







@interface GameControllerTests: OFObject <OFApplicationDelegate>
@end

OF_APPLICATION_DELEGATE(GameControllerTests)

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



#if defined(OF_NINTENDO_3DS)
	gfxInitDefault();
	atexit(gfxExit);

	consoleInit(GFX_TOP, NULL);
#endif

	controllers = [OFGameController controllers];

	[OFStdOut clear];

	for (;;) {


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

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








>
>
>
>
>
>
>












>
>
>
>
>
>











>
>
|











>
>







23
24
25
26
27
28
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
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
#import "OFArray.h"
#import "OFColor.h"
#import "OFGameController.h"
#import "OFNumber.h"
#import "OFSet.h"
#import "OFStdIOStream.h"
#import "OFThread.h"

#ifdef OF_NINTENDO_DS
# define asm __asm__
# include <nds.h>
# undef asm
# define BUTTONS_PER_LINE 2
#endif

#ifdef OF_NINTENDO_3DS
/* Newer versions of libctru started using id as a parameter name. */
# define id id_3ds
# include <3ds.h>
# undef id
# define BUTTONS_PER_LINE 3
#endif

#ifndef BUTTONS_PER_LINE
# define BUTTONS_PER_LINE 5
#endif

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

	consoleInit(GFX_TOP, NULL);
#endif

	controllers = [OFGameController controllers];

	[OFStdOut clear];

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

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

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

118
119
120
121
122
123
124


125
126
127
				[OFStdOut writeFormat: @"(%5.2f, %5.2f)",
						       position.x, position.y];
			}
			[OFStdOut writeString: @"\n"];
		}

		[OFThread sleepForTimeInterval: 1.f / 60.f];


	}
}
@end







>
>



135
136
137
138
139
140
141
142
143
144
145
146
				[OFStdOut writeFormat: @"(%5.2f, %5.2f)",
						       position.x, position.y];
			}
			[OFStdOut writeString: @"\n"];
		}

		[OFThread sleepForTimeInterval: 1.f / 60.f];

		objc_autoreleasePoolPop(pool);
	}
}
@end

Modified tests/gamecontroller/Makefile from [7887f2c1f8] to [933ce281d6].

91
92
93
94
95
96
97






98
99
100
101
102
103
104
	exit $$EXIT

${PROG_NOINST}: ${LIBOBJFW_DEP_LVL2} ${LIBOBJFWRT_DEP_LVL2} \
		${LIBOBJFWHID_DEP_LVL2}

${PROG_NOINST}.3dsx: ${PROG_NOINST}
	3dsxtool $< $@







CPPFLAGS += -I../../src			\
	    -I../../src/exceptions	\
	    -I../../src/hid		\
	    -I../../src/runtime		\
	    -I../..			\
	    -DOBJFWHID_LOCAL_INCLUDES







>
>
>
>
>
>







91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
	exit $$EXIT

${PROG_NOINST}: ${LIBOBJFW_DEP_LVL2} ${LIBOBJFWRT_DEP_LVL2} \
		${LIBOBJFWHID_DEP_LVL2}

${PROG_NOINST}.3dsx: ${PROG_NOINST}
	3dsxtool $< $@

${PROG_NOINST}.arm9: ${PROG_NOINST}
	arm-none-eabi-objcopy -O binary $< $@

${PROG_NOINST}.nds: ${PROG_NOINST}.arm9
	ndstool -c $@ -9 ${PROG_NOINST}

CPPFLAGS += -I../../src			\
	    -I../../src/exceptions	\
	    -I../../src/hid		\
	    -I../../src/runtime		\
	    -I../..			\
	    -DOBJFWHID_LOCAL_INCLUDES