0ad/source/dcdt/se/sr_event.cpp
janwas 5bf9bca9ef fix/disable warnings.
there are too many W4 and "potentially uninitialized", so those are
disabled by 0ad_warning_disable.h.

the silly "int x = strlen" and very dangerous "int x = (void*)p" (and
vice versa) problems are fixed.

This was SVN commit r5526.
2007-12-23 12:18:57 +00:00

64 lines
1.3 KiB
C++

#include "precompiled.h"
#include "0ad_warning_disable.h"
# include "sr_event.h"
//# define SR_USE_TRACE1
# include "sr_trace.h"
//===================================== SrEvent =================================
SrEvent::SrEvent ()
{
init ();
}
void SrEvent::init ()
{
type = None;
key = 0;
button = 0;
button1 = button2 = button3 = 0;
ctrl = shift = alt = key = 0;
width = heigth = 0;
pixel_size = 0.05f;
}
void SrEvent::init_lmouse ()
{
type = None;
key = 0;
button = 0;
button1 = button2 = button3 = 0;
ctrl = shift = alt = key = 0;
lmouse = mouse;
lmouse = mouse;
mouse.x = mouse.y = 0;
}
const char *SrEvent::type_name () const
{
switch ( type )
{ case None : return "none";
case Push : return "push";
case Drag : return "drag";
case Release : return "release";
case Keyboard : return "keyboard";
}
return "undefined?!";
}
SrOutput& operator<< ( SrOutput& out, const SrEvent& e )
{
out << e.type_name();
if ( e.type==SrEvent::Keyboard )
out << " [" << (e.key? e.key:' ') << ':' << (int)e.key << ']';
out << " POS:" << e.mouse <<
" BUTS:" << (int)e.button1<<(int)e.button2<<(int)e.button3<<
" ACS:" << (int)e.alt<<(int)e.ctrl<<(int)e.shift;
return out;
}