(please forgive shorthand memory) have code similar to:
bool myclass::handle(event ea){ switch (ea.geteventtype()){ case(osgga::keydown): switch (ea.getkey() ) { case (osgga::key_lshift): down = true; break; case (osgga::key_w): forward = true; break; } return false; case(osgga::keyup){ switch (ea.getkey() ) { case (osgga::key_lshift): down = false; break; case (osgga::key_w): forward = false; break; } return false; }
i print ea.getkey() , when press 'w', expected behavior of moving forward. however, if press 'shift' next , let go of 'w', debug: "keyup: w". note it's capitalized, , continue move forward until lowercase 'w' pressed , released.
am expected use basic c++ functions convert lowercase? i'm trying use standard wasd movement space/l-shift move , down around environment.
when press key, osg creates event corresponding key code, different letter or corresponding capitalized one.
osgga::key_w
it's enum value corresponding lower case 'w' (119 ascii code), while 'w' has code 87.
so if want either lower or upper case keypress, write like:
if (ea.geteventtype() == osgga::guieventadapter::keydown) { if (ea.getkey() == osgga::guieventadapter::key_w || ea.getkey() == 'w') { /*code when either w or w pressed*/ } }
Comments
Post a Comment