Index: trunk/tools/Controller/DualShock3/resources/core2-64/dualshock3.sh
===================================================================
--- trunk/tools/Controller/DualShock3/resources/core2-64/dualshock3.sh	(revision 465)
+++ trunk/tools/Controller/DualShock3/resources/core2-64/dualshock3.sh	(revision 467)
@@ -1,4 +1,3 @@
 #! /bin/bash
-#ARCH_DIR=$(uname -m)
 ARCH_DIR=core2-64
 #on kernel >=4.13, ds3 is seen as a mouse
@@ -6,18 +5,7 @@
 for id in `xinput --list|grep 'Sony PLAYSTATION(R)3 Controller'|perl -ne 'while (m/id=(\d+)/g){print "$1\n";}'`; do
     xinput set-prop $id 'Device Enabled' 0
-done 
-
-#This script is the only one that calls itself with sudo.
-#As a consequence, only one exception is needed in sudoers (the following 2 lines)
-#  Defaults!/opt/flair/flair-bin/tools/scripts/dualshock3.sh setenv
-#  uav ALL=(root) /opt/flair/flair-bin/tools/scripts/dualshock3.sh
-
-#we must run as root
-if [ $EUID -ne 0 ]; then
-  exec sudo -E $0 $*
-fi
+done
 
 . ${FLAIR_ROOT}/flair-src/scripts/ubuntu_cgroup_hack.sh
 
-export LD_LIBRARY_PATH="${OECORE_HOST_SYSROOT}/usr/lib:${OECORE_HOST_SYSROOT}/lib"
 ${FLAIR_ROOT}/flair-install/bin/tools/$ARCH_DIR/dualshock3 $*
Index: trunk/tools/Controller/DualShock3/src/DualShock3.cpp
===================================================================
--- trunk/tools/Controller/DualShock3/src/DualShock3.cpp	(revision 465)
+++ trunk/tools/Controller/DualShock3/src/DualShock3.cpp	(revision 467)
@@ -39,4 +39,5 @@
 #include <bluetooth/hci_lib.h>
 #include <sys/file.h>
+#include <linux/input.h>
 
 #define USB_DIR_IN 0x80
@@ -113,4 +114,5 @@
   dataSize = 6;
   datas = new int8_t[dataSize];
+  for(int i=0;i<dataSize;i++) datas[i]=0;
 
   GroupBox *settingsGroupBox =
@@ -148,5 +150,5 @@
       setup_device(dev);
     }
-  } else if (connectionType == Usb) {
+  } else if (connectionType == UsbHidRaw) {
     int nr, i;
     unsigned char buf[128];
@@ -180,5 +182,5 @@
     }
     if (i == 255) {
-      Thread::Err("sixad-raw::open(hidrawX) - failed to open hidraw device\n");
+      Thread::Err("open(hidrawX) - failed to open hidraw device\n");
       return;
     }
@@ -186,9 +188,50 @@
     // block until PS button is pressed
     if ((nr = read(usb_fd, buf, sizeof(buf))) < 0) {
-      Thread::Err("sixad-raw::read(fd) - failed to read from device\n");
+      Thread::Err("read(fd) - failed to read from device\n");
     }
 
     if (nr < 49 || nr > 50) {
-      Thread::Err("sixad-raw::read(fd) - not a sixaxis (nr = %i )\n", nr);
+      Thread::Err("read(fd) - not a sixaxis (nr = %i )\n", nr);
+    }
+  } else if (connectionType == UsbEvent) {
+    int nr, i;
+    unsigned char buf[128];
+
+    for (i = 0; i < 255; i++) {
+      ostringstream dev_name;
+      dev_name << "/dev/input/event" << i;
+      if ((usb_fd = open(dev_name.str().c_str(), O_RDONLY)) >= 0) {
+        int res=flock(usb_fd, LOCK_EX|LOCK_NB);
+        if(res<0) {
+          Thread::Warn("%s seems to be locked by another application\n", dev_name.str().c_str());
+          close(usb_fd);
+          continue;
+        }
+       
+        unsigned short id[4];
+        res = ioctl(usb_fd, EVIOCGID, id);
+        if (res < 0) {
+          Thread::Err("ioctl error (EVIOCGID) on %s\n",dev_name.str().c_str());
+        } else {
+          if (id[ID_VENDOR] == 0x054c && id[ID_PRODUCT] == 0x0268) {
+            Printf("successfully opened %s\n", dev_name.str().c_str());
+            Printf("Press PS button to turn the controller on\n");
+            break;
+          }
+        }
+        flock(usb_fd, LOCK_UN);
+        close(usb_fd);
+      }
+    }
+    if (i == 255) {
+      Thread::Err("open(/dev/input/eventX) - failed to open event device\n");
+      Thread::Err("you can try with the old usb_hidraw method\n");
+      return;
+    }
+    
+    // block until PS button is pressed
+    struct input_event tmp;
+    if ((nr = read(usb_fd, &tmp, sizeof(struct input_event))) < 0) {
+      Thread::Err("read(fd) - failed to read from device\n");
     }
   }
