MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
JoystickDR Struct Reference
Inheritance diagram for JoystickDR:
Collaboration diagram for JoystickDR:

Public Member Functions

virtual DriveRead (unsigned uLabel, const DataManager *pDM, MBDynParser &HP)
 
- Public Member Functions inherited from DriveRead
virtual ~DriveRead (void)
 

Detailed Description

Definition at line 365 of file module-hid.cc.

Member Function Documentation

Drive * JoystickDR::Read ( unsigned  uLabel,
const DataManager pDM,
MBDynParser HP 
)
virtual

Implements DriveRead.

Definition at line 371 of file module-hid.cc.

References IncludeParser::GetFileName(), HighParser::GetInt(), HighParser::GetReal(), HighParser::IsArg(), HighParser::IsKeyWord(), MBDYN_EXCEPT_ARGS, DataManager::pGetDrvHdl(), and v0.

372 {
373  if (HP.IsKeyWord("help")) {
374  silent_cout(
375 " \n"
376 "Module: joystick \n"
377 "Author: Pierangelo Masarati <pierangelo.masarati@polimi.it> \n"
378 "Organization: Dipartimento di Scienze e Tecnologie Aerospaziali \n"
379 " Politecnico di Milano \n"
380 " http://www.aero.polimi.it/ \n"
381 " \n"
382 " All rights reserved \n"
383 " \n"
384 " file: <label> , joystick , \n"
385 " <file> , \n"
386 " <number_of_buttons> , \n"
387 " <number_of_linear_controls> , \n"
388 " [ scale, <scale_factor> [ , ... ] ] ; \n"
389 " \n"
390 " <file> ::= \"/dev/input/js0\" \n"
391 " \n"
392 " <scale_factor>'s default to 1.0 \n"
393  << std::endl);
394 
395  if (!HP.IsArg()) {
396  /*
397  * Exit quietly if nothing else is provided
398  */
399  throw NoErr(MBDYN_EXCEPT_ARGS);
400  }
401  }
402 
403  const char *s = HP.GetFileName();
404  if (s == 0) {
405  // error
406  }
407  std::string sFileName(s);
408 
409  integer nButtons = HP.GetInt();
410  if (nButtons < 0) {
411  // error
412  }
413 
414  integer nLC = HP.GetInt();
415  if (nLC <= 0) {
416  // error
417  }
418 
419  std::vector<doublereal> lc_scale(nLC);
420  if (HP.IsKeyWord("scale")) {
421  for (integer idx = 0; idx < nLC; idx++) {
422  lc_scale[idx] = HP.GetReal();
423  }
424 
425  } else {
426  for (integer idx = 0; idx < nLC; idx++) {
427  lc_scale[idx] = 1.;
428  }
429  }
430 
431  const std::vector<doublereal> v0;
432 
433  return new JoystickDrive(uLabel, pDM->pGetDrvHdl(), sFileName, nButtons, lc_scale, v0);
434 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
virtual integer GetInt(integer iDefval=0)
Definition: parser.cc:1050
virtual const char * GetFileName(enum Delims Del=DEFAULTDELIM)
Definition: parsinc.cc:673
const DriveHandler * pGetDrvHdl(void) const
Definition: dataman.h:340
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
Definition: except.h:79
virtual bool IsArg(void)
Definition: parser.cc:807
static const std::vector< doublereal > v0
Definition: fixedstep.cc:45
long int integer
Definition: colamd.c:51
virtual doublereal GetReal(const doublereal &dDefval=0.0)
Definition: parser.cc:1056

Here is the call graph for this function:


The documentation for this struct was generated from the following file: