Panda3D
 All Classes Functions Variables Enumerations
AwMouseAndKeyboard.cxx
00001 // Filename: AwMouseAndKeyboard.cxx
00002 // Created by:  Bei Yang (Mar2010)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "config_awesomium.h"
00016 #include "AwMouseAndKeyboard.h"
00017 #include "dataNodeTransmit.h"
00018 
00019 TypeHandle AwMouseAndKeyboard::_type_handle;
00020 
00021 AwMouseAndKeyboard::AwMouseAndKeyboard(const string &name):
00022 DataNode(name)
00023 {
00024   _button_events_input = define_input("button_events", ButtonEventList::get_class_type());
00025   _button_events_output = define_output("button_events", ButtonEventList::get_class_type());
00026 }
00027 
00028 
00029 void AwMouseAndKeyboard::do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, DataNodeTransmit &output){
00030 
00031   if (input.has_data(_button_events_input)) {
00032     const ButtonEventList *button_events;
00033     DCAST_INTO_V(button_events, input.get_data(_button_events_input).get_ptr());
00034     
00035     int num_events = button_events->get_num_events();
00036     for (int i = 0; i < num_events; i++) {
00037       const ButtonEvent &be = button_events->get_event(i);
00038       string event_name = be._button.get_name();
00039       printf("Button Event! : %s with code %i and index %i ", event_name.c_str(), be._keycode, be._button.get_index());
00040       if(be._type == ButtonEvent::T_down) printf("down");
00041       if(be._type == ButtonEvent::T_repeat) printf("repeat");
00042       if(be._type == ButtonEvent::T_up) printf("up");
00043       if(be._type == ButtonEvent::T_resume_down) printf("T_resume_down");
00044       printf("\n");
00045     }
00046   }
00047 
00048 }
 All Classes Functions Variables Enumerations