pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r3070 - in trunk/pingus/src: . input


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3070 - in trunk/pingus/src: . input
Date: Mon, 3 Sep 2007 19:17:59 +0200

Author: grumbel
Date: 2007-09-03 19:17:58 +0200 (Mon, 03 Sep 2007)
New Revision: 3070

Added:
   trunk/pingus/src/input/SConstruct.main
   trunk/pingus/src/input/xinput_device.cpp
   trunk/pingus/src/input/xinput_device.hpp
   trunk/pingus/src/input/xinput_driver.cpp
   trunk/pingus/src/input/xinput_driver.hpp
Removed:
   trunk/pingus/src/input/SConstruct
Modified:
   trunk/pingus/src/SConscript
Log:
- added XInput framework (untested, but compiles, this is X11 only)

Modified: trunk/pingus/src/SConscript
===================================================================
--- trunk/pingus/src/SConscript 2007-09-03 03:44:09 UTC (rev 3069)
+++ trunk/pingus/src/SConscript 2007-09-03 17:17:58 UTC (rev 3070)
@@ -24,7 +24,7 @@
                   CCFLAGS = ['-O2', '-Wall', '-Werror', '-g'],
                   CPPDEFINES = ['ENABLE_BINRELOC', 'HAVE_CWIID'],
                   CPPPATH = ['..', '.'],
-                  LIBS = ['cwiid']) # FIXME: Make this configurable
+                  LIBS = ['cwiid', 'Xi']) # FIXME: Make this configurable
 
 env.ParseConfig('sdl-config  --cflags --libs')
 env['LIBS'] += ['SDL_image', 'SDL_mixer', 'png']
