Rev 1 | Rev 10 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1 | Rev 7 | ||
---|---|---|---|
Line 7... | Line 7... | ||
7 | * named README, which can be found in the root of this distribution. By |
7 | * named README, which can be found in the root of this distribution. By |
8 | * using this software in any fashion, you are agreeing to be bound by the |
8 | * using this software in any fashion, you are agreeing to be bound by the |
9 | * terms of this license. |
9 | * terms of this license. |
10 | * |
10 | * |
11 | * You must not remove this notice, or any other, from this software. |
11 | * You must not remove this notice, or any other, from this software. |
12 | */ |
- | |
13 | - | ||
14 | /* |
- | |
15 | * 20021010 SDLK_n replaced by SDLK_Fn because some non-US keyboards |
- | |
16 | * requires that SHIFT be pressed to input numbers. |
- | |
17 | */ |
12 | */ |
18 | 13 | ||
19 | #include <SDL.h> |
14 | #include <SDL.h> |
20 | 15 | ||
21 | #include "system.h" |
16 | #include "system.h" |
Line 27... | Line 22... | ||
27 | #define SYSJOY_RANGE 3280 |
22 | #define SYSJOY_RANGE 3280 |
28 | 23 | ||
29 | static SDL_Event event; |
24 | static SDL_Event event; |
30 | extern U8 want_filter; |
25 | extern U8 want_filter; |
31 | extern U8 want_fullscreen; |
26 | extern U8 want_fullscreen; |
32 | extern U8 |
27 | extern U8 recreate_screen; |
33 | 28 | ||
34 | 29 | ||
35 | /* |
30 | /* |
36 | * Process an event |
31 | * Process an event |
37 | */ |
32 | */ |
38 | static void processEvent (void) |
33 | static void processEvent (void) |
39 | { |
34 | { |
40 | static U8 alt_pressed = FALSE; |
35 | static U8 alt_pressed = FALSE; |
41 | 36 | ||
42 | U16 key = event.key.keysym. |
37 | U16 key = event.key.keysym.scancode; |
43 | 38 | ||
44 | switch (event.type) |
39 | switch (event.type) |
45 | { |
40 | { |
46 | case SDL_KEYDOWN: |
41 | case SDL_KEYDOWN: |
47 | if (key == |
42 | if (key == SDL_SCANCODE_LALT) |
48 | alt_pressed = TRUE; |
43 | alt_pressed = TRUE; |
49 | else if (alt_pressed && key == |
44 | else if (alt_pressed && key == SDL_SCANCODE_RETURN) |
50 | { |
45 | { |
51 | want_fullscreen ^= TRUE; |
46 | want_fullscreen ^= TRUE; |
52 |
|
47 | recreate_screen = TRUE; |
53 | } |
48 | } |
54 | else if (alt_pressed && key == |
49 | else if (alt_pressed && key == SDL_SCANCODE_F4) |
55 | { |
50 | { |
56 | control_status |= CONTROL_EXIT; |
51 | control_status |= CONTROL_EXIT; |
57 | control_last = CONTROL_EXIT; |
52 | control_last = CONTROL_EXIT; |
58 | } |
53 | } |
59 | else if (key == |
54 | else if (key == SDL_SCANCODE_O || key == SDL_SCANCODE_UP) |
60 | { |
55 | { |
61 | control_status |= CONTROL_UP; |
56 | control_status |= CONTROL_UP; |
62 | control_last = CONTROL_UP; |
57 | control_last = CONTROL_UP; |
63 | } |
58 | } |
64 | else if (key == |
59 | else if (key == SDL_SCANCODE_K || key == SDL_SCANCODE_DOWN) |
65 | { |
60 | { |
66 | control_status |= CONTROL_DOWN; |
61 | control_status |= CONTROL_DOWN; |
67 | control_last = CONTROL_DOWN; |
62 | control_last = CONTROL_DOWN; |
68 | } |
63 | } |
69 | else if (key == |
64 | else if (key == SDL_SCANCODE_Z || key == SDL_SCANCODE_LEFT) |
70 | { |
65 | { |
71 | control_status |= CONTROL_LEFT; |
66 | control_status |= CONTROL_LEFT; |
72 | control_last = CONTROL_LEFT; |
67 | control_last = CONTROL_LEFT; |
73 | } |
68 | } |
74 | else if (key == |
69 | else if (key == SDL_SCANCODE_X || key == SDL_SCANCODE_RIGHT) |
75 | { |
70 | { |
76 | control_status |= CONTROL_RIGHT; |
71 | control_status |= CONTROL_RIGHT; |
77 | control_last = CONTROL_RIGHT; |
72 | control_last = CONTROL_RIGHT; |
78 | } |
73 | } |
79 | else if (key == |
74 | else if (key == SDL_SCANCODE_PAUSE) |
80 | { |
75 | { |
81 | control_status |= CONTROL_PAUSE; |
76 | control_status |= CONTROL_PAUSE; |
82 | control_last = CONTROL_PAUSE; |
77 | control_last = CONTROL_PAUSE; |
83 | } |
78 | } |
84 | else if (key == |
79 | else if (key == SDL_SCANCODE_END) |
85 | { |
80 | { |
86 | control_status |= CONTROL_END; |
81 | control_status |= CONTROL_END; |
87 | control_last = CONTROL_END; |
82 | control_last = CONTROL_END; |
88 | } |
83 | } |
89 | else if (key == |
84 | else if (key == SDL_SCANCODE_ESCAPE) |
90 | { |
85 | { |
91 | control_status |= CONTROL_EXIT; |
86 | control_status |= CONTROL_EXIT; |
92 | control_last = CONTROL_EXIT; |
87 | control_last = CONTROL_EXIT; |
93 | } |
88 | } |
94 | else if (key == |
89 | else if (key == SDL_SCANCODE_SPACE) |
95 | { |
90 | { |
96 | control_status |= CONTROL_FIRE; |
91 | control_status |= CONTROL_FIRE; |
97 | control_last = CONTROL_FIRE; |
92 | control_last = CONTROL_FIRE; |
98 | } |
93 | } |
99 | else if (key == |
94 | else if (key == SDL_SCANCODE_F4) |
100 | syssnd_toggleMute(); |
95 | syssnd_toggleMute(); |
101 | else if (key == |
96 | else if (key == SDL_SCANCODE_F5) |
102 | syssnd_vol(-1); |
97 | syssnd_vol(-1); |
103 | else if (key == |
98 | else if (key == SDL_SCANCODE_F6) |
104 | syssnd_vol(+1); |
99 | syssnd_vol(+1); |
105 | else if (key == |
100 | else if (key == SDL_SCANCODE_F7) |
106 | { |
- | |
107 | want_filter ^= TRUE; |
101 | want_filter ^= TRUE; |
108 | redraw_screen = TRUE; |
- | |
109 | } |
- | |
110 | else if (key == |
102 | else if (key == SDL_SCANCODE_F10) |
111 | { |
103 | { |
112 | control_status &= ~CONTROL_EXIT; |
104 | control_status &= ~CONTROL_EXIT; |
113 | control_last = CONTROL_EXIT; |
105 | control_last = CONTROL_EXIT; |
114 | } |
106 | } |
115 | break; |
107 | break; |
116 | case SDL_KEYUP: |
108 | case SDL_KEYUP: |
117 | if (key == |
109 | if (key == SDL_SCANCODE_LALT) |
118 | alt_pressed = FALSE; |
110 | alt_pressed = FALSE; |
119 | else if (key == |
111 | else if (key == SDL_SCANCODE_O || key == SDL_SCANCODE_UP) |
120 | { |
112 | { |
121 | control_status &= ~CONTROL_UP; |
113 | control_status &= ~CONTROL_UP; |
122 | control_last = CONTROL_UP; |
114 | control_last = CONTROL_UP; |
123 | } |
115 | } |
124 | else if (key == |
116 | else if (key == SDL_SCANCODE_K || key == SDL_SCANCODE_DOWN) |
125 | { |
117 | { |
126 | control_status &= ~CONTROL_DOWN; |
118 | control_status &= ~CONTROL_DOWN; |
127 | control_last = CONTROL_DOWN; |
119 | control_last = CONTROL_DOWN; |
128 | } |
120 | } |
129 | else if (key == |
121 | else if (key == SDL_SCANCODE_Z || key == SDL_SCANCODE_LEFT) |
130 | { |
122 | { |
131 | control_status &= ~CONTROL_LEFT; |
123 | control_status &= ~CONTROL_LEFT; |
132 | control_last = CONTROL_LEFT; |
124 | control_last = CONTROL_LEFT; |
133 | } |
125 | } |
134 | else if (key == |
126 | else if (key == SDL_SCANCODE_X || key == SDL_SCANCODE_RIGHT) |
135 | { |
127 | { |
136 | control_status &= ~CONTROL_RIGHT; |
128 | control_status &= ~CONTROL_RIGHT; |
137 | control_last = CONTROL_RIGHT; |
129 | control_last = CONTROL_RIGHT; |
138 | } |
130 | } |
139 | else if (key == |
131 | else if (key == SDL_SCANCODE_PAUSE) |
140 | { |
132 | { |
141 | control_status &= ~CONTROL_PAUSE; |
133 | control_status &= ~CONTROL_PAUSE; |
142 | control_last = CONTROL_PAUSE; |
134 | control_last = CONTROL_PAUSE; |
143 | } |
135 | } |
144 | else if (key == |
136 | else if (key == SDL_SCANCODE_END) |
145 | { |
137 | { |
146 | control_status &= ~CONTROL_END; |
138 | control_status &= ~CONTROL_END; |
147 | control_last = CONTROL_END; |
139 | control_last = CONTROL_END; |
148 | } |
140 | } |
149 | else if (key == |
141 | else if (key == SDL_SCANCODE_ESCAPE) |
150 | { |
142 | { |
151 | control_status &= ~CONTROL_EXIT; |
143 | control_status &= ~CONTROL_EXIT; |
152 | control_last = CONTROL_EXIT; |
144 | control_last = CONTROL_EXIT; |
153 | } |
145 | } |
154 | else if (key == |
146 | else if (key == SDL_SCANCODE_SPACE) |
155 | { |
147 | { |
156 | control_status &= ~CONTROL_FIRE; |
148 | control_status &= ~CONTROL_FIRE; |
157 | control_last = CONTROL_FIRE; |
149 | control_last = CONTROL_FIRE; |
158 | } |
150 | } |
159 | break; |
151 | break; |