Skip to content
Snippets Groups Projects
Select Git revision
  • 298d74b3c28a96c6c074008e97a5db10fffd7604
  • master default
  • cgnsUnstructured
  • partitioning
  • poppler
  • HighOrderBLCurving
  • gmsh_3_0_4
  • gmsh_3_0_3
  • gmsh_3_0_2
  • gmsh_3_0_1
  • gmsh_3_0_0
  • gmsh_2_16_0
  • gmsh_2_15_0
  • gmsh_2_14_1
  • gmsh_2_14_0
  • gmsh_2_13_2
  • gmsh_2_13_1
  • gmsh_2_12_0
  • gmsh_2_11_0
  • gmsh_2_10_1
  • gmsh_2_10_0
  • gmsh_2_9_3
  • gmsh_2_9_2
  • gmsh_2_9_1
  • gmsh_2_9_0
  • gmsh_2_8_6
26 results

graphicWindow.cpp

Blame
  • Forked from gmsh / gmsh
    Source project has a limited visibility.
    GamePad.cpp 7.59 KiB
    // Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle
    //
    // See the LICENSE.txt file for license information. Please report all
    // bugs and problems to the public mailing list <gmsh@geuz.org>.
    //
    // Contributed by Gilles Marckmann <gilles.marckmann@ec-nantes.fr>
    
    
    #if defined(WIN32) || defined(__APPLE__)
    
    
       #include <cstring>
       #include <string>
       #include <iostream>
       #include <stdio.h>
       #include "GamePad.h"
    
       GamePad::GamePad() : active(false), frequency(.01), gamepad_fd(0) {
         for (int i=0;i<9;i++) button_map[i]=i;
         for (int i=0;i<7;i++)    axe_map[i]=i;
         axe_map[6]=1;
         //  other recognized map "Thrustmaster Run'N' Drive Wireless PS3"
         if ( strcmp(name,"Thrustmaster Run'N' Drive Wireless PS3" ) == 0){
           button_map[0]=1;
           button_map[1]=0;
           button_map[5]=6;
           button_map[6]=5;
         }
       }
    
       GamePad::~GamePad() {  gamepad_fd = 0;}
    
       bool GamePad::toggle(const int _nbut) {
         bool res;
         if( toggle_status[_nbut] ){ res = true; toggle_status[_nbut]=false;}
         else { res=false;  }
         return res;
       }
    
       int GamePad::read_event() {  return 1;}
    
       void GamePad::affiche() {}
    
    
    
    
    #else // if !win32 => if linux/apple
    
       #include <cstring>
       #include <string>
       #include <iostream>
       #include <stdio.h>
       #include "GamePad.h"
       #include "Context.h"
       #include <unistd.h>
    
       GamePad::GamePad() : active(false), frequency(.01), gamepad_fd(0) {
         gamepad_fd = open(GAMEPAD_DEV, O_RDONLY | O_NONBLOCK);
         if (gamepad_fd > 0) {
           ioctl(gamepad_fd, JSIOCGNAME(256), name);
           ioctl(gamepad_fd, JSIOCGVERSION, &version);
           ioctl(gamepad_fd, JSIOCGAXES, &axes);
           ioctl(gamepad_fd, JSIOCGBUTTONS, &buttons);
           std::cout << "Joystick/Gamepad detected: " <<  name ;
           std::cout << " (version " << version  << " / " ;
           std::cout << (int)axes <<" axes /" ;
           std::cout << (int)buttons <<" buttons)" << std::endl;
           active = true;
         }