@@ -32,7 +32,6 @@
 env.Program('../pingus', [
 
 # # 'gui/buffer_graphic_context.cpp', 
-# # 'input/axes/mouse_axis.cpp', 
 # # 'pingus_level_test.cpp', 
 # # 'sound/slot_manager.cpp', 
 # # 'xml_eval.cpp',
@@ -151,6 +150,8 @@
 'input/usbmouse_driver.cpp',
 'input/wiimote_driver.cpp',
 'input/wiimote.cpp',
+'input/xinput_driver.cpp',
+'input/xinput_device.cpp',
 'input/sdl_driver.cpp',
 'input/manager.cpp',
 

Deleted: trunk/pingus/src/input/SConstruct
===================================================================
--- trunk/pingus/src/input/SConstruct   2007-09-03 03:44:09 UTC (rev 3069)
+++ trunk/pingus/src/input/SConstruct   2007-09-03 17:17:58 UTC (rev 3070)
@@ -1,37 +0,0 @@
-##  -*- python -*-
-
-env = Environment(CCFLAGS  = ['-O0', '-Wall', '-Werror', '-g'],
-                  CPPPATH  = ['..', '../..'],
-                  CPPDEFINES = ['HAVE_CWIID'],
-                  LIBS = ['cwiid'])
-
-env.ParseConfig('sdl-config  --cflags --libs')
-env['LIBS'] += ['SDL_image', 'SDL_mixer', 'png']
-
-env.Program('main', [
-    'main.cpp',
-    'controller_description.cpp',
-    'controller.cpp',
-    'core_driver.cpp',
-    'usbmouse_driver.cpp',
-    'wiimote_driver.cpp',
-    'wiimote.cpp',
-    'sdl_driver.cpp',
-    'manager.cpp',
-    '../file_reader.cpp',
-    '../string_util.cpp',
-    '../path_manager.cpp',
-    '../pingus_error.cpp',
-    '../lisp/parser.cpp',
-    '../lisp/lexer.cpp',
-    '../lisp/lisp.cpp',
-    '../resource_modifier.cpp',
-    '../globals.cpp',
-    '../sexpr_file_reader.cpp',
-    '../math/vector3f.cpp',
-    '../debug.cpp',
-    '../debug_stream.cpp',
-    '../system.cpp',
-])
-
-# EOF #

Copied: trunk/pingus/src/input/SConstruct.main (from rev 3069, 
trunk/pingus/src/input/SConstruct)

Added: trunk/pingus/src/input/xinput_device.cpp
===================================================================
--- trunk/pingus/src/input/xinput_device.cpp    2007-09-03 03:44:09 UTC (rev 
3069)
+++ trunk/pingus/src/input/xinput_device.cpp    2007-09-03 17:17:58 UTC (rev 
3070)
@@ -0,0 +1,308 @@
+/*  $Id$
+**   __      __ __             ___        __   __ __   __
+**  /  \    /  \__| ____    __| _/_______/  |_|__|  | |  |   ____
+**  \   \/\/   /  |/    \  / __ |/  ___/\   __\  |  | |  | _/ __ \
+**   \        /|  |   |  \/ /_/ |\___ \  |  | |  |  |_|  |_\  ___/
+**    \__/\  / |__|___|  /\____ /____  > |__| |__|____/____/\___  >
+**         \/          \/      \/    \/                         \/
+**  Copyright (C) 2007 Ingo Ruhnke <address@hidden>
+**
+**  This program is free software; you can redistribute it and/or
+**  modify it under the terms of the GNU General Public License
+**  as published by the Free Software Foundation; either version 2
+**  of the License, or (at your option) any later version.
+**
+**  This program 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 General Public License for more details.
+** 
+**  You should have received a copy of the GNU General Public License
+**  along with this program; if not, write to the Free Software
+**  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+**  02111-1307, USA.
+*/
+
+#include "SDL_syswm.h"
+
+#include "xinput_driver.hpp"
+#include "xinput_device.hpp"
+
+namespace Input {
+
+#define INVALID_EVENT_TYPE -1
+
+XInputDevice::XInputDevice(XInputDriver* owner_, XDeviceInfo* info)
+  : owner(owner_),
+    name(info->name),
+    absolute(false),
+    num_keys   (0),
+    motion_type        (INVALID_EVENT_TYPE),
+    button_press_type  (INVALID_EVENT_TYPE),
+    button_release_type(INVALID_EVENT_TYPE),
+    key_press_type     (INVALID_EVENT_TYPE),
+    key_release_type   (INVALID_EVENT_TYPE),
+    proximity_in_type  (INVALID_EVENT_TYPE),
+    proximity_out_type (INVALID_EVENT_TYPE)
+{
+  //info = find_device_info(owner->get_display(), name.c_str(), True);
+  //if (!info)
+  // throw CL_Error("CL_InputDeviceXInput Error: Couldn't find device: " + 
name);
+
+  get_info(info);
+
+  if (!register_events(owner->get_syswminfo().info.x11.display, info, 
name.c_str(), True))
+    {
+      std::cout << "debug: CL_InputDeviceXInput: Couldn't find device: " << 
name << std::endl;
+    }
+  else
+    {
+      //slot_xevent = owner->sig_unknown_xevent.connect(this, 
&CL_InputDevice_XInput::on_xevent);
+    }
+}
+
+void
+XInputDevice::on_xevent(XEvent &event)
+{
+  if (0)
+    std::cout << this << " event: "
+              << event.type << " Defs: "
+              << motion_type << " "
+              << button_press_type << " "
+              << button_release_type << " "
+              << key_press_type << " "
+              << key_release_type << " "
+              << proximity_out_type << " "
+              << proximity_in_type << " "
+              << std::endl;
+
+  std::vector<AxisInfo> old_axis = axis;
+  std::vector<bool>     old_buttons = buttons;
+
+  if (event.type == motion_type)
+    {
+      XDeviceMotionEvent *motion = (XDeviceMotionEvent *) &event;
+
+      //printf("motion ");
+
+      for(int loop=0; loop<motion->axes_count; loop++) {
+        //printf("a[%d]=%d ", motion->first_axis + loop, 
motion->axis_data[loop]);
+        axis[loop + motion->first_axis].pos = motion->axis_data[loop];
+      }
+      //printf("\n");
+    }
+  else if ((event.type == button_press_type) ||
+           (event.type == button_release_type))
+    {
+      int loop;
+      XDeviceButtonEvent *button = (XDeviceButtonEvent *) &event;
+
+      //printf("button %s %d ", (event.type == button_release_type) ? 
"release" : "press  ", button->button);
+
+      buttons[button->button] = (event.type == button_press_type);
+
+      for(loop=0; loop<button->axes_count; loop++) {
+        //printf("a[%d]=%d ", button->first_axis + loop, 
button->axis_data[loop]);
+        axis[loop + button->first_axis].pos = button->axis_data[loop];
+      }
+      //printf("\n");
+    }
+  else if ((event.type == key_press_type) ||
+           (event.type == key_release_type))
+    {
+      int loop;
+      XDeviceKeyEvent *key = (XDeviceKeyEvent *) &event;
+
+      printf("key %s %d ", (event.type == key_release_type) ? "release" : 
"press  ", key->keycode);
+
+      for(loop=0; loop<key->axes_count; loop++) {
+        printf("a[%d]=%d ", key->first_axis + loop, key->axis_data[loop]);
+        axis[loop + key->first_axis].pos = key->axis_data[loop];
+      }
+      printf("\n");
+    }
+  else if ((event.type == proximity_out_type) ||
+           (event.type == proximity_in_type))
+    {
+      int loop;
+      XProximityNotifyEvent *prox = (XProximityNotifyEvent *) &event;
+
+      printf("proximity %s ", (event.type == proximity_in_type) ? "in " : 
"out");
+
+      for(loop=0; loop<prox->axes_count; loop++) {
+        printf("a[%d]=%d ", prox->first_axis + loop, prox->axis_data[loop]);
+        axis[loop + prox->first_axis].pos = prox->axis_data[loop];
+      }
+      printf("\n");
+    }
+  else
+    {
+      printf("CL_InputDevice_XInput: what's that %d\n", event.type);
+    }
+
+
+  for (std::vector<bool>::size_type i = 0; i < buttons.size(); ++i)
+    {
+      if (buttons[i] != old_buttons[i])
+        {
+//           CL_InputEvent ie;
+
+//           ie.id           = i;
+//           ie.type         = CL_InputEvent::pressed;
+//           ie.device       = CL_InputDevice(this);
+//           ie.mouse_pos    = CL_Point(0, 0);
+//           ie.axis_pos     = 0;
+//           ie.repeat_count = false;
+
+//           sig_axis_move(ie);
+        }
+    }
+
+  for (std::vector<AxisInfo>::size_type i = 0; i < axis.size(); ++i)
+    {
+      if (axis[i].pos != old_axis[i].pos)
+        {
+//           CL_InputEvent ie;
+          
+//           ie.id           = i;
+//           ie.type         = CL_InputEvent::axis_moved;
+//           ie.device       = CL_InputDevice(this);
+//           ie.mouse_pos    = CL_Point(0, 0);
+//           ie.axis_pos     = get_axis(i);
+//           ie.repeat_count = false;
+          
+//           sig_axis_move(ie);
+        }
+    }
+}
+
+int
+XInputDevice::register_events(Display* dpy,
+                              XDeviceInfo* info,
+                              const char* dev_name,
+                              Bool handle_proximity)
+{
+  int             number = 0; /* number of events registered */
+  XEventClass     event_list[7];
+  int             i;
+  XDevice         *device;
+  Window          root_win;
+  unsigned long   screen;
+  XInputClassInfo *ip;
+
+  screen   = DefaultScreen(dpy);
+  root_win = RootWindow(dpy, screen);
+
+  device = XOpenDevice(dpy, info->id);
+
+  if (!device) {
+    fprintf(stderr, "unable to open device %s\n", dev_name);
+    return 0;
+  }
+
+  if (device->num_classes > 0) {
+    for (ip = device->classes, i=0; i<info->num_classes; ip++, i++) {
+      switch (ip->input_class) {
+        case KeyClass:
+          DeviceKeyPress  (device, key_press_type,   event_list[number]); 
number++;
+          DeviceKeyRelease(device, key_release_type, event_list[number]); 
number++;
+          break;
+
+        case ButtonClass:
+          DeviceButtonPress  (device, button_press_type,   
event_list[number]); number++;
+          DeviceButtonRelease(device, button_release_type, 
event_list[number]); number++;
+          break;
+
+        case ValuatorClass:
+          DeviceMotionNotify(device, motion_type, event_list[number]); 
number++;
+          if (handle_proximity) {
+            ProximityIn (device, proximity_in_type,  event_list[number]); 
number++;
+            ProximityOut(device, proximity_out_type, event_list[number]); 
number++;
+          }
+          break;
+
+        default:
+          fprintf(stderr, "unknown class\n");
+          break;
+      }
+    }
+
+    if (XSelectExtensionEvent(dpy, root_win, event_list, number)) {
+      fprintf(stderr, "error selecting extended events\n");
+      return 0;
+    }
+  }
+
+  //std::cout << "### Registered events: " << number << std::endl;
+  return number;
+}
+
+void
+XInputDevice::get_info(XDeviceInfo* info)
+{
+  int   i,j;
+  XAnyClassPtr any;
+  XKeyInfoPtr  k;
+  XButtonInfoPtr b;
+  XValuatorInfoPtr v;
+  XAxisInfoPtr a;
+
+  printf("\"%s\"\tid=%ld\t[%s]\n", info->name, info->id,
+     (info->use == IsXExtensionDevice) ? "XExtensionDevice" :
+      ((info->use == IsXPointer) ? "XPointer" : "XKeyboard"));
+
+  if (info->num_classes > 0) {
+    any = (XAnyClassPtr) (info->inputclassinfo);
+    for (i=0; i<info->num_classes; i++) {
+      switch (any->c_class) {
+        case KeyClass:
+          k = (XKeyInfoPtr) any;
+  
+          printf("\tNum_keys is %d\n", k->num_keys);
+          printf("\tMin_keycode is %d\n", k->min_keycode);
+          printf("\tMax_keycode is %d\n", k->max_keycode);
+
+          num_keys = k->num_keys;
+          break;
+
+        case ButtonClass:
+          b = (XButtonInfoPtr)any;
+          printf("\tNum_buttons is %d\n", b->num_buttons);
+
+          buttons.resize(b->num_buttons, false);
+          break;
+
+        case ValuatorClass:
+          v = (XValuatorInfoPtr)any;
+          a = (XAxisInfoPtr) ((char*)v +
+                              sizeof (XValuatorInfo));
+
+          printf("\tNum_axes is %d\n", v->num_axes);
+          printf("\tMode is %s\n", (v->mode == Absolute) ? "Absolute" : 
"Relative");
+          printf("\tMotion_buffer is %ld\n", v->motion_buffer);
+
+          absolute = (v->mode == Absolute);
+
+          for (j=0; j<v->num_axes; j++, a++)
+            {
+              printf("\tAxis %d :\n", j);
+              printf("\t\tMin_value is %d\n", a->min_value);
+              printf("\t\tMax_value is %d\n", a->max_value);
+              printf ("\t\tResolution is %d\n", a->resolution);
+
+              axis.push_back(AxisInfo(a->min_value, a->max_value, 
a->resolution));
+            }
+
+          break;
+
+        default:
+          printf ("unknown class\n");
+      }
+      any = (XAnyClassPtr)((char*) any + any->length);
+    }
+  }
+}
+
+} // namespace Input
+
+/* EOF */


