ObjGameKit  Check-in [1f8de6b2e2]

Overview
Comment:Add OGKCharacterTypedEvent.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1f8de6b2e22e624612a780ba5ac1a10d03e1ebf454f4b9529eaa6b96f00fe013
User & Date: js on 2012-08-28 20:00:01
Other Links: manifest | tags
Context
2012-08-28
20:10
Add a test animation. check-in: d5c8cc4029 user: js tags: trunk
20:00
Add OGKCharacterTypedEvent. check-in: 1f8de6b2e2 user: js tags: trunk
19:48
Add methods for drawing rotated. check-in: 8577d195c4 user: js tags: trunk
Changes

Modified src/OGKEvent.h from [5d7e7a26bf] to [50d5609ed0].

40
41
42
43
44
45
46






47
48
49
50
51
52
53
@end

@interface OGKKeyPressEvent: OGKKeyboardEvent
@end

@interface OGKKeyReleaseEvent: OGKKeyboardEvent
@end







@interface OGKMouseEvent: OGKEvent
@property (readonly, assign) of_point_t cursor;
@property (readonly, assign) of_point_t wheel;
@end

@interface OGKMouseMovedEvent: OGKMouseEvent







>
>
>
>
>
>







40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
@end

@interface OGKKeyPressEvent: OGKKeyboardEvent
@end

@interface OGKKeyReleaseEvent: OGKKeyboardEvent
@end

@interface OGKCharacterTypedEvent: OGKKeyboardEvent
@property (readonly, assign) of_unichar_t character;
@property (readonly, assign) unsigned modifiers;
@property (readonly, assign) BOOL repeated;
@end

@interface OGKMouseEvent: OGKEvent
@property (readonly, assign) of_point_t cursor;
@property (readonly, assign) of_point_t wheel;
@end

@interface OGKMouseMovedEvent: OGKMouseEvent

Modified src/OGKEvent.m from [5e13753beb] to [d9d82a1154].

38
39
40
41
42
43
44




















45
46
47
48
49
50
51
@end

@implementation OGKKeyPressEvent
@end

@implementation OGKKeyReleaseEvent
@end





















@implementation OGKMouseEvent
- (of_point_t)cursor
{
	return of_point(event.mouse.x, event.mouse.y);
}








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







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
@end

@implementation OGKKeyPressEvent
@end

@implementation OGKKeyReleaseEvent
@end

@implementation OGKCharacterTypedEvent
- (of_unichar_t)character
{
	if (event.keyboard.unichar < 1)
		return 0xFFFD;

	return event.keyboard.unichar;
}

- (unsigned)modifiers
{
	return event.keyboard.modifiers;
}

- (BOOL)repeated
{
	return event.keyboard.repeat;
}
@end

@implementation OGKMouseEvent
- (of_point_t)cursor
{
	return of_point(event.mouse.x, event.mouse.y);
}

Modified src/OGKEventQueue.h from [d68b9f8b49] to [2b4fafbdb3].

29
30
31
32
33
34
35


36
37
38
39
40
41
42
@optional
- (void)display: (OGKDisplay*)display
      wasClosed: (OGKCloseEvent*)event;
- (void)keyWasPressed: (OGKKeyPressEvent*)event
	      display: (OGKDisplay*)display;
- (void)keyWasReleased: (OGKKeyReleaseEvent*)event
	       display: (OGKDisplay*)display;


- (void)mouseWasMoved: (OGKMouseMovedEvent*)event
	      display: (OGKDisplay*)display;
- (void)mouseButtonWasPressed: (OGKMouseButtonPressedEvent*)event
		      display: (OGKDisplay*)display;
- (void)mouseButtonWasReleased: (OGKMouseButtonReleasedEvent*)event
		      display: (OGKDisplay*)display;
@end







>
>







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@optional
- (void)display: (OGKDisplay*)display
      wasClosed: (OGKCloseEvent*)event;
- (void)keyWasPressed: (OGKKeyPressEvent*)event
	      display: (OGKDisplay*)display;
- (void)keyWasReleased: (OGKKeyReleaseEvent*)event
	       display: (OGKDisplay*)display;
- (void)characterWasTyped: (OGKCharacterTypedEvent*)event
		  display: (OGKDisplay*)display;
- (void)mouseWasMoved: (OGKMouseMovedEvent*)event
	      display: (OGKDisplay*)display;
- (void)mouseButtonWasPressed: (OGKMouseButtonPressedEvent*)event
		      display: (OGKDisplay*)display;
- (void)mouseButtonWasReleased: (OGKMouseButtonReleasedEvent*)event
		      display: (OGKDisplay*)display;
