CONTROL.C 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // Choose which type of controller to use
  3. //
  4. #include "main.h"
  5. enum {CON_MOUSE,CON_JOY,CON_KEY,CON_MAX};
  6. item_t controlitems[]=
  7. {
  8. {CON_MOUSE, 26,11,28, -1,-1},
  9. {CON_JOY, 26,12,28, -1,-1},
  10. {CON_KEY, 26,13,28, -1,-1}
  11. };
  12. menu_t controlmenu=
  13. {
  14. &controlitems[0],
  15. CON_MOUSE,
  16. CON_MAX,
  17. 0x7f
  18. };
  19. int ChooseController (void)
  20. {
  21. short key;
  22. short field;
  23. int rval = 0;
  24. SaveScreen();
  25. DrawPup(&control);
  26. // DEFAULT FIELD ========================================
  27. if (newc.control == C_MOUSE)
  28. field = CON_MOUSE;
  29. else
  30. if (newc.control == C_JOYSTICK)
  31. field = CON_JOY;
  32. else
  33. field = CON_KEY;
  34. controlmenu.startitem = field;
  35. while(1)
  36. {
  37. SetupMenu(&controlmenu);
  38. field = GetMenuInput();
  39. key = menukey;
  40. switch ( key )
  41. {
  42. case KEY_ESC:
  43. rval = -1;
  44. goto func_exit;
  45. case KEY_ENTER:
  46. case KEY_F10:
  47. switch ( field )
  48. {
  49. case CON_KEY:
  50. newc.control = C_KEY;
  51. usemouse = 0;
  52. usejoystick = 0;
  53. goto func_exit;
  54. case CON_MOUSE:
  55. newc.control = C_MOUSE;
  56. usemouse = 1;
  57. usejoystick = 0;
  58. goto func_exit;
  59. case CON_JOY:
  60. newc.control = C_JOYSTICK;
  61. usemouse = 0;
  62. usejoystick = 1;
  63. goto func_exit;
  64. default:
  65. break;
  66. }
  67. break;
  68. }
  69. }
  70. func_exit:
  71. RestoreScreen();
  72. DrawCurrentConfig();
  73. return ( rval );
  74. }