@@ -197,5 +240,5 @@
 
 DualShock3::~DualShock3() {
-  if (connectionType == Usb) {
+  if (connectionType == UsbHidRaw || connectionType == UsbEvent) {
     flock(usb_fd, LOCK_UN);
     close(usb_fd);
@@ -335,9 +378,63 @@
     return false;
 
-  } else if (connectionType == Usb) {
+  } else if (connectionType == UsbHidRaw) {
     int nr = read(usb_fd, report, sizeof(report));
     return parse_report_sixaxis_ds3(report, nr);
+  } else if (connectionType == UsbEvent) {
+    return parse_input_event();
   }
   return false;
+}
+
+uint8_t DualShock3::SetBitValue(int8_t &reg,uint8_t mask,uint8_t value) {
+  reg=(reg&~mask) | value*mask; 
+}
+
+bool DualShock3::parse_input_event(void) {
+  struct input_event ev[64];
+	int i, rd;
+
+  rd = read(usb_fd, ev, sizeof(struct input_event) * 64);
+
+  if (rd < (int) sizeof(struct input_event)) {
+    printf("expected %d bytes, got %d\n", (int) sizeof(struct input_event), rd);
+    return false;
+  }
+
+  for (i = 0; i < rd / sizeof(struct input_event); i++) {
+    if (ev[i].type == EV_ABS) {
+      //code 2 and 5 are z/rz (l2 and r2)
+      if(ev[i].code==0) datas[2] = compute_dead_zone(0, ev[i].value);//x
+      if(ev[i].code==1) datas[3] = compute_dead_zone(1, ev[i].value);//y
+      if(ev[i].code==3) datas[4] = compute_dead_zone(2, ev[i].value);//rx
+      if(ev[i].code==4) datas[5] = compute_dead_zone(3, ev[i].value);//ry
+    }
+    if (ev[i].type == EV_KEY) {
+      if(ev[i].code==BTN_START) SetBitValue(datas[0],0x08,ev[i].value);
+      if(ev[i].code==BTN_SELECT) SetBitValue(datas[0],0x01,ev[i].value);
+      if(ev[i].code==BTN_WEST) SetBitValue(datas[1],0x80,ev[i].value);// square
+      if(ev[i].code==BTN_NORTH) SetBitValue(datas[1],0x10,ev[i].value);// triangle
+      if(ev[i].code==BTN_EAST) SetBitValue(datas[1],0x20,ev[i].value);// circle
+      if(ev[i].code==BTN_SOUTH) SetBitValue(datas[1],0x40,ev[i].value);// cross
+      if(ev[i].code==BTN_TL) SetBitValue(datas[1],0x04,ev[i].value);
+      if(ev[i].code==BTN_TL2) SetBitValue(datas[1],0x01,ev[i].value);
+      if(ev[i].code==BTN_THUMBL) SetBitValue(datas[0],0x02,ev[i].value);
+      if(ev[i].code==BTN_TR) SetBitValue(datas[1],0x08,ev[i].value);
+      if(ev[i].code==BTN_TR2) SetBitValue(datas[1],0x02,ev[i].value);
+      if(ev[i].code==BTN_THUMBR) SetBitValue(datas[0],0x04,ev[i].value);
+      if(ev[i].code==BTN_DPAD_UP) SetBitValue(datas[0],0x10,ev[i].value);
+      if(ev[i].code==BTN_DPAD_DOWN) SetBitValue(datas[0],0x40,ev[i].value);
+      if(ev[i].code==BTN_DPAD_LEFT) SetBitValue(datas[0],0x80,ev[i].value);
+      if(ev[i].code==BTN_DPAD_RIGHT) SetBitValue(datas[0],0x20,ev[i].value);
+    }
+  
+    if (GetTime() > (last_voltage_time + 5 * (Time)1000000000)) {
+      // toute les 5 secondes
+      // report battery charge level
+      batteryChargeLevel->SetText("battery: usb connected");
+      last_voltage_time = GetTime();
+    }
+  }
+  return true;
 }
 
@@ -357,5 +454,5 @@
         batteryChargeLevel->SetText("battery: %i/5", r[30]);
       }
