input drastically improved

This commit is contained in:
James Turk 2005-07-19 05:57:43 +00:00
parent 538f2c0b28
commit 06e2e736bb
2 changed files with 48 additions and 5 deletions

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: Audio_test.cpp,v 1.3 2005/07/18 05:14:19 cozman Exp $ // $Id: Audio_test.cpp,v 1.4 2005/07/19 05:57:58 cozman Exp $
#include "photon.hpp" #include "photon.hpp"
using namespace photon; using namespace photon;
@ -199,8 +199,7 @@ public:
{ {
AppCore::getInstance().createDisplay(800,600,32,0,0,false); AppCore::getInstance().createDisplay(800,600,32,0,0,false);
AudioCore::setDesiredDevice("OSS"); AudioCore::initAudioDevice("OSS");
new AudioCore;
Kernel::getInstance().addTask(TaskPtr(new MainTask())); Kernel::getInstance().addTask(TaskPtr(new MainTask()));

View File

@ -5,12 +5,47 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: Input_test.cpp,v 1.1 2005/07/17 06:19:18 cozman Exp $ // $Id: Input_test.cpp,v 1.2 2005/07/19 05:57:43 cozman Exp $
#include "photon.hpp" #include "photon.hpp"
using namespace photon; using namespace photon;
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
class LastEventListener : public InputListener
{
public:
void onKeyPress(int key)
{
lastEvent = "key " + boost::lexical_cast<std::string>(key) +
" pressed";
}
void onKeyRelease(int key)
{
lastEvent = "key " + boost::lexical_cast<std::string>(key) +
" released";
}
void onMouseButtonPress(int button)
{
lastEvent = "mouse button " + boost::lexical_cast<std::string>(button) +
" pressed";
}
void onMouseButtonRelease(int button)
{
lastEvent = "mouse button " + boost::lexical_cast<std::string>(button) +
" released";
}
void onMouseMove(const math::Vector2& pos)
{
lastEvent = "mouse moved to " + boost::lexical_cast<std::string>(pos);
}
std::string lastEvent;
};
class MainTask : public Task class MainTask : public Task
{ {
@ -45,11 +80,19 @@ public:
video.clear(); video.clear();
font.beginDraw(0,curHeight) << "Last event: " << lel.lastEvent <<
font.endDraw();
curHeight += fontHeight;
font.beginDraw(0,curHeight) << "Mouse at " << app.getMouseX() << "," << font.beginDraw(0,curHeight) << "Mouse at " << app.getMouseX() << "," <<
app.getMouseY() << " wheel = " << app.getMouseWheelPos() << app.getMouseY() << " wheel = " << app.getMouseWheelPos() <<
font.endDraw(); font.endDraw();
curHeight += fontHeight; curHeight += fontHeight;
font.beginDraw(0,curHeight) << "#Pressed Keys = " <<
app.getPressedKeys().size() << font.endDraw();
curHeight += fontHeight;
if(app.keyPressed(KEY_SPACE)) if(app.keyPressed(KEY_SPACE))
{ {
font.drawText(0,curHeight, "Space key is pressed."); font.drawText(0,curHeight, "Space key is pressed.");
@ -80,6 +123,7 @@ public:
private: private:
video::Font font; video::Font font;
LastEventListener lel;
Log log; Log log;
AppCore& app; AppCore& app;