File tree Expand file tree Collapse file tree 1 file changed +35
-16
lines changed Expand file tree Collapse file tree 1 file changed +35
-16
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,8 @@ string_array_free(char** str_array, unsigned int length)
109
109
110
110
// INPUT UNTILS //
111
111
112
+ #ifdef __unix__
113
+
112
114
/*
113
115
*
114
116
*/
@@ -133,34 +135,51 @@ getch() {
133
135
return buf ;
134
136
}
135
137
138
+ #endif
139
+
136
140
/*
137
141
*
138
142
*/
139
143
int
140
144
get_key_pressed ()
141
145
{
142
- int getch_buf ;
143
- getch_buf = getch ();
146
+ int init_buffer , ch = -1 ;
147
+ init_buffer = getch ();
148
+
149
+ //printf("\nInit buffer: %d", init_buffer);
144
150
145
151
// in different machines backspace can be 8 or 127 coded
146
- if (getch_buf == BS_KEY || getch_buf == BS_KEY2 )
152
+ if (init_buffer == BS_KEY || init_buffer == BS_KEY2 )
147
153
return BACKSPACE ;
148
154
149
- if (getch_buf == ESCAPE_CODE ) {
155
+ #ifdef __unix__
156
+
157
+ if (init_buffer == ESCAPE_CODE ) {
150
158
getch ();
151
- switch (getch ())
152
- {
153
- case A_KEY :
154
- return ARROW_UP ;
155
- case B_KEY :
156
- return ARROW_DOWN ;
157
- case C_KEY :
158
- return ARROW_RIGHT ;
159
- case D_KEY :
160
- return ARROW_LEFT ;
161
- }
159
+ ch = getch ();
162
160
}
163
- return getch_buf ;
161
+
162
+ #elif _WIN32
163
+
164
+ if (init_buffer == WIN_META_CODE1 || init_buffer == WIN_META_CODE2 )
165
+ ch = getch ();
166
+
167
+ #endif
168
+
169
+ switch (ch )
170
+ {
171
+ case A_KEY :
172
+ return ARROW_UP ;
173
+ case B_KEY :
174
+ return ARROW_DOWN ;
175
+ case C_KEY :
176
+ return ARROW_RIGHT ;
177
+ case D_KEY :
178
+ return ARROW_LEFT ;
179
+ default : break ;
180
+ }
181
+
182
+ return init_buffer ;
164
183
}
165
184
166
185
You can’t perform that action at this time.
0 commit comments