Property changes on: trunk/pingus/src/input/xinput_device.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/pingus/src/input/xinput_device.hpp
===================================================================
--- trunk/pingus/src/input/xinput_device.hpp    2007-09-03 03:44:09 UTC (rev 
3069)
+++ trunk/pingus/src/input/xinput_device.hpp    2007-09-03 17:17:58 UTC (rev 
3070)
@@ -0,0 +1,96 @@
+/*  $Id$
+**   __      __ __             ___        __   __ __   __
+**  /  \    /  \__| ____    __| _/_______/  |_|__|  | |  |   ____
+**  \   \/\/   /  |/    \  / __ |/  ___/\   __\  |  | |  | _/ __ \
+**   \        /|  |   |  \/ /_/ |\___ \  |  | |  |  |_|  |_\  ___/
+**    \__/\  / |__|___|  /\____ /____  > |__| |__|____/____/\___  >
+**         \/          \/      \/    \/                         \/
+**  Copyright (C) 2007 Ingo Ruhnke <address@hidden>
+**
+**  This program is free software; you can redistribute it and/or
+**  modify it under the terms of the GNU General Public License
+**  as published by the Free Software Foundation; either version 2
+**  of the License, or (at your option) any later version.
+**
+**  This program 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 General Public License for more details.
+** 
+**  You should have received a copy of the GNU General Public License
+**  along with this program; if not, write to the Free Software
+**  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+**  02111-1307, USA.
+*/
+
+#ifndef HEADER_INPUT_XINPUT_DEVICE_HPP
+#define HEADER_INPUT_XINPUT_DEVICE_HPP
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/XInput.h>
+#include <string>
+#include <vector>
+#include "math/vector2i.hpp"
+
+namespace Input {
+
+class XInputDriver;
+
+/** */
+class XInputDevice
+{
+private:
+  struct AxisInfo {
+    int min_value;
+    int max_value;
+    int resolution;
+    int pos;
+
+    AxisInfo(int min_value_, int max_value_, int resolution_)
+      : min_value(min_value_), max_value(max_value_), resolution(resolution_), 
pos(0)
+    {}
+  };
+
+private:
+  XInputDriver* owner;
+  std::string name;
+    
+  bool absolute;
+    
+  std::vector<bool> buttons;
+  std::vector<AxisInfo> axis;
+
+  int num_keys;        
+  
+  Vector2i mouse_pos;
+  Time time_at_last_press;
+  int  last_press_id;
+  
+  bool key_states[5];
+
+  int motion_type;
+  int button_press_type;
+  int button_release_type;
+  int key_press_type;
+  int key_release_type;
+  int proximity_in_type;
+  int proximity_out_type;
+
+public:
+  XInputDevice(XInputDriver* owner_, XDeviceInfo* info);
+  ~XInputDevice();
+
+  void get_info(XDeviceInfo* info);
+  void on_xevent(XEvent &event);
+  int  register_events(Display* dpy,
+                       XDeviceInfo* info,
+                       const char* dev_name,
+                       Bool handle_proximity);
+};
+
+} // namespace Input
+
+#endif
+
+/* EOF */


