Joystick.h
上传用户:luhy168
上传日期:2022-01-10
资源大小:240k
文件大小:1k
源码类别:

模拟服务器

开发平台:

Visual C++

  1. // Joystick.hpp
  2. // If you are confused about how this works please read Yoshi's NESTECH.TXT
  3. // It will explain this very well.  I will try to add as many comments as
  4. // possible but they wont make sense if you don't understand how the NES
  5. // joysticks work.
  6. #ifndef __JOYSTICK_H__
  7. #define __JOYSTICK_H__
  8. #define JOYA 0
  9. #define JOYB 1
  10. #define JOYSELECT    2
  11. #define JOYSTART 3
  12. #define JOYUP 4
  13. #define JOYDOWN 5
  14. #define JOYLEFT 6
  15. #define JOYRIGHT 7
  16. class Joystick
  17. {
  18. public:
  19. Joystick( unsigned int );
  20.    void write( unsigned char );
  21.    unsigned char read();
  22.    void Strobe();
  23. char GetButton( int );
  24.    void SetButton( int );
  25.    void ClearButton( int );
  26. private:
  27. // Using an array for the bit stream takes more memory but it is faster
  28.    // and much easier to implement.  Btw this is the actual joystick data
  29.    char BitStream[ 24 ];
  30.    // The current item to be read from the joystick
  31.    int BitIndex;
  32.    // The toggle switch that dictates whether to Srobe or not on the Next
  33.    // write to the port
  34.    bool StrobeOnNext;
  35.    // The port associated with eack joystick
  36.    unsigned int Port;
  37. };
  38. #endif