Update of /cvsroot/openmsx/openMSX/src In directory usw-pr-cvs1:/tmp/cvs-serv15170/src Modified Files: KeyEventInserter.cc KeyEventInserter.hh Makefile.am Scheduler.cc Scheduler.hh openmsx.cc Added Files: SDLEventInserter.cc SDLEventInserter.hh Log Message: updated KeyEventInserter --- NEW FILE: SDLEventInserter.cc --- #include "SDLEventInserter.hh" SDLEventInserter::SDLEventInserter(SDL_Event &evnt, const Emutime &time) { event = evnt; Scheduler::instance()->setSyncPoint(time, *this); } SDLEventInserter::~SDLEventInserter() { } void SDLEventInserter::executeUntilEmuTime(const Emutime &time) { SDL_PushEvent(&event); delete this; // job is done } --- NEW FILE: SDLEventInserter.hh --- #ifndef __SDLEVENTINSERTER_HH__ #define __SDLEVENTINSERTER_HH__ #include "emutime.hh" #include "Scheduler.hh" #include <SDL/SDL.h> class SDLEventInserter : public Schedulable { public: SDLEventInserter(SDL_Event &event, const Emutime &time); void executeUntilEmuTime(const Emutime &time); protected: virtual ~SDLEventInserter(); private: SDL_Event event; }; #endif Index: KeyEventInserter.cc =================================================================== RCS file: /cvsroot/openmsx/openMSX/src/KeyEventInserter.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- KeyEventInserter.cc 2001/10/17 19:51:47 1.2 +++ KeyEventInserter.cc 2001/11/18 21:36:11 1.3 @@ -1,25 +1,5 @@ #include "KeyEventInserter.hh" - #include "MSXCPU.hh" -#include "MSXPPI.hh" - -//KeyEventInserter keyi; - -KeyEventInserterEvent::KeyEventInserterEvent(int key_, bool up_):key(key_),up(up_) -{ -} - -void -KeyEventInserterEvent::executeUntilEmuTime(const Emutime &time) -{ - // we won't do it this way: MSXPPI::instance()->injectKey(key, up); - SDL_Event event; - event.key.keysym.sym = static_cast<enum SDLKey>(key); - event.type = up?SDL_KEYUP:SDL_KEYDOWN; - SDL_PushEvent(&event); - - delete this; -} KeyEventInserter::KeyEventInserter() { @@ -39,9 +19,17 @@ void KeyEventInserter::flush(uint64 offset) { - // create KeyEventInserterSchedulable's - // for each key and schedule them - // - // prevTime = MSXCPU::instance()->getCurrentTime(); + SDL_Event event; + Emutime time(10); // 10 Hz + time = MSXCPU::instance()->getCurrentTime(); + for (unsigned i=0; i<buffer.length(); i++) { + event.key.keysym.sym = (SDLKey)buffer[i]; + event.type = SDL_KEYDOWN; + new SDLEventInserter(event, time); + time++; + event.type = SDL_KEYUP; + new SDLEventInserter(event, time); + time++; + } buffer = ""; } Index: KeyEventInserter.hh =================================================================== RCS file: /cvsroot/openmsx/openMSX/src/KeyEventInserter.hh,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- KeyEventInserter.hh 2001/10/17 19:51:47 1.2 +++ KeyEventInserter.hh 2001/11/18 21:36:11 1.3 @@ -2,29 +2,20 @@ #define __KEYEVENTINSERTER_HH__ #include "emutime.hh" -#include "Scheduler.hh" - +#include "SDLEventInserter.hh" #include <string> -class KeyEventInserterEvent: public Schedulable -{ - public: - KeyEventInserterEvent(int key, bool up); - void executeUntilEmuTime(const Emutime &time); - private: - int key; - bool up; -}; class KeyEventInserter { public: - KeyEventInserter(); - KeyEventInserter &operator<<(std::string &str); - KeyEventInserter &operator<<(const char* cstr); - void flush(uint64 offset=0); + KeyEventInserter(); + KeyEventInserter &operator<<(std::string &str); + KeyEventInserter &operator<<(const char* cstr); + void flush(uint64 offset=0); + private: - std::string buffer; + std::string buffer; }; Index: Makefile.am =================================================================== RCS file: /cvsroot/openmsx/openMSX/src/Makefile.am,v retrieving revision 1.64 retrieving revision 1.65 diff -u -d -r1.64 -r1.65 --- Makefile.am 2001/11/17 16:27:10 1.64 +++ Makefile.am 2001/11/18 21:36:11 1.65 @@ -51,7 +51,8 @@ MSXMegaRom.hh MSXMegaRom.cc \ MSXKonamiSynthesizer.hh MSXKonamiSynthesizer.cc \ DACSound.cc DACSound.hh \ - KeyEventInserter.cc KeyEventInserter.hh + KeyEventInserter.cc KeyEventInserter.hh \ + SDLEventInserter.cc SDLEventInserter.hh # MSXPostLoad.hh MSXPostLoad.cc Index: Scheduler.cc =================================================================== RCS file: /cvsroot/openmsx/openMSX/src/Scheduler.cc,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- Scheduler.cc 2001/11/16 11:34:08 1.28 +++ Scheduler.cc 2001/11/18 21:36:11 1.29 @@ -45,7 +45,7 @@ Scheduler *Scheduler::oneInstance = NULL; -void Scheduler::setSyncPoint(Emutime &time, Schedulable &device) +void Scheduler::setSyncPoint(const Emutime &time, Schedulable &device) { PRT_DEBUG("Sched: registering " << device.getName() << " for emulation at " << time); PRT_DEBUG("Sched: CPU is at " << MSXCPU::instance()->getCurrentTime()); Index: Scheduler.hh =================================================================== RCS file: /cvsroot/openmsx/openMSX/src/Scheduler.hh,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- Scheduler.hh 2001/11/16 11:34:08 1.19 +++ Scheduler.hh 2001/11/18 21:36:11 1.20 @@ -37,7 +37,7 @@ public: virtual ~Scheduler(); static Scheduler *instance(); - void setSyncPoint(Emutime ×tamp, Schedulable &activedevice); + void setSyncPoint(const Emutime ×tamp, Schedulable &activedevice); void scheduleEmulation(); void stopScheduling(); // EventListener Index: openmsx.cc =================================================================== RCS file: /cvsroot/openmsx/openMSX/src/openmsx.cc,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- openmsx.cc 2001/11/15 23:01:14 1.30 +++ openmsx.cc 2001/11/18 21:36:11 1.31 @@ -124,8 +124,9 @@ // Start a new thread for event handling thread=SDL_CreateThread(eventDistributorStarter, 0); - // test thingy for Joost: [doesn't do harm YET] - keyi << "Hello"; + //It works!! But commented out because this is annoying + //keyi << "... key inserter test ..."; + //keyi.flush(); PRT_DEBUG ("starting MSX"); MSXMotherBoard::instance()->StartMSX(); |