Property changes on: trunk/pingus/src/input/xinput_device.hpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/pingus/src/input/xinput_driver.cpp
===================================================================
--- trunk/pingus/src/input/xinput_driver.cpp    2007-09-03 03:44:09 UTC (rev 
3069)
+++ trunk/pingus/src/input/xinput_driver.cpp    2007-09-03 17:17:58 UTC (rev 
3070)
@@ -0,0 +1,153 @@
+/*  $Id$
+**   __      __ __             ___        __   __ __   __
+**  /  \    /  \__| ____    __| _/_______/  |_|__|  | |  |   ____
+**  \   \/\/   /  |/    \  / __ |/  ___/\   __\  |  | |  | _/ __ \
+**   \        /|  |   |  \/ /_/ |\___ \  |  | |  |  |_|  |_\  ___/
+**    \__/\  / |__|___|  /\____ /____  > |__| |__|____/____/\___  >
+**         \/          \/      \/    \/                         \/
+**  Copyright (C) 2007 Ingo Ruhnke <address@hidden>
+**
+**  This program is free software; you can redistribute it and/or
+**  modify it under the terms of the GNU General Public License
+**  as published by the Free Software Foundation; either version 2
+**  of the License, or (at your option) any later version.
+**
+**  This program 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 General Public License for more details.
+** 
+**  You should have received a copy of the GNU General Public License
+**  along with this program; if not, write to the Free Software
+**  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+**  02111-1307, USA.
+*/
+
+#include <iostream>
+
+#include "xinput_driver.hpp"
+#include "xinput_device.hpp"
+
+namespace Input {
+
+XInputDriver::XInputDriver()
+{
+  SDL_VERSION(&sys.version); // this is important!
+  if (!SDL_GetWMInfo(&sys))
+    std::cout << "Fatal Error: Couldn't get SDL_SysWMinfo" << std::endl;
+
+  setup_xinput();
+}
+
+XInputDriver::~XInputDriver()
+{
+}
+
+Bool
+XInputDriver::xinput_is_present()
+{
+  XExtensionVersion* version = XGetExtensionVersion(sys.info.x11.display, 
INAME);
+
+  if (version && (version != (XExtensionVersion*)NoSuchExtension)) 
+    {
+      Bool present = version->present;
+      XFree(version);
+      return present;
+    } 
+  else 
+    {
+      return False;
+    }
+}
+
+void
+XInputDriver::setup_xinput()
+{
+  if (!xinput_is_present())
+    {
+      std::cout << "debug: XInput extentsion not found" << std::endl;
+    }
+  else
+    {
+      int num_devices;
+      XDeviceInfo* info = XListInputDevices(sys.info.x11.display, 
&num_devices);
+      for(int loop = 0; loop < num_devices; ++loop) 
+        {
+        // FIXME: Xinput isn't necesarrily a mouse, could be anything
+        if (info[loop].use == IsXExtensionDevice)
+          devices.push_back(new XInputDevice(this, info + loop));
+
+        XFreeDeviceList(info);
+      }
+    }
+}
+
+void
+XInputDriver::update(float delta)
+{
+}
+
+XDeviceInfo*
+XInputDriver::find_device_info(Display *display,
+                               const char* name,
+                               Bool only_extended)
+{
+  // FIXME: Not really needed could simply pass XDeviceInfo to the
+  // constructor, might however make a nicer interface
+  XDeviceInfo *devices;
+  int  loop;
+  int  num_devices;
+  int  len = strlen(name);
+  Bool is_id = True;
+  XID  id = 0;
+
+  for(loop=0; loop<len; loop++) {
+    if (!isdigit(name[loop])) {
+      is_id = False;
+      break;
+    }
+  }
+
+  if (is_id) {
+    id = atoi(name);
+  }
+
+  devices = XListInputDevices(display, &num_devices);
+
+  for(loop=0; loop<num_devices; loop++) {
+    if ((!only_extended || (devices[loop].use == IsXExtensionDevice)) &&
+        ((!is_id && strcmp(devices[loop].name, name) == 0) ||
+         (is_id && devices[loop].id == id))) {
+      return &devices[loop];
+    }
+  }
+  return NULL;
+}
+
+Button*
+XInputDriver::create_button(const FileReader& reader, Control* parent)
+{
+  return 0;
+}
+
+Axis*
+XInputDriver::create_axis(const FileReader& reader, Control* parent)
+{
+  return 0;
+}
+
+Scroller*
+XInputDriver::create_scroller(const FileReader& reader, Control* parent)
+{
+  return 0;
+}
+
+Pointer*
+XInputDriver::create_pointer (const FileReader& reader, Control* parent)
+{
+  return 0;
+}
+
+} // namespace Input
+
+/* EOF */