@end

Modified src/OGKEventQueue.m from [9c06e7380d] to [53fa172d0d].

102
103
104
105
106
107
108
















109
110
111
112
113
114
115
				    allegroEvent->keyboard.display];
				OGKKeyReleaseEvent *keyReleaseEvent =
				    (OGKKeyReleaseEvent*)event;

				[delegate keyWasReleased: keyReleaseEvent
						 display: display];
			}

















			break;
		case ALLEGRO_EVENT_MOUSE_AXES:
			object_setClass(event, [OGKMouseMovedEvent class]);

			if ([delegate respondsToSelector:
			    @selector(mouseWasMoved:display:)]) {







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







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
127
128
129
130
131
				    allegroEvent->keyboard.display];
				OGKKeyReleaseEvent *keyReleaseEvent =
				    (OGKKeyReleaseEvent*)event;

				[delegate keyWasReleased: keyReleaseEvent
						 display: display];
			}

			break;
		case ALLEGRO_EVENT_KEY_CHAR:
			object_setClass(event, [OGKCharacterTypedEvent class]);

			if ([delegate respondsToSelector:
			    @selector(characterWasTyped:display:)]) {
				OGKDisplay *display = [OGKDisplay
				    OGK_displayForAllegroDisplay:
				    allegroEvent->keyboard.display];
				OGKCharacterTypedEvent *characterTypedEvent =
				    (OGKCharacterTypedEvent*)event;

				[delegate characterWasTyped: characterTypedEvent
						    display: display];
			}

			break;
		case ALLEGRO_EVENT_MOUSE_AXES:
			object_setClass(event, [OGKMouseMovedEvent class]);

			if ([delegate respondsToSelector:
			    @selector(mouseWasMoved:display:)]) {

Modified tests/TestMain.m from [d6c7c983df] to [cf73ffbefb].

33
34
35
36
37
38
39













40
41
42
43
44
45
46
	running = NO;
}

- (void)keyWasPressed: (OGKKeyPressEvent*)event
	      display: (OGKDisplay*)display
{
	of_log(@"Pressed: %d", event.keycode);














	switch (event.keycode) {
	case OGK_KEY_R:
		tint = ogk_color(1, 0.5, 0.5, 0);
		break;
	case OGK_KEY_G:
		tint = ogk_color(0.5, 1, 0.5, 0);







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







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
	running = NO;
}

- (void)keyWasPressed: (OGKKeyPressEvent*)event
	      display: (OGKDisplay*)display
{
	of_log(@"Pressed: %d", event.keycode);
}

- (void)keyWasReleased: (OGKKeyReleaseEvent*)event
	       display: (OGKDisplay*)display
{
	of_log(@"Released: %d", event.keycode);
}

- (void)characterWasTyped: (OGKCharacterTypedEvent*)event
		  display: (OGKDisplay*)display
{
	of_log(@"Character typed: %u (keycode=%d, modifiers=%d, repeated=%d)",
	    event.character, event.keycode, event.modifiers, event.repeated);

	switch (event.keycode) {
	case OGK_KEY_R:
		tint = ogk_color(1, 0.5, 0.5, 0);
		break;
	case OGK_KEY_G:
		tint = ogk_color(0.5, 1, 0.5, 0);
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
		break;
	case OGK_KEY_Q:
		running = NO;
		break;
	}
}

- (void)keyWasReleased: (OGKKeyReleaseEvent*)event
	       display: (OGKDisplay*)display
{
	of_log(@"Released: %d", event.keycode);
}

- (void)mouseWasMoved: (OGKMouseMovedEvent*)event
	      display: (OGKDisplay*)display
{
	of_log(@"Mouse moved: X=%.f(%.f) Y=%.f(%.f) WX=%.f(%.f) WY=%.f(%.f)",
	    event.cursor.x, event.deltaCursor.x,
	    event.cursor.y, event.deltaCursor.y,
	    event.wheel.x, event.deltaWheel.x,







<
<
<
<
<
<







72
73
74
75
76
77
78






79
80
81
82
83
84
85
		break;
	case OGK_KEY_Q:
		running = NO;
		break;
	}
}







- (void)mouseWasMoved: (OGKMouseMovedEvent*)event
	      display: (OGKDisplay*)display
{
	of_log(@"Mouse moved: X=%.f(%.f) Y=%.f(%.f) WX=%.f(%.f) WY=%.f(%.f)",
	    event.cursor.x, event.deltaCursor.x,
	    event.cursor.y, event.deltaCursor.y,
	    event.wheel.x, event.deltaWheel.x,