ObjFW  Check-in [efeac48cc3]

Overview
Comment:Make game controller tests work on 3DS
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | gamecontroller
Files: files | file ages | folders
SHA3-256: efeac48cc337f95f61f92fda8d342ac9a35e618b170c6ba660b22f5e99672365
User & Date: js on 2024-05-19 00:11:45
Other Links: branch diff | manifest | tags
Context
2024-05-19
00:21
OFGameController: Fix analog stick on 3DS check-in: 551a37ad2e user: js tags: gamecontroller
00:11
Make game controller tests work on 3DS check-in: efeac48cc3 user: js tags: gamecontroller
00:06
Merge trunk into branch "gamecontroller" check-in: a13251499a user: js tags: gamecontroller
Changes

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

40
41
42
43
44
45
46

47
48
49
50
51
52
53
src/tls/libobjfwtls.*
tests/DerivedData
tests/EBOOT.PBP
tests/Info.plist
tests/PARAM.SFO
tests/big_dictionary_msgpack_gz.m
tests/gamecontroller/gamecontroller_tests

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







>







40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
src/tls/libobjfwtls.*
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

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

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
#import "OFArray.h"
#import "OFColor.h"
#import "OFGameController.h"
#import "OFNumber.h"
#import "OFSet.h"
#import "OFStdIOStream.h"
#import "OFThread.h"













@interface GameControllerTests: OFObject <OFApplicationDelegate>
@end

OF_APPLICATION_DELEGATE(GameControllerTests)

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









	OFArray *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;

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

			[controller retrieveState];

			for (OFGameControllerButton button in buttons) {
				float pressure =





				    [controller pressureForButton: button];

				if (pressure == 1)
					[OFStdOut setForegroundColor:
					    [OFColor red]];
				else if (pressure > 0.5)
					[OFStdOut setForegroundColor:
					    [OFColor yellow]];
				else if (pressure > 0)
					[OFStdOut setForegroundColor:
					    [OFColor green]];
				else
					[OFStdOut setForegroundColor:
					    [OFColor gray]];

				[OFStdOut writeFormat: @"[%@]", button];

				if (++i == 5) {
					[OFStdOut writeString: @"\n"];
					i = 0;
				} else
					[OFStdOut writeString: @" "];
			}
			[OFStdOut setForegroundColor: [OFColor gray]];
			[OFStdOut writeString: @"\n"];








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









>
>
>
>
>
>
>
>
>
|












|




|
>
>
>
>
>

















|
<







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
89
90
91
92
93
94
95
96
97
98
99
100
101

102
103
104
105
106
107
108
#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;

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

			[controller retrieveState];

			for (OFGameControllerButton button in buttons) {
				float pressure;

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

				pressure =
				    [controller pressureForButton: button];

				if (pressure == 1)
					[OFStdOut setForegroundColor:
					    [OFColor red]];
				else if (pressure > 0.5)
					[OFStdOut setForegroundColor:
					    [OFColor yellow]];
				else if (pressure > 0)
					[OFStdOut setForegroundColor:
					    [OFColor green]];
				else
					[OFStdOut setForegroundColor:
					    [OFColor gray]];

				[OFStdOut writeFormat: @"[%@]", button];

				if (++i == BUTTONS_PER_LINE) {

					i = 0;
				} else
					[OFStdOut writeString: @" "];
			}
			[OFStdOut setForegroundColor: [OFColor gray]];
			[OFStdOut writeString: @"\n"];

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

88
89
90
91
92
93
94



95
96
97
98
99
100
101
	rm -f libobjfwhid.so.${OBJFWHID_LIB_MAJOR_MINOR}; \
	rm -f objfwhid${OBJFWHID_LIB_MAJOR}.dll; \
	rm -f libobjfwhid.${OBJFWHID_LIB_MAJOR}.dylib; \
	exit $$EXIT

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




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







>
>
>







88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
	rm -f libobjfwhid.so.${OBJFWHID_LIB_MAJOR_MINOR}; \
	rm -f objfwhid${OBJFWHID_LIB_MAJOR}.dll; \
	rm -f libobjfwhid.${OBJFWHID_LIB_MAJOR}.dylib; \
	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