File: vgastubs.c

package info (click to toggle)
gravitywars 1.102-34
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 2,468 kB
  • ctags: 553
  • sloc: ansic: 3,938; makefile: 52; sh: 52
file content (671 lines) | stat: -rw-r--r-- 15,388 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671

/* GravityWars 1.1, SDL wrapper (C) 2003 Sam Hocevar <sam@zoy.org> */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "memory.h"

#ifdef USE_SDL
#include "vgastubs.h"

/*
#include <SDL.h>
*/

/* VGA */

#define WIDTH 640
#define HEIGHT 480

SDL_Surface *screen;
SDL_Surface *bg;
SDL_Rect score_rect, level_rect, game_rect;

#ifdef USE_JOYSTICK
SDL_Joystick * joy = NULL;

int JOY_INDEX = 0;
int JOY_XAXIS = 0;
int JOY_YAXIS = 1;
int JOY_BUTTON_UP = 0;
int JOY_BUTTON_SHOOT = 1;
int JOY_BUTTON_TOGGLE_FULLSCREEN = 2;
int JOY_BUTTON_ESCAPE = 2;

Sint16 JOY_XAXIS_CENTER = 0;
Sint16 JOY_XAXIS_MINIMUM = -32767;
Sint16 JOY_XAXIS_MAXIMUM = 32767;
Sint16 JOY_XAXIS_NULLZONE = 1024;

Sint16 JOY_YAXIS_CENTER = 0;
Sint16 JOY_YAXIS_MINIMUM = -32767;
Sint16 JOY_YAXIS_MAXIMUM = 32767;
Sint16 JOY_YAXIS_NULLZONE = 1024;

int save_joystick_settings (void) {
	/*Just a dirty hack to save the joystick settings*/
	FILE * joyset = NULL;
	char * home = NULL;
	char   fpath[1000];

	if ((home = getenv ("HOME")) == NULL)
		return (2);
	strcpy (fpath, home);
	joyset = fopen (strcat (fpath, "/.gravitywars-joystick-settings"), "w");

	if (joyset != NULL) {
		if (fprintf (
			joyset,
			"%d %d %d %d %d %d %d %hd %hd %hd %hd %hd %hd %hd %hd\n",
			JOY_INDEX,
			JOY_XAXIS,
			JOY_YAXIS,
			JOY_BUTTON_UP,
			JOY_BUTTON_SHOOT,
			JOY_BUTTON_TOGGLE_FULLSCREEN,
			JOY_BUTTON_ESCAPE,
			JOY_XAXIS_CENTER,
			JOY_XAXIS_MINIMUM,
			JOY_XAXIS_MAXIMUM,
			JOY_XAXIS_NULLZONE,
			JOY_YAXIS_CENTER,
			JOY_YAXIS_MINIMUM,
			JOY_YAXIS_MAXIMUM,
			JOY_YAXIS_NULLZONE
			) >= 0) {
			fclose (joyset);
			return (0);
		} else {
			fclose (joyset);
			return (1);
		}
	} else {
		return (2);
	}
}

int load_joystick_settings (void) {
	FILE * joyset = NULL;
	char * lineptr = NULL;
	size_t n = 0;
	char * home = NULL;
	char   fpath[1000];

	if ((home = getenv ("HOME")) == NULL)
		return (2);
	strcpy (fpath, home);
	joyset = fopen (strcat (fpath, "/.gravitywars-joystick-settings"), "r");

	if (joyset != NULL) {
		if (getline (&lineptr, &n, joyset) == -1)
			return 1;
		if (
			sscanf (
			lineptr,
			"%d %d %d %d %d %d %d %hd %hd %hd %hd %hd %hd %hd %hd",
			&JOY_INDEX,
			&JOY_XAXIS,
			&JOY_YAXIS,
			&JOY_BUTTON_UP,
			&JOY_BUTTON_SHOOT,
			&JOY_BUTTON_TOGGLE_FULLSCREEN,
			&JOY_BUTTON_ESCAPE,
			&JOY_XAXIS_CENTER,
			&JOY_XAXIS_MINIMUM,
			&JOY_XAXIS_MAXIMUM,
			&JOY_XAXIS_NULLZONE,
			&JOY_YAXIS_CENTER,
			&JOY_YAXIS_MINIMUM,
			&JOY_YAXIS_MAXIMUM,
			&JOY_YAXIS_NULLZONE
		) == 15) {
			fclose (joyset);
			return 0;
		} else {
			fclose (joyset);
			return 2;
		}
	} else {
	return 3;
	}
}

