X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fsensor.cpp;h=ecd06473fb4bdf2234a2c149f19d0b3ae1af849e;hb=73e4a36bbf828e07b83a779b696875e1f80045cc;hp=618a06b7b609c6ac8a930bc62c197bb4ac2db768;hpb=b28062f2dc88e082ee5a28b2e1f7c4c8bd989023;p=r2c2.git diff --git a/source/libr2c2/sensor.cpp b/source/libr2c2/sensor.cpp index 618a06b..ecd0647 100644 --- a/source/libr2c2/sensor.cpp +++ b/source/libr2c2/sensor.cpp @@ -9,6 +9,7 @@ namespace R2C2 { Sensor::Sensor(Layout &l): layout(l), address(0), + id(0), invert(false), state(INACTIVE) { @@ -28,11 +29,13 @@ Sensor::~Sensor() void Sensor::set_address(unsigned a) { Driver *driver = (layout.has_driver() ? &layout.get_driver() : 0); - if(driver && address) - driver->remove_sensor(address); + if(driver && id) + driver->remove_sensor(id); address = a; if(driver && address) - driver->add_sensor(address); + id = driver->add_sensor(address); + else + id = 0; } void Sensor::tick(const Time::TimeDelta &dt) @@ -52,9 +55,9 @@ void Sensor::tick(const Time::TimeDelta &dt) } } -void Sensor::event(unsigned a, bool s) +void Sensor::event(unsigned i, bool s) { - if(a==address) + if(i==id) { if(s!=invert && state