Skip to content

Commit

Permalink
KOTOR: Enable free look using the right mouse button
Browse files Browse the repository at this point in the history
  • Loading branch information
vobject authored and DrMcCoy committed Mar 19, 2013
1 parent 0b2f339 commit 4dee958
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/engines/kotor/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,16 @@ void Module::handleEvents() {
}

bool Module::handleCamera(const Events::Event &e) {
if (e.type != Events::kEventKeyDown)
return false;

if (e.type == Events::kEventKeyDown)
return handleCameraKeyboardInput(e);
else if (e.type == Events::kEventMouseMove)
return handleCameraMouseInput(e);

return false;
}

bool Module::handleCameraKeyboardInput(const Events::Event &e) {
if (e.key.keysym.sym == SDLK_UP)
CameraMan.move( 0.5);
else if (e.key.keysym.sym == SDLK_DOWN)
Expand Down Expand Up @@ -356,6 +363,16 @@ bool Module::handleCamera(const Events::Event &e) {
return true;
}

bool Module::handleCameraMouseInput(const Events::Event &e) {
// Holding down the right mouse button enables free look.
if (e.motion.state & SDL_BUTTON(3))
CameraMan.turn(-0.5 * e.motion.yrel, 0.5 * e.motion.xrel, 0.0);
else
return false;

return true;
}

Area *Module::createArea() const {
return new Area;
}
Expand Down
2 changes: 2 additions & 0 deletions src/engines/kotor/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ class Module {

void handleEvents();
bool handleCamera(const Events::Event &e);
bool handleCameraKeyboardInput(const Events::Event &e);
bool handleCameraMouseInput(const Events::Event &e);

virtual Area *createArea() const;

Expand Down

0 comments on commit 4dee958

Please sign in to comment.