// $Id: Keyboard.hh 5779 2006-10-14 16:17:32Z m9710797 $ #ifndef KEYBOARD_HH #define KEYBOARD_HH #include "MSXEventListener.hh" #include "Schedulable.hh" #include "openmsx.hh" #include #include #include namespace openmsx { class Scheduler; class MSXCommandController; class MSXEventDistributor; class EmuTime; class KeyMatrixUpCmd; class KeyMatrixDownCmd; class KeyInserter; class Keyboard : private MSXEventListener, private Schedulable { public: /** * Constructs a new Keyboard object. * @param scheduler ref to the scheduler * @param msxCommandController ref to the command controller * @param eventDistributor ref to the user input event distributor * @param keyGhosting turn keyGhosting on/off */ Keyboard(Scheduler& scheduler, MSXCommandController& msxCommandController, MSXEventDistributor& eventDistributor, bool keyGhosting); virtual ~Keyboard(); /** * Returns a pointer to the current KeyBoard matrix */ const byte* getKeys(); static const unsigned NR_KEYROWS = 16; private: // MSXEventListener virtual void signalEvent(shared_ptr event, const EmuTime& time); // Schedulable virtual void executeUntil(const EmuTime& time, int userData); virtual const std::string& schedName() const; void processKey(bool down, int key); void doKeyGhosting(); void parseKeymapfile(const byte* buf, unsigned size); void loadKeymapfile(const std::string& filename); std::string processCmd(const std::vector& tokens, bool up); void pressAscii(char asciiCode, bool down); bool commonKeys(char asciiCode1, char asciiCode2); MSXEventDistributor& eventDistributor; friend class KeyMatrixUpCmd; friend class KeyMatrixDownCmd; friend class KeyInserter; const std::auto_ptr keyMatrixUpCmd; const std::auto_ptr keyMatrixDownCmd; const std::auto_ptr keyTypeCmd; byte cmdKeyMatrix[NR_KEYROWS]; byte userKeyMatrix[NR_KEYROWS]; byte keyMatrix[NR_KEYROWS]; bool keyGhosting; bool keysChanged; static const int MAX_KEYSYM = 0x150; static byte keyTab[MAX_KEYSYM][2]; static short asciiTab[256][2]; }; } // namespace openmsx #endif