void set_joystick (void)
{
	SDL_Joystick ** joyar = NULL;
	SDL_Event e;
	int i, axis_set, axis_ref, axis_ref_set, axis_max, axis_min, num_of_joystick;

	SDL_JoystickEventState (SDL_ENABLE);
	num_of_joystick = SDL_NumJoysticks();

	if (num_of_joystick > 0) {
		printf ("Found %d joystick.\n", num_of_joystick);

		joyar = (SDL_Joystick **) malloc (sizeof (SDL_Joystick *) * num_of_joystick);
		if (joyar != NULL) {
			for (i = 0; i < num_of_joystick; i++) {
				if (!SDL_JoystickOpened(i))
					joyar[i] = SDL_JoystickOpen(i);
			}

		} else {
			SDL_Quit ();
			exit (1);
		}

/*Select the joystick*/
		printf ("Press any button or move the axis on the joystick you want to configure...\n");

/* Emptying the event queue. My joystick throws
 * some false event right after it is opened.*/
		while (SDL_PollEvent(&e));

		while (1) {
			if (SDL_WaitEvent (&e)){
				if (e.type == SDL_JOYAXISMOTION) {
					JOY_INDEX = e.jaxis.which;
					break;
				} else if (e.type == SDL_JOYBUTTONDOWN) {
					JOY_INDEX = e.jbutton.which;
					break;
				}
			}
		}
		printf ("Joystick with index %d selected.\n", JOY_INDEX);

/* Closing other opened (if any) joystick. */
		for (i = 0; i < num_of_joystick; i++) {
			if (i != JOY_INDEX) {
				if (SDL_JoystickOpened(i))
					SDL_JoystickClose (joyar[i]);
			}
		}

		printf ("Move x-axis to full left and right. Then press a button...\n");

		axis_set = 0;
		axis_ref_set = 0;

		while (SDL_PollEvent(&e));
		while (1) {
			if (SDL_WaitEvent (&e) == 1) {
				if (e.type == SDL_JOYAXISMOTION) {
					if (axis_set == 0) {
						JOY_XAXIS = e.jaxis.axis;
						axis_set = 1;
					}
					if (axis_set == 1) {
						if (e.jaxis.axis == JOY_XAXIS) {
							if (axis_ref_set == 0) {
								axis_ref = e.jaxis.value;
								axis_max = axis_ref;
								axis_min = axis_ref;
								axis_ref_set = 1;
							} else {
								if (e.jaxis.value > axis_max)
									axis_max = e.jaxis.value;
								else if (e.jaxis.value < axis_min)
									axis_min = e.jaxis.value;
							}
						}
					}
				} else if (e.type == SDL_JOYBUTTONDOWN) {
					if (axis_set == 1) {
						if (axis_ref_set == 1) {
							if (axis_min != axis_max) {
								JOY_XAXIS_MAXIMUM = axis_max;
								JOY_XAXIS_MINIMUM = axis_min;
								JOY_XAXIS_CENTER = axis_min + (axis_max - axis_min)/2;
								JOY_XAXIS_NULLZONE = (axis_max - axis_min)/(20); /*10% of difference max and center*/
								break;
							}
						}
					}
				}
			}
		}

		printf ("Selected axis %d as x-axis.\n", JOY_XAXIS);
		printf ("Move y-axis to full up and down. Then press a button...\n");

		axis_set = 0;
		axis_ref_set = 0;

		while (SDL_PollEvent(&e));
		while (1) {
			if (SDL_WaitEvent (&e) == 1) {
				if (e.type == SDL_JOYAXISMOTION) {
					if (e.jaxis.axis != JOY_XAXIS) {
						if (axis_set == 0) {
							JOY_YAXIS = e.jaxis.axis;
							axis_set = 1;
						}
						if (axis_set == 1) {
							if (e.jaxis.axis ==  JOY_YAXIS) {
								if (axis_ref_set == 0) {
									axis_ref = e.jaxis.value;
									axis_max = axis_ref;
									axis_min = axis_ref;
									axis_ref_set = 1;
								} else {
									if (e.jaxis.value > axis_max)
										axis_max = e.jaxis.value;
									else if (e.jaxis.value < axis_min)
										axis_min = e.jaxis.value;
								}
							}
						}
					}
				} else if (e.type == SDL_JOYBUTTONDOWN) {
					if (axis_set == 1) {
						if (axis_ref_set == 1) {
							if (axis_min != axis_max) {
								JOY_YAXIS_MAXIMUM = axis_max;
								JOY_YAXIS_MINIMUM = axis_min;
								JOY_YAXIS_CENTER = axis_min + (axis_max - axis_min)/2;
								JOY_YAXIS_NULLZONE = (axis_max - axis_min)/(20); /*10% of difference max and center*/
								break;
							}
						}
					}
				}
			}
		}

		printf ("Selected axis %d as y-yxis.\n", JOY_YAXIS);

		printf ("Press the button for action:\"up\"...\n");
		while (SDL_PollEvent(&e));
		while (1) {
			SDL_WaitEvent (&e);
			if (e.type == SDL_JOYBUTTONDOWN) {
				JOY_BUTTON_UP = e.jbutton.button;
				break;
			}
		}
		printf ("\"up\":%d\n", JOY_BUTTON_UP);

		printf ("Press the button for action:\"shoot\"...\n");
		while (SDL_PollEvent(&e));
		while (1) {
			SDL_WaitEvent (&e);
			if (e.type == SDL_JOYBUTTONDOWN) {
				JOY_BUTTON_SHOOT = e.jbutton.button;
				break;
			}
		}
		printf ("\"shoot\":%d\n", JOY_BUTTON_SHOOT);
		printf ("Press the button for action:\"toggle fullscreen\"...\n");
		while (SDL_PollEvent(&e));
		while (1) {
			SDL_WaitEvent (&e);
			if (e.type == SDL_JOYBUTTONDOWN) {
				JOY_BUTTON_TOGGLE_FULLSCREEN = e.jbutton.button;
				break;
			}
		}
		printf ("\"toggle fullscreen\":%d\n", JOY_BUTTON_TOGGLE_FULLSCREEN);
		printf ("Press the button for action:\"escape\"...\n");
		while (SDL_PollEvent(&e));
		while (1) {
			SDL_WaitEvent (&e);
			if (e.type == SDL_JOYBUTTONDOWN) {
				JOY_BUTTON_ESCAPE = e.jbutton.button;
				break;
			}
		}
		printf ("\"escape\":%d\n", JOY_BUTTON_ESCAPE);
		SDL_JoystickClose (joyar[JOY_INDEX]);
		free (joyar);
		if (save_joystick_settings ())
			printf ("Error saving joystick settings.\n");
		else
			printf ("Joystick configuration saved.\n");
	}	else {
		printf ("No joystick found.\n");
	}
}
#endif

