InputDevice.cpp

Go to the documentation of this file.
00001 
00005 /* Copyright © 2009, 2010 James Legg.
00006     This program is free software: you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation, either version 3 of the License, or
00009     (at your option) any later version.
00010 */
00011 #include "InputDevice.h"
00012 #include "GameObjects/Car.h"
00013 #include "InputHandler.h"
00014 
00015 namespace Engine
00016 {
00017 
00018 InputDevice::InputDevice()
00019     : scene(0),
00020       car(0)
00021 {
00022     handler_reference = InputHandler::get_instance().add_device(*this);
00023 }
00024 
00025 InputDevice::~InputDevice()
00026 {
00027     InputHandler::get_instance().remove_device(InputHandler::iterator(handler_reference));
00028 }
00029 
00030 void InputDevice::set_scene(Scene & scene_in)
00031 {
00032     scene = &scene_in;
00033 }
00034 
00035 void InputDevice::set_car(GameObjects::Car * car_in)
00036 {
00037     car = car_in;
00038 }
00039 
00040 std::set<InputDevice *>::iterator InputDevice::get_handle() const
00041 {
00042     return handler_reference;
00043 }
00044 
00045 void InputDevice::report(InputReport::ReportType type, int value)
00046 {
00047     InputReport report(this, type, value);
00048     if(scene)
00049     {
00050         scene->take_input(report);
00051     }
00052     if (car)
00053     {
00054         car->take_input(report);
00055     }   
00056 }
00057 
00058 }

Get Racer at SourceForge.net. Fast, secure and Free Open Source software downloads

Generated at Mon Sep 6 00:41:12 2010 by Doxygen version 1.4.7 for Racer version svn335.