-      if (connectionType == Usb) {
+      if (connectionType == UsbHidRaw) {
         batteryChargeLevel->SetText("battery: usb connected");
       }
@@ -388,18 +485,6 @@
 
 void DualShock3::GetButtonData() {
-  // static uint8_t old_start_button=0;
   button->GetMutex();
   button->SetValueNoMutex(0, 0, (datas[0] & 0x08) == 0 ? 0 : 1); // start
-  /*
-      uint8_t start_button=datas[0]&0x08;
-      if (start_button!=old_start_button) {
-          if (start_button==0) {
-              Thread::Info("Debug: start button released\n");
-          } else {
-              Thread::Info("Debug: start button pressed\n");
-          }
-          old_start_button=start_button;
-      }
-  */
   button->SetValueNoMutex(1, 0, (datas[0] & 0x01) == 0 ? 0 : 1); // select
   button->SetValueNoMutex(2, 0, (datas[1] & 0x80) == 0 ? 0 : 1); // square
Index: trunk/tools/Controller/DualShock3/src/DualShock3.h
===================================================================
--- trunk/tools/Controller/DualShock3/src/DualShock3.h	(revision 465)
+++ trunk/tools/Controller/DualShock3/src/DualShock3.h	(revision 467)
@@ -50,5 +50,5 @@
 class DualShock3 : public HostEthController {
 public:
-  typedef enum { Usb, Bluetooth } ConnectionType_t;
+  typedef enum { UsbHidRaw, UsbEvent,Bluetooth } ConnectionType_t;
 
   DualShock3(std::string name,
@@ -79,7 +79,9 @@
   void setup_device(struct motion_dev *dev);
   bool parse_report_sixaxis_ds3(unsigned char *r, int len);
+  bool parse_input_event(void);
   int mystr2ba(const char *s, bdaddr_t *ba);
   char *myba2str(const bdaddr_t *ba);
   int8_t compute_dead_zone(int axis, unsigned char value);
+  uint8_t SetBitValue(int8_t &reg,uint8_t mask,uint8_t value);
   struct motion_dev *dev;
   int usb_fd;
Index: trunk/tools/Controller/DualShock3/src/main.cpp
===================================================================
--- trunk/tools/Controller/DualShock3/src/main.cpp	(revision 465)
+++ trunk/tools/Controller/DualShock3/src/main.cpp	(revision 467)
@@ -47,8 +47,15 @@
   if (connection == "usb") {
     joystick = new DualShock3("dualshock3", receiverAddress,
-                              receiverPort, DualShock3::Usb, period, 6);
-  } else {
+                              receiverPort, DualShock3::UsbEvent, period, 6);
+  } else if (connection == "usb_hidraw") {
+    joystick = new DualShock3("dualshock3", receiverAddress,
+                              receiverPort, DualShock3::UsbHidRaw, period, 6);
+  } else if (connection == "bluetooth") {
     joystick = new DualShock3("dualshock3", receiverAddress,
                               receiverPort, DualShock3::Bluetooth, period, 6);
+  } else {
+    manager->Err("unknown connection type\n");
+    delete manager;
+    return -1;
   }
 
@@ -73,5 +80,5 @@
 
     ValueArg<string> connectionArg("c", "connection",
-                                   "connection type (usb or bluetooth)", false,
+                                   "connection type (usb, usb_hidraw or bluetooth)", false,
                                    "bluetooth", "string");
     cmd.add(connectionArg);
Index: trunk/tools/FlairGCS/resources/core2-64/launch_flairgcs.sh
===================================================================
--- trunk/tools/FlairGCS/resources/core2-64/launch_flairgcs.sh	(revision 465)
+++ trunk/tools/FlairGCS/resources/core2-64/launch_flairgcs.sh	(revision 467)
@@ -25,5 +25,4 @@
 [ "$1" = "--" ] && usage 
 
-#export LD_LIBRARY_PATH="${OECORE_HOST_SYSROOT}/usr/lib:${OECORE_HOST_SYSROOT}/lib"
 export FONTCONFIG_PATH=${OECORE_HOST_SYSROOT}/etc/fonts/ 
 export FONTCONFIG_FILE=${OECORE_HOST_SYSROOT}/etc/fonts/fonts.conf 
Index: trunk/tools/VrpnLite/resources/core2-64/vrpnlite.sh
===================================================================
--- trunk/tools/VrpnLite/resources/core2-64/vrpnlite.sh	(revision 465)
+++ trunk/tools/VrpnLite/resources/core2-64/vrpnlite.sh	(revision 467)
@@ -1,19 +1,7 @@
 #! /bin/bash
-#ARCH_DIR=$(uname -m)
 ARCH_DIR=core2-64
-
-#This script is the only one that calls itself with sudo.
-#As a consequence, only one exception is needed in sudoers (the following 2 lines)
-#  Defaults!/opt/flair/flair-bin/tools/scripts/dualshock3.sh setenv
-#  uav ALL=(root) /opt/flair/flair-bin/tools/scripts/dualshock3.sh
-
-#we must run as root
-if [ $EUID -ne 0 ]; then
-  exec sudo -E $0 $*
-fi
 
 . ${FLAIR_ROOT}/flair-src/scripts/ubuntu_cgroup_hack.sh
 
-export LD_LIBRARY_PATH="${OECORE_HOST_SYSROOT}/usr/lib:${OECORE_HOST_SYSROOT}/lib"
 ${FLAIR_ROOT}/flair-install/bin/tools/$ARCH_DIR/vrpnlite -p 9000 -x vrpnlite.xml -s 172.26.213.1:3883 -v 3884
 