int vga_init(void) {
#ifdef USE_JOYSTICK
  if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE|SDL_INIT_JOYSTICK) < 0)
#else
  if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0)
#endif
    return -1;

  atexit(SDL_Quit);

  return 0;
}

int vga_setmode(int mode) {

  switch(mode) {
    case G640x480x256:
      screen = SDL_SetVideoMode(WIDTH, HEIGHT, 8,
                                SDL_HWPALETTE/*|SDL_FULLSCREEN*/);
      if(!screen) {
        fprintf(stderr, "error setting %dx%d 8bpp indexed mode: %s\n",
                WIDTH, HEIGHT, SDL_GetError());
        return -1;
      }
      break;
    case TEXT:
      break;
  }

  /* The level area in the background bitmap */
  level_rect.w = WIDTH;
  level_rect.h = HEIGHT;
  level_rect.x = 0;
  level_rect.y = 16; /* gets modified, between 16 and 960 */

  /* Where our viewport gets blitted */
  game_rect.w = WIDTH;
  game_rect.h = HEIGHT;
  game_rect.x = 0;
  game_rect.y = 0;

  /* The score area in the background bitmap */
  score_rect.w = WIDTH;
  score_rect.h = 0;
  score_rect.x = 0;
  score_rect.y = 16;

  /* Where the score gets blitted - heh, we use NULL! */

  return 0;
}

/* This one is SDL-only */
void vga_setsplitline(int sl) {
  score_rect.h = 480 - sl;
  score_rect.y = 16 - (480 - sl);
}

#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif

