-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Many many changes. In short, now able to render scenes entierly from …
…erland and receive all keyboard and mouse events within erlang.
- Loading branch information
John Koenig
committed
Jul 13, 2011
1 parent
a2aae2e
commit 01cfa9c
Showing
16 changed files
with
1,774 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#include "OgreEvent.h" | ||
|
||
extern "C" { | ||
#include <gen_cnode.h> | ||
} | ||
|
||
using namespace OIS; | ||
|
||
bool OgreEvent::keyPressed( const KeyEvent& e ){ | ||
ei_x_buff key = {0}; | ||
|
||
ei_x_new(&key); | ||
|
||
gen_cnode_format(&key, "~i", e.key); | ||
|
||
gen_cnode_notify("keyPressed", &key); | ||
|
||
ei_x_free(&key); | ||
|
||
return true; | ||
} | ||
|
||
bool OgreEvent::keyReleased( const KeyEvent& e ){ | ||
ei_x_buff key = {0}; | ||
|
||
ei_x_new(&key); | ||
|
||
gen_cnode_format(&key, "~i", e.key); | ||
|
||
gen_cnode_notify("keyReleased", &key); | ||
|
||
ei_x_free(&key); | ||
|
||
return true; | ||
} | ||
|
||
bool OgreEvent::mouseMoved( const MouseEvent& e ){ | ||
ei_x_buff event = {0}; | ||
|
||
ei_x_new(&event); | ||
|
||
encodeMouseEvent((MouseButtonID)0, e, &event); | ||
|
||
gen_cnode_notify("mouseMoved", &event); | ||
|
||
ei_x_free(&event); | ||
|
||
return true; | ||
} | ||
|
||
bool OgreEvent::mousePressed( const MouseEvent& e, MouseButtonID id ){ | ||
ei_x_buff event = {0}; | ||
|
||
ei_x_new(&event); | ||
|
||
encodeMouseEvent(id, e, &event); | ||
|
||
gen_cnode_notify("mousePressed", &event); | ||
|
||
ei_x_free(&event); | ||
|
||
return true; | ||
} | ||
|
||
bool OgreEvent::mouseReleased( const MouseEvent& e, MouseButtonID id ){ | ||
ei_x_buff event = {0}; | ||
|
||
ei_x_new(&event); | ||
|
||
encodeMouseEvent(id, e, &event); | ||
|
||
gen_cnode_notify("mouseReleased", &event); | ||
|
||
ei_x_free(&event); | ||
return true; | ||
} | ||
|
||
//Exported utility functions | ||
int OgreEvent::encodeMouseEvent( MouseButtonID id, | ||
const MouseEvent& event, | ||
ei_x_buff* output ){ | ||
|
||
if( ei_x_encode_tuple_header(output, 2) || | ||
ei_x_encode_ulong(output, id) || | ||
ei_x_encode_list_header(output, 3) || | ||
|
||
//Encode X position | ||
ei_x_encode_tuple_header(output, 2) || | ||
ei_x_encode_long(output, event.state.X.abs) || | ||
ei_x_encode_long(output, event.state.X.rel) || | ||
|
||
//Encode Y position | ||
ei_x_encode_tuple_header(output, 2) || | ||
ei_x_encode_long(output, event.state.Y.abs) || | ||
ei_x_encode_long(output, event.state.Y.rel) || | ||
|
||
//Encode Z position | ||
ei_x_encode_tuple_header(output, 2) || | ||
ei_x_encode_long(output, event.state.Z.abs) || | ||
ei_x_encode_long(output, event.state.Z.rel) || | ||
|
||
//Encode end of list | ||
ei_x_encode_empty_list(output) ) | ||
{ | ||
return -1; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef OGREEVENT_H | ||
#define OGREEVENT_H | ||
|
||
#include <OIS.h> | ||
|
||
#include <gen_cnode.h> | ||
|
||
class OgreEvent : public OIS::KeyListener, | ||
public OIS::MouseListener { | ||
|
||
int encodeMouseEvent( OIS::MouseButtonID id, | ||
const OIS::MouseEvent& event, | ||
ei_x_buff* output ); | ||
public: | ||
bool keyPressed( const OIS::KeyEvent& e ); | ||
bool keyReleased( const OIS::KeyEvent& e ); | ||
|
||
bool mouseMoved( const OIS::MouseEvent &e ); | ||
bool mousePressed( const OIS::MouseEvent &e, OIS::MouseButtonID id ); | ||
bool mouseReleased( const OIS::MouseEvent &e, OIS::MouseButtonID id ); | ||
}; | ||
|
||
#endif |
Oops, something went wrong.