BJOY.H 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. // This is a public header file. It is to be included by applications that use
  19. // the WinBlue Library.
  20. ///////////////////////////////////////////////////////////////////////////////
  21. #ifndef B_JOY_H
  22. #define B_JOY_H
  23. ///////////////////////////////////////////////////////////////////////////////
  24. // Typedefs.
  25. ///////////////////////////////////////////////////////////////////////////////
  26. // Joystick easy access.
  27. typedef union
  28. {
  29. struct
  30. {
  31. unsigned button1 : 1;
  32. unsigned button2 : 1;
  33. unsigned button3 : 1;
  34. unsigned button4 : 1;
  35. unsigned up : 1;
  36. unsigned down : 1;
  37. unsigned left : 1;
  38. unsigned right : 1;
  39. unsigned toward : 1;
  40. unsigned away : 1;
  41. unsigned unused1 : 1; // Do not use or even reference the unused fields
  42. unsigned unused2 : 1; // as they may someday be used and changed in name.
  43. unsigned unused3 : 1; // To keep your code compiling when we change these
  44. unsigned unused4 : 1; // unused fields to useful things do not use or
  45. unsigned unused5 : 1; // even reference these. Thanks.
  46. unsigned unused6 : 1;
  47. } ;
  48. USHORT us;
  49. } JOYSTATE, *PJOYSTATE;
  50. ///////////////////////////////////////////////////////////////////////////////
  51. // Macros.
  52. ///////////////////////////////////////////////////////////////////////////////
  53. // Joy button types.
  54. // Use 0 to specify first joystick and 1 to specify second.
  55. // Joy button states.
  56. #define JOY_BUT_1 0x0001
  57. #define JOY_BUT_2 0x0002
  58. #define JOY_BUT_3 0x0004
  59. #define JOY_BUT_4 0x0008
  60. // Joy buttons' mask.
  61. #define JOY_BUT 0x000F
  62. // Joy dir states.
  63. #define JOY_DIR_UP 0x0010
  64. #define JOY_DIR_DOWN 0x0020
  65. #define JOY_DIR_LEFT 0x0040
  66. #define JOY_DIR_RIGHT 0x0080
  67. #define JOY_DIR_TOWARD 0x0100 // Toward player.
  68. #define JOY_DIR_AWAY 0x0200 // Away from player.
  69. // Joy dir states.
  70. #define JOY_DIR_STATES 0x03F0
  71. ///////////////////////////////////////////////////////////////////////////////
  72. // Prototypes.
  73. ///////////////////////////////////////////////////////////////////////////////
  74. // Updates joystick sJoy's current state and makes the current state the
  75. // previous.
  76. // Returns 0 on success.
  77. extern short Blu_UpdateJoy(short sJoy);
  78. // Puts the coordinates of joystick sJoy's position in your longs.
  79. // Returns nothing.
  80. extern void Blu_GetJoyPos(short sJoy, long *px, long *py, long *pz);
  81. // Puts the coordinates of the previous joystick sJoy's position in your longs.
  82. // Returns nothing.
  83. extern void Blu_GetJoyPrevPos(short sJoy, long *px, long *py, long *pz);
  84. // Returns the current joystick sJoy's state.
  85. extern USHORT Blu_GetJoyState(short sJoy);
  86. // Places the current joystick sJoy's state.
  87. extern void Blu_GetJoyState(short sJoy, PJOYSTATE pjs);
  88. // Returns the previous joystick sJoy's state.
  89. extern USHORT Blu_GetJoyPrevState(short sJoy);
  90. // Places the previous joystick sJoy's state.
  91. extern void Blu_GetJoyPrevState(short sJoy, PJOYSTATE pjs);
  92. #endif // B_JOY_H
  93. //////////////////////////////////////////////////////////////////////////////
  94. // EOF
  95. //////////////////////////////////////////////////////////////////////////////