int vga_claimvideomemory(int m) {
  bg = SDL_CreateRGBSurface(SDL_SWSURFACE, WIDTH, m / WIDTH, 8, 0, 0, 0, 0);

  if(!bg)
    return -1;

  /* set the palette to the logical screen palette so that blits
     won't be translated */
  SDL_SetColors(bg, screen->format->palette->colors, 0, 256);

  vga_setpage(0);

  return 0;
}

unsigned char *vga_getgraphmem(void) {
  return bg->pixels;
}

/* FIXME: implement this as a macro */
void vga_setpage(int page) {
  vga_ptr = bg->pixels + (page << 16);
}

void vga_waitretrace(void) {
  SDL_BlitSurface(bg, &level_rect, screen, &game_rect);
  SDL_BlitSurface(bg, &score_rect, screen, NULL);
  SDL_UpdateRect(screen, 0, 0, 0, 0);
}

/* gl */

void gl_setpalette(void *sp) {
  SDL_Color cmap[256];
  char *cols = (char *)sp;
  int i;

  for(i=0; i<256; i++) {
    cmap[i].r = *cols++ * 4;
    cmap[i].g = *cols++ * 4;
    cmap[i].b = *cols++ * 4;
  }

  SDL_SetPalette(screen, SDL_PHYSPAL, cmap, 0, 256);
}

int gl_setcontextvga(int mode) {
  return 0;
}

void  gl_setcontextvirtual(int  w,  int  h,  int  bpp, int bitspp, void *vbuf) {
  return;
}

void *gl_setdisplaystart(int x, int y) {
  level_rect.x = x;
  level_rect.y = y; /* y >= 16 */

  return NULL;
}

void gl_setpalettecolor(int c, int r, int g, int b) {
  SDL_Color cmap[1];
  cmap[0].r = r * 4;
  cmap[0].g = g * 4;
  cmap[0].b = b * 4;

  SDL_SetColors(screen, cmap, 0, 1);
}

/* Mouse */

int mouse_init(char *dev, int type, int samplerate) {
  return 0;
}

int mouse_update(void) {
  return 0;
}

int mouse_getbutton(void) {
  return 0;
}

void mouse_close(void) {
  return;
}

/* Keyboard */

unsigned char keybuf[256];

int keyboard_init(void) {
  scans = keybuf;
  memset(scans, 0, 256);
  return 0;
}

void keyboard_close(void) {
  return;
}

char *keyboard_getstate(void) {
  return scans;
}