Property changes on: trunk/pingus/src/input/xinput_driver.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/pingus/src/input/xinput_driver.hpp
===================================================================
--- trunk/pingus/src/input/xinput_driver.hpp    2007-09-03 03:44:09 UTC (rev 
3069)
+++ trunk/pingus/src/input/xinput_driver.hpp    2007-09-03 17:17:58 UTC (rev 
3070)
@@ -0,0 +1,75 @@
+/*  $Id$
+**   __      __ __             ___        __   __ __   __
+**  /  \    /  \__| ____    __| _/_______/  |_|__|  | |  |   ____
+**  \   \/\/   /  |/    \  / __ |/  ___/\   __\  |  | |  | _/ __ \
+**   \        /|  |   |  \/ /_/ |\___ \  |  | |  |  |_|  |_\  ___/
+**    \__/\  / |__|___|  /\____ /____  > |__| |__|____/____/\___  >
+**         \/          \/      \/    \/                         \/
+**  Copyright (C) 2007 Ingo Ruhnke <address@hidden>
+**
+**  This program is free software; you can redistribute it and/or
+**  modify it under the terms of the GNU General Public License
+**  as published by the Free Software Foundation; either version 2
+**  of the License, or (at your option) any later version.
+**
+**  This program 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 General Public License for more details.
+** 
+**  You should have received a copy of the GNU General Public License
+**  along with this program; if not, write to the Free Software
+**  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+**  02111-1307, USA.
+*/
+
+#ifndef HEADER_INPUT_XINPUT_DRIVER_HPP
+#define HEADER_INPUT_XINPUT_DRIVER_HPP
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/XInput.h>
+#include <vector>
+
+#include "SDL_syswm.h"
+#include "driver.hpp"
+
+namespace Input {
+
+class XInputDevice;
+
+/** */
+class XInputDriver : public Driver
+{
+private:
+  SDL_SysWMinfo sys;
+
+  void setup_xinput();
+  Bool xinput_is_present();
+
+  std::vector<XInputDevice*> devices;
+
+
+  XDeviceInfo* find_device_info(Display *display,
+                                const char* name,
+                                Bool only_extended);
+public:
+  XInputDriver();
+  ~XInputDriver();
+
+  SDL_SysWMinfo& get_syswminfo() { return sys; }
+ 
+  std::string get_name() const { return "xinput"; }
+  void update(float delta);
+
+  Button*   create_button  (const FileReader& reader, Control* parent);
+  Axis*     create_axis    (const FileReader& reader, Control* parent);
+  Scroller* create_scroller(const FileReader& reader, Control* parent);
+  Pointer*  create_pointer (const FileReader& reader, Control* parent);
+};
+
+} // namespace Input
+
+#endif
+
+/* EOF */


Property changes on: trunk/pingus/src/input/xinput_driver.hpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native





reply via email to

[Prev in Thread] Current Thread [Next in Thread]