home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / oslib / oslib_1 / OSLib / Computer / h / joystick < prev    next >
Encoding:
Text File  |  1995-06-22  |  3.9 KB  |  134 lines

  1. #ifndef joystick_H
  2. #define joystick_H
  3.  
  4. /* C header file for Joystick
  5.  * written by DefMod (Jun 20 1995) on Thu Jun 22 12:12:37 1995
  6.  * Jonathan Coxhead, Acorn Computers Ltd
  7.  */
  8.  
  9. #ifndef types_H
  10. #include "types.h"
  11. #endif
  12.  
  13. #ifndef os_H
  14. #include "os.h"
  15. #endif
  16.  
  17. /**********************************
  18.  * SWI names and SWI reason codes *
  19.  **********************************/
  20. #undef  Joystick_Read
  21. #define Joystick_Read                           0x43F40
  22. #undef  XJoystick_Read
  23. #define XJoystick_Read                          0x63F40
  24. #undef  Joystick_ReadHalfWord
  25. #define Joystick_ReadHalfWord                   0x43F40
  26. #undef  XJoystick_ReadHalfWord
  27. #define XJoystick_ReadHalfWord                  0x63F40
  28. #undef  Joystick_CalibrateTopRight
  29. #define Joystick_CalibrateTopRight              0x43F41
  30. #undef  XJoystick_CalibrateTopRight
  31. #define XJoystick_CalibrateTopRight             0x63F41
  32. #undef  Joystick_CalibrateBottomLeft
  33. #define Joystick_CalibrateBottomLeft            0x43F42
  34. #undef  XJoystick_CalibrateBottomLeft
  35. #define XJoystick_CalibrateBottomLeft           0x63F42
  36.  
  37. /********************
  38.  * Type definitions *
  39.  ********************/
  40. typedef bits joystick_state;
  41.  
  42. typedef bits joystick_half_word_state;
  43.  
  44. /************************
  45.  * Constant definitions *
  46.  ************************/
  47. #define joystick_X                              ((joystick_state) 0xFFu)
  48. #define joystick_Y                              ((joystick_state) 0xFF00u)
  49. #define joystick_SWITCHES                       ((joystick_state) 0xFF0000u)
  50. #define joystick_XSHIFT                         0
  51. #define joystick_YSHIFT                         8
  52. #define joystick_SWITCHES_SHIFT                 16
  53. #define joystick_HALF_WORDX                     ((joystick_state) 0xFFFFu)
  54. #define joystick_HALF_WORDY                     ((joystick_state) 0xFFFF0000u)
  55. #define joystick_HALF_WORD_XSHIFT               0
  56. #define joystick_HALF_WORD_YSHIFT               16
  57.  
  58. /*************************
  59.  * Function declarations *
  60.  *************************/
  61.  
  62. #ifdef __cplusplus
  63.    extern "C" {
  64. #endif
  65.  
  66. /* ------------------------------------------------------------------------
  67.  * Function:      joystick_read()
  68.  *
  69.  * Description:   Returns the state of a joystick
  70.  *
  71.  * Input:         joystick_no - value of R0 on entry
  72.  *
  73.  * Output:        state - value of R0 on exit (X version only)
  74.  *
  75.  * Returns:       R0 (non-X version only)
  76.  *
  77.  * Other notes:   Calls SWI 0x43F40.
  78.  */
  79.  
  80. extern os_error *xjoystick_read (int joystick_no,
  81.       joystick_state *state);
  82. __swi (0x43F40) joystick_state joystick_read (int joystick_no);
  83.  
  84. /* ------------------------------------------------------------------------
  85.  * Function:      joystick_read_half_word()
  86.  *
  87.  * Description:   Returns the state of a joystick
  88.  *
  89.  * Input:         joystick_no - value of R0 on entry
  90.  *
  91.  * Output:        state - value of R0 on exit (X version only)
  92.  *                switches - value of R1 on exit
  93.  *
  94.  * Returns:       R0 (non-X version only)
  95.  *
  96.  * Other notes:   Calls SWI 0x43F40 with R0 |= 0x100.
  97.  */
  98.  
  99. extern os_error *xjoystick_read_half_word (int joystick_no,
  100.       joystick_half_word_state *state,
  101.       bits *switches);
  102. extern joystick_half_word_state joystick_read_half_word (int joystick_no,
  103.       bits *switches);
  104.  
  105. /* ------------------------------------------------------------------------
  106.  * Function:      joystick_calibrate_top_right()
  107.  *
  108.  * Description:   One of the pair of SWI's to calibrate an analogue
  109.  *                joystick
  110.  *
  111.  * Other notes:   Calls SWI 0x43F41.
  112.  */
  113.  
  114. extern os_error *xjoystick_calibrate_top_right (void);
  115. __swi (0x43F41) void joystick_calibrate_top_right (void);
  116.  
  117. /* ------------------------------------------------------------------------
  118.  * Function:      joystick_calibrate_bottom_left()
  119.  *
  120.  * Description:   One of the pair of SWI's to calibrate an analogue
  121.  *                joystick
  122.  *
  123.  * Other notes:   Calls SWI 0x43F42.
  124.  */
  125.  
  126. extern os_error *xjoystick_calibrate_bottom_left (void);
  127. __swi (0x43F42) void joystick_calibrate_bottom_left (void);
  128.  
  129. #ifdef __cplusplus
  130.    }
  131. #endif
  132.  
  133. #endif
  134.