1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#ifndef _PERLOIS_KEYLISTENER_H_
#define _PERLOIS_KEYLISTENER_H_
#include "perlOIS.h"
#include <map>
#include <string>
using namespace std;
// this class implements OIS::KeyListener,
// so it can be passed to Keyboard->setEventCallback,
// but it allows implementing the callbacks from Perl
class PerlOISKeyListener : public OIS::KeyListener
{
public:
PerlOISKeyListener();
~PerlOISKeyListener();
// these are used in xs/Keyboard.xs setEventCallback
void setPerlObject(SV *pobj);
// KeyListener interface
bool keyPressed(const OIS::KeyEvent &evt);
bool keyReleased(const OIS::KeyEvent &evt);
private:
bool perlCallbackCan(string const &cbmeth);
void setCans();
bool callPerlCallback(string const &cbmeth, const OIS::KeyEvent &evt);
SV * mPerlObj;
typedef map<string, bool> CanMap;
CanMap mCanMap;
};
#endif /* define _PERLOIS_KEYLISTENER_H_ */
|