Code Search for Developers
 
 
  

csjoywin.h from Spatial Knowledge Experiments at Krugle


Show csjoywin.h syntax highlighted

/*
    Copyright (C) 2002, 2003, 2004, 2005 by Cappa Luca
    Written by Luca Cappa groton@users.sourceforge.net
  
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.
  
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.
  
    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 0139, USA.
*/

#ifndef _CS_WINDOWS_JOYSTICK_
#define _CS_WINDOWS_JOYSTICK_

/**
 * This plugin puts joystick events in CS event queue.
 * Joystick data is gathered via DirectInput joystick api.
 */

#include "csutil/scf.h"
#include "iutil/event.h"
#include "iutil/eventh.h"
#include "iutil/eventq.h"
#include "iutil/comp.h"
#include "csutil/cfgacc.h"
#include "ikjoystick.h"

#define PLUGIN_NAME "crystalspace.device.windows.joywin"

#define BUTTON_1    0x00000001l
#define BUTTON_2    0x00000002l
#define BUTTON_3    0x00000004l
#define BUTTON_4    0x00000008l


class csWindowsJoystick : public iKJoystick, public iComponent
{
protected:
  iObjectRegistry *m_objectReg;
  csRef<iGraphics2D> m_g2d;
  
  csRef<iEventQueue> l_eQ;
  csRef<iEventOutlet> m_eventOutlet;
  
  bool m_bHooked;//hooked in the iEventQueue?
  
  bool m_acquired;

  bool m_isActive;//is at least one joystick available?
  
  bool m_cmdSystemOpenReceived;//Has cscmdSystemOpen been received?

  bool Open ();
  bool Close ();
  void Report (int p_severity, const char* p_msg, ...);
  
public:
  
  SCF_DECLARE_IBASE;
  
  csWindowsJoystick (iBase *p_parent);
  virtual ~csWindowsJoystick ();
  
  virtual bool Initialize (iObjectRegistry *p_oreg);
  virtual bool HandleEvent (iEvent &p_event);
  
  //iKJoystick interface-------------starts
  bool SetAcquire (bool p_bool);
  bool GetAcquire ();
  bool IsActive ();
  bool InitializeDI ();
  //iKJoystick interface-------------ends

  struct eiEventHandler : public iEventHandler
  {
    SCF_DECLARE_EMBEDDED_IBASE (csWindowsJoystick);
    virtual bool HandleEvent (iEvent &Event)
    {
      return scfParent->HandleEvent (Event);
    }
  } scfiEventHandler;
  friend struct eiEventHandler;
  
  struct eiEventPlug : public iEventPlug
  {
    SCF_DECLARE_EMBEDDED_IBASE (csWindowsJoystick);
    virtual unsigned GetPotentiallyConflictingEvents ()
    { 
      return CSEVTYPE_Joystick;
    }
    virtual unsigned QueryEventPriority (unsigned )
    {
      return 110;
    }
  } scfiEventPlug;
  friend struct eiEventPlug;
};

#endif // _CS_WINDOWS_JOYSTICK_




See more files for this project here

Spatial Knowledge Experiments

A simulation of 3D virtual worlds for psychological experiments

Project homepage: http://sourceforge.net/projects/ske
Programming language(s): C,C++,Perl
License: other

  Jamfile
  csjoywin.cpp
  csjoywin.h
  ikjoystick.h
  joystick.csplugin