annotate test/testcursor.c @ 1876:406b8325ee34

Fixed bug #147 Only enable Unicode key events if Unicode translation is enabled.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 23 Jun 2006 04:27:55 +0000
parents fe99535ac064
children 2780f547f5e7
rev   line source
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
1 #include <stdio.h>
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
2 #include <stdlib.h>
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
3
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
4 #include "SDL.h"
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
5
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
6 /* This is an example 16x16 cursor
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
7 top left : black
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
8 top right : inverted color or black
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
9 bottom left: white
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
10 bottom right: transparent
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
11 (swap left and right for different endianness)
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
12 */
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
13
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
14 Uint16 cursor_data[16]={
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
15 0xffff,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
16 0xffff,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
17 0xffff,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
18 0xffff,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
19
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
20 0xffff,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
21 0xffff,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
22 0xffff,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
23 0xffff,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
24
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
25 0x0000,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
26 0x0000,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
27 0x0000,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
28 0x0000,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
29
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
30 0x0000,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
31 0x0000,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
32 0x0000,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
33 0x0000
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
34 };
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
35
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
36 Uint16 cursor_mask[16]={
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
37 0xff00,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
38 0xff00,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
39 0xff00,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
40 0xff00,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
41
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
42 0xff00,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
43 0xff00,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
44 0xff00,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
45 0xff00,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
46
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
47 0xff00,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
48 0xff00,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
49 0xff00,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
50 0xff00,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
51
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
52 0xff00,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
53 0xff00,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
54 0xff00,
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
55 0xff00
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
56 };
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
57
1862
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
58
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
59 /* XPM */
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
60 static const char *arrow[] = {
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
61 /* width height num_colors chars_per_pixel */
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
62 " 32 32 3 1",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
63 /* colors */
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
64 "X c #000000",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
65 ". c #ffffff",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
66 " c None",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
67 /* pixels */
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
68 "X ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
69 "XX ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
70 "X.X ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
71 "X..X ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
72 "X...X ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
73 "X....X ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
74 "X.....X ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
75 "X......X ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
76 "X.......X ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
77 "X........X ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
78 "X.....XXXXX ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
79 "X..X..X ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
80 "X.X X..X ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
81 "XX X..X ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
82 "X X..X ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
83 " X..X ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
84 " X..X ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
85 " X..X ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
86 " XX ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
87 " ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
88 " ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
89 " ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
90 " ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
91 " ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
92 " ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
93 " ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
94 " ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
95 " ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
96 " ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
97 " ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
98 " ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
99 " ",
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
100 "0,0"
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
101 };
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
102
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
103 static SDL_Cursor *create_arrow_cursor()
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
104 {
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
105 int i, row, col;
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
106 Uint8 data[4*32];
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
107 Uint8 mask[4*32];
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
108 int hot_x, hot_y;
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
109
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
110 i = -1;
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
111 for ( row=0; row<32; ++row ) {
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
112 for ( col=0; col<32; ++col ) {
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
113 if ( col % 8 ) {
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
114 data[i] <<= 1;
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
115 mask[i] <<= 1;
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
116 } else {
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
117 ++i;
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
118 data[i] = mask[i] = 0;
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
119 }
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
120 switch (arrow[4+row][col]) {
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
121 case 'X':
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
122 data[i] |= 0x01;
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
123 mask[i] |= 0x01;
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
124 break;
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
125 case '.':
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
126 mask[i] |= 0x01;
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
127 break;
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
128 case ' ':
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
129 break;
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
130 }
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
131 }
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
132 }
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
133 sscanf(arrow[4+row], "%d,%d", &hot_x, &hot_y);
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
134 return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y);
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
135 }
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
136
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
137
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
138 int main(int argc, char *argv[])
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
139 {
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
140 SDL_Surface *screen;
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
141 SDL_bool quit = SDL_FALSE, first_time = SDL_TRUE;
1862
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
142 SDL_Cursor *cursor[2];
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
143 int current;
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
144
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
145 /* Load the SDL library */
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
146 if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
147 fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
148 return(1);
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
149 }
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
150
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
151 screen = SDL_SetVideoMode(320,200,8,SDL_ANYFORMAT);
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
152 if (screen==NULL) {
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
153 fprintf(stderr, "Couldn't initialize video mode: %s\n",SDL_GetError());
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
154 return(1);
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
155 }
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
156
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
157 SDL_FillRect(screen, NULL, 0x664422);
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
158
1862
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
159 cursor[0] = SDL_CreateCursor((Uint8 *)cursor_data, (Uint8 *)cursor_mask,
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
160 16, 16, 8, 8);
1862
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
161 if (cursor[0]==NULL) {
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
162 fprintf(stderr, "Couldn't initialize test cursor: %s\n",SDL_GetError());
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
163 SDL_Quit();
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
164 return(1);
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
165 }
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
166 cursor[1] = create_arrow_cursor();
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
167 if (cursor[1]==NULL) {
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
168 fprintf(stderr, "Couldn't initialize arrow cursor: %s\n",SDL_GetError());
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
169 SDL_FreeCursor(cursor[0]);
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
170 SDL_Quit();
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
171 return(1);
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
172 }
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
173
1862
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
174 current = 0;
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
175 SDL_SetCursor(cursor[current]);
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
176
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
177 while (!quit) {
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
178 SDL_Event event;
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
179 while (SDL_PollEvent(&event)) {
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
180 switch(event.type) {
1862
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
181 case SDL_MOUSEBUTTONDOWN:
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
182 current = !current;
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
183 SDL_SetCursor(cursor[current]);
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
184 break;
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
185 case SDL_KEYDOWN:
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
186 if (event.key.keysym.sym == SDLK_ESCAPE) {
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
187 quit = SDL_TRUE;
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
188 }
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
189 break;
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
190 case SDL_QUIT:
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
191 quit = SDL_TRUE;
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
192 break;
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
193 }
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
194 }
1862
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
195 SDL_Flip(screen);
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
196 SDL_Delay(1);
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
197 }
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
198
1862
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
199 SDL_FreeCursor(cursor[0]);
fe99535ac064 Test case for bug #240
Sam Lantinga <slouken@libsdl.org>
parents: 1859
diff changeset
200 SDL_FreeCursor(cursor[1]);
1858
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
201
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
202 SDL_Quit();
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
203 return(0);
d3ac464fb3c1 Add program to test mouse cursor change
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
204 }