int keyboard_update(void) {
  SDL_Event e;
  int updated = 0;
  int mod;

  mod = SDL_GetModState();
  scans[SCANCODE_LEFTCONTROL] = mod & KMOD_LCTRL;
  scans[SCANCODE_RIGHTCONTROL] = mod & KMOD_RCTRL;
#ifdef USE_JOYSTICK
	scans[SCANCODE_LEFTCONTROL] = SDL_JoystickGetButton (joy, JOY_BUTTON_SHOOT);
#endif

  while(SDL_PollEvent(&e)) {
    if(e.type == SDL_KEYDOWN) {
      switch(e.key.keysym.sym) {
        case SDLK_ESCAPE:
          scans[SCANCODE_ESCAPE] = 1;
          updated = 1;
          break;
        case SDLK_LEFT:
          scans[SCANCODE_CURSORBLOCKLEFT] = 1;
          updated = 1;
          break;
        case SDLK_RIGHT:
          scans[SCANCODE_CURSORBLOCKRIGHT] = 1;
          updated = 1;
          break;
        case SDLK_UP:
          scans[SCANCODE_CURSORBLOCKUP] = 1;
          updated = 1;
          break;
        case SDLK_f:
          SDL_WM_ToggleFullScreen(screen);
          break;
        default:
          updated = 1;
          break;
      }
    } else if(e.type == SDL_KEYUP) {
      switch(e.key.keysym.sym) {
        case SDLK_ESCAPE:
          scans[SCANCODE_ESCAPE] = 0;
          break;
        case SDLK_LEFT:
          scans[SCANCODE_CURSORBLOCKLEFT] = 0;
          break;
        case SDLK_RIGHT:
          scans[SCANCODE_CURSORBLOCKRIGHT] = 0;
          break;
        case SDLK_UP:
          scans[SCANCODE_CURSORBLOCKUP] = 0;
          break;
        default:
          break;
      }
    }
#ifdef USE_JOYSTICK
/*Joystick*/
			else if (joy != NULL) {
				if (e.type == SDL_JOYAXISMOTION) {
#ifdef DEBUG
				puts ("Joystick axis motion detected.");
#endif
					if (e.jaxis.which == JOY_INDEX) {
						if (e.jaxis.axis == JOY_XAXIS) {
#ifdef DEBUG
							printf ("Axis : X, Value : %i\n", e.jaxis.value);
#endif
							if ((JOY_XAXIS_MINIMUM <= e.jaxis.value) &&
								(e.jaxis.value < JOY_XAXIS_CENTER - JOY_XAXIS_NULLZONE)) {
								scans[SCANCODE_CURSORBLOCKLEFT] = 1;
								scans[SCANCODE_CURSORBLOCKRIGHT] = 0;
								updated = 1;
							} else if ((JOY_XAXIS_CENTER + JOY_XAXIS_NULLZONE < e.jaxis.value) &&
								(e.jaxis.value <= JOY_XAXIS_MAXIMUM)) {
								scans[SCANCODE_CURSORBLOCKRIGHT] = 1;
								scans[SCANCODE_CURSORBLOCKLEFT] = 0;
								updated = 1;
							} else {
								scans[SCANCODE_CURSORBLOCKRIGHT] = 0;
								scans[SCANCODE_CURSORBLOCKLEFT] = 0;
							}
						} else if (e.jaxis.axis == JOY_YAXIS) {
#ifdef DEBUG
						printf ("Axis : Y, Value : %d\n", e.jaxis.value);
#endif
						if ((JOY_YAXIS_MINIMUM <= e.jaxis.value) &&
							(e.jaxis.value < JOY_YAXIS_CENTER - JOY_YAXIS_NULLZONE)) {
							scans[SCANCODE_CURSORBLOCKUP] = 1;
							updated = 1;
						} else if ((JOY_YAXIS_CENTER + JOY_YAXIS_NULLZONE < e.jaxis.value) &&
							(e.jaxis.value <= JOY_YAXIS_MAXIMUM)) {
							scans[SCANCODE_CURSORBLOCKUP] = 1;
							updated = 1;
						} else {
							scans[SCANCODE_CURSORBLOCKUP] = 0;
						}
					}
 				}
			} else if (e.type == SDL_JOYBUTTONDOWN) {
				if (e.jbutton.which == JOY_INDEX) {
					if (e.jbutton.button == JOY_BUTTON_UP) {
						scans[SCANCODE_CURSORBLOCKUP] = 1;
						updated = 1;
/*
					} else if (e.jbutton.button == JOY_BUTTON_SHOOT) {
						scans[SCANCODE_LEFTCONTROL] = 1;
						scans[SCANCODE_RIGHTCONTROL] = 1;
						updated = 1;
*/
					} else if (e.jbutton.button == JOY_BUTTON_ESCAPE) {
						scans[SCANCODE_ESCAPE] = 1;
						updated = 1;
					} else if (e.jbutton.button == JOY_BUTTON_TOGGLE_FULLSCREEN) {
   	    		SDL_WM_ToggleFullScreen(screen);
					}
				}
			} else if (e.type == SDL_JOYBUTTONUP) {
				if (e.jbutton.which == JOY_INDEX) {
					if (e.jbutton.button == JOY_BUTTON_UP) {
						scans[SCANCODE_CURSORBLOCKUP] = 0;
/*
					} else if (e.jbutton.button == JOY_BUTTON_SHOOT) {
						scans[SCANCODE_LEFTCONTROL] = 0;
						scans[SCANCODE_RIGHTCONTROL] = 0;
*/
					} else if (e.jbutton.button == JOY_BUTTON_ESCAPE) {
						scans[SCANCODE_ESCAPE] = 0;
					}
				}
			}
		}
#endif
  }
  return updated;
}

#ifdef USE_JOYSTICK
int joystick_init (void) {
	SDL_JoystickEventState (SDL_ENABLE);
	if (SDL_NumJoysticks () >= JOY_INDEX) {
		joy = SDL_JoystickOpen (JOY_INDEX);

		if (joy == NULL) {
#ifdef DEBUG
			printf ("Failed to open joystick.\n");
#endif
			return (1);
		}
		else
			return (0);
	}
	else {
#ifdef DEBUG
		printf ("Joystick not found.\n");
#endif
		return (2);
	}
}

void joystick_close (void) {
	if (SDL_JoystickOpened (JOY_INDEX)) {
		SDL_JoystickClose (joy);
	}
}
#endif

#endif /* USE_SDL */