void Block(char *exit_label)
{
	while ( (Look != 'e') && (Look !='l') && (Look !='u') ) {
		Fin();
		printf("# BLOCK start\n");
		switch (Look) {
		case 'i':
			DoIf(exit_label);
			break;
		case 'w':
			DoWhile();
			break;
		case 'p':
			DoLoop();
			break;
		case 'r':
			DoRepeat();
			break;
		case 'f':
			DoFor();
			break;
		case 'd':
			DoDo();
			break;
		case 'b':
			DoBreak(exit_label);
			break;
		default:
			Assignment();
			break;
		}
		Fin();
		printf("# BLOCK end\n");
	}
}
示例#2
0
/* parse and translate a Begin-Block */
void BeginBlock()
{
    Match('b');
    Fin();
    DoBlock();
    Match('e');
    Fin();
}
示例#3
0
void Block()
{
    while(Look != '.') {
        Assignment();
        Fin();
    }
}
示例#4
0
void Block(char *L)
{
    while (! strchr("elu", Look)) {
        dprint("Block: get Look = %c\n", Look);
        switch (Look) {
            case 'i':
                DoIf(L);
                break;
            case 'w':
                DoWhile();
                break;
            case 'p':
                DoLoop();
                break;
            case 'r':
                DoRepeat();
                break;
            case 'f':
                DoFor();
                break;
            case 'd':
                DoDo();
                break;
            case 'b':
                DoBreak(L);
            default:
                Assignment();
                break;
        }
        /* this is for convinent, otherwise newline character will
        cause an error */
        /*Newline();*/
        Fin();
    }
}
示例#5
0
/* parse and translate a block of statement */
void DoBlock()
{
    while(strchr("e", Look) == NULL) {
        Assignment();
        Fin();
    }
}
示例#6
0
int hw_getReg(const int REG){
	Fin();
	if (REG<0 || REG>8) {
		Ftr("No such reg:%d", (unsigned int)REG);
		return -1;
	}
	Fout("reg:%d has %X", REG, mHW.reg[REG]);
	return mHW.reg[REG];
}
示例#7
0
int main(int argc, char *argv[])
{
    Init();
    TopDecls();
    Match('B');
    Fin();
    Block();
    DumpTable();
    return 0;
}
示例#8
0
int hw_sendData(
		const int  REG,
		const unsigned char data_) {
	unsigned long int_flags;

	struct timeval tv1,tv2;
	unsigned char data = data_;

	Fin();
	if (REG<0 || REG>8) {
		Ftr();
		return -1;
	}

	Ftr(" echo %d > %d", data, REG);


	if (REG == 0) {
		// 1110 0111
		data &= 0xe7;
		// To disable unstable flags, vendor suggests it.
	}

	do_gettimeofday(&tv1);
	spin_lock_irqsave(&my_lock, int_flags);
	mHW.reg[REG] = data;

	gpio_set_value(mHW.CTRL, 1);
	udelay(20); // TDS: data start. typical 10 us
	// fill the address.
	if (REG&0x08) SEND_HIGH(); else SEND_LOW();
	if (REG&0x04) SEND_HIGH(); else SEND_LOW();
	if (REG&0x02) SEND_HIGH(); else SEND_LOW();
	if (REG&0x01) SEND_HIGH(); else SEND_LOW();
	// fill the data.
	if (data&0x80) SEND_HIGH(); else SEND_LOW();
	if (data&0x40) SEND_HIGH(); else SEND_LOW();
	if (data&0x20) SEND_HIGH(); else SEND_LOW();
	if (data&0x10) SEND_HIGH(); else SEND_LOW();
    if (data&0x08) SEND_HIGH(); else SEND_LOW();
    if (data&0x04) SEND_HIGH(); else SEND_LOW();
    if (data&0x02) SEND_HIGH(); else SEND_LOW();
    if (data&0x01) SEND_HIGH(); else SEND_LOW();
	// fill EOD
	gpio_set_value(mHW.CTRL,0);
	udelay(8); //typical val: 2 us
	gpio_set_value(mHW.CTRL,1);
	udelay(400); //typical val: 350 us
	spin_unlock_irqrestore(&my_lock, int_flags);
	do_gettimeofday(&tv2);
	
	Fout("at %d, tv: (%d)us", REG, tv2.tv_usec - tv1.tv_usec);
	return 1;
}
示例#9
0
void Scan()
{ 
    /* in Unix/Linux, Endline is CR instead of LF CR in MSDOS*/
    SkipWhite();   
    while(Look == '\n') {
        Fin();
    }

    GetName();
    int index = Lookup(KWList, Value, KWNum);
    Token = KWCode[index+1];
}
示例#10
0
void Block() {
  while(Look != 'e' && Look !='l' && Look != 'u') {
    Fin();
    switch(Look) {
      case 'i': DoIf(); break;
      case 'w': DoWhile(); break;
      case 'p': DoLoop(); break;
      case 'r': DoRepeat(); break;
      case 'f': DoFor(); break;
      default : Assignment(); break;
    }
  }
}
示例#11
0
/* Init the rgb chip.
Actually, I do not need any lock her!
Because there are only least delay time, no delay limitation.
*/
int hw_requestGPIO(const rgb_chip_layout *layout) {
	int res = 0;
	Fin("CTRL:%d", layout->gpio_CTRL);
	mHW.CTRL = layout->gpio_CTRL;
	memset(mHW.reg,0, sizeof(mHW.reg));

    res = gpio_request(mHW.CTRL, "rgb_ctrl");
    if (res<0) {
        Fout("Error 4");
        return -1;
    }

	Fout("Success");
	return 1;
}
示例#12
0
文件: abdruck.cpp 项目: logtcn/cgal
int main(int argc, char* argv[]) {

    CGAL_assertion(argc==2);

    Nef_polyhedron N,F;

    std::ifstream Fin("centered_cube.nef3");
    Fin >> F;

    std::ifstream Nin(argv[1]);
    Nin >> N;

    transform_form(N,F);

    cgal_nef3_timer_on = true;
    F.difference(N);
};
示例#13
0
inline void igl::PlanarizerShapeUp<DerivedV, DerivedF>::assembleSelector(int fi,
                                                                            Eigen::SparseMatrix<typename DerivedV::Scalar > &S)
{
  
  std::vector<Eigen::Triplet<typename DerivedV::Scalar>> tripletList;
  for (int fvi = 0; fvi< ni; fvi++)
  {
    int vi = Fin(fi,fvi);
    tripletList.push_back(Eigen::Triplet<typename DerivedV::Scalar>(3*fvi+0,3*vi+0,1.));
    tripletList.push_back(Eigen::Triplet<typename DerivedV::Scalar>(3*fvi+1,3*vi+1,1.));
    tripletList.push_back(Eigen::Triplet<typename DerivedV::Scalar>(3*fvi+2,3*vi+2,1.));
  }
  
  S.resize(3*ni,3*numV);
  S.setFromTriplets(tripletList.begin(), tripletList.end());
  
}
示例#14
0
void GetName()
{
    SkipWhite();   
    while(Look == '\n') {
        Fin();
    }

    char *p = Value;
    if (!IsAlpha(Look)) {
        Expected("Name");
    }

    while(IsAlNum(Look)) {
        *p++ = uppercase(Look);
        GetChar();
    }
    *p = '\0';
}
示例#15
0
/* parse and translate global declarations */
void TopDecls(void)
{
    printf(".section .data\n");
    char tmp_buf[MAX_BUF];
    while(Look != 'B') {
        switch(Look) {
            case 'b':
            case 'w':
            case 'l':
                Decl();
                break;
            default:
                sprintf(tmp_buf, "Unrecognized keyword %c", Look);
                Abort(tmp_buf);
                break;
        }
        Fin();
    }
}
void CClassifyGrid::Classify()
{
	CParamManager * manager = CParamManager::GetParamManager();
	CTimeMeter timer;
	timer.Start();

	fprintf_s( stderr, "==================== Classify points ====================\n" );

	Init();

	fprintf_s( stderr, "Initialize ... finished.\n" );

	fprintf_s( stderr, "Processing progress ... " );
	InitPrintProgress();

	int index;
	while ( ( index = ReadNextChunk() ) != -1 ) {

		PrintProgress(  );

		CClassifyChunk * chunk = m_vecPointer[ index ];
		chunk->BuildGridIndex();

		// check neighborhood of index chunk
		m_vecState[ chunk->m_iIndex ] = CClassifyChunk::CCS_Read;
		NotifyCCSRead( chunk->m_iX, chunk->m_iY );

		if ( manager->m_bDebugPrintOut ) {
			PrintGridState( manager->m_pDebugPrintOutFile );
		}

	}

	fprintf_s( stderr, " ... done!\n" );

	Fin();

	timer.End();
	timer.Print();

	fprintf_s( stderr, ".\n" );
}
void ThreadServeur::run()
{
    QByteArray baReception;
    while(m_etat)
    {
        baReception.clear();
             sockClient->waitForReadyRead(-1); // Attente des données pendant 0.1 sec maximum
             baReception.append(sockClient->read(sockClient->bytesAvailable())); // Lecture des donnée

             if(QString(baReception.left(4)) == QString("Env#"))
             {
                 emit(Envoie(sockClient,QString(baReception.right(baReception.length()))));
             }
             if(QString(baReception.left(4)) == QString("Fin#"))
             {
                 m_etat = false;
                emit(Fin(sockClient));
             }
    }
}
示例#18
0
void Block()
{
    Scan();
    while (! strchr("el", Token)) {
        dprint("Block: get Look = %c\n", Look);
        switch (Token) {
            case 'i':
                DoIf();
                break;
            case '\n':
                while(Look == '\n') {
                    Fin();
                }
                break;
            default:
                Assignment();
                break;
        }
        Scan();
    }
}
示例#19
0
void CHC_Mirror::Load() {
	ifstream Fin(MirrorModelPath);
	CHC_Mirror::ViewList = glGenLists(1);
	
	Fin >> TextureIndex;

	glNewList(ViewList, GL_COMPILE);
		glBegin(GL_TRIANGLES);
			int n3; 
			Fin >> n3;
			while (n3 --) {
				float x, y, z;
				Fin >> x >> y >> z;
				glColor4f(x, y, z, 1.0);
				for (int i = 0; i < 3; i++) {
					Fin >> x >> y;
					glTexCoord2f(x, y);
					Fin >> x >> y >> z;
					glVertex3f(x, y, z);
				}
			}
		glEnd();
		glBegin(GL_QUADS);
			int n4;
			Fin >> n4;
			while (n4 --) {
				float x, y, z;
				Fin >> x >> y >> z;
				glColor4f(x, y, z, 1.0);
				for (int i = 0; i < 4; i++) {
					Fin >> x >> y;
					glTexCoord2f(x, y);
					Fin >> x >> y >> z;
					glVertex3f(x, y, z);
				}
			}
		glEnd();
	glEndList();
}
示例#20
0
CAffichage::CAffichage ()
{
	m_pInstance = 0;
	m_iFpsCompte = 0;
	m_iFpsNiveau = 0;
	m_iFps = 0;
	m_FpsTimer.Init ();

	// On récupère la liste des extensions supportés par les drivers de la carte graphique.
    char* szExtList = (char*) glGetString (GL_EXTENSIONS);

	// Pour ce jeu, nous utilisons l'extension GL_ARB_point_sprite.
	// Pour nous assurer qu'elle est supporté nous vérifions que la chaîne "GL_ARB_point_sprite"
	// est présente dans la chaîne récupérée avec glGetString (GL_EXTENSIONS)
    if (!strstr (szExtList, "GL_ARB_point_sprite"))
	{
		// L'extension GL_ARB_point_sprite n'est pas supporté 
		m_bPointSprite = false;
		fprintf (stderr, "L'extension OpenGL 'GL_ARB_point_sprite', n'est pas supporté ...\n");
		fprintf (stderr, "Veuillez installer les derniers pilotes de votre carte graphique.\n");
	}
	else
	{
		// L'extension GL_ARB_point_sprite est supporté 
		m_bPointSprite = true;
	}

	// Couleur utiliser quand le tampon chromatique est vidé
	glClearColor (0.0f, 0.0f, 0.1f, 0.0f);
	glShadeModel (GL_FLAT);

	Debut ();
	Fin ();

	// Charge la texture utilisé pour l'affichage des caractères
	m_Font.ChargerTexture(DIRECTORY + FICHIER_TEXTURE_FONT);
}
示例#21
0
void ASSISTANT::Fermer()
{
    if(liste)
    {
        if(page(lect)->terminer)
        {
            int k = 1;
            while(res->size())
            {res->pop_back();}
            for(int i=1; i<=liste->nb();i++)
            {
                for(int j=1; j<=page(i)->nbResult;j++)
                {
                    res->push_back(page(i)->resultat(j));
                    k++;
                }
            }
            emit Fin();
        }

       page(lect)->close();
    }
    delete this;
}
示例#22
0
int hw_wakeup(void) {
	unsigned long int_flags;
    struct timeval tv1,tv2;
	//long artv[3];
	Fin();
	do_gettimeofday(&tv1);

    spin_lock_irqsave(&my_lock, int_flags);
	
	udelay(200);
	gpio_set_value(mHW.CTRL, 1);
	udelay(100);
	
    gpio_set_value(mHW.CTRL, 0); //min: 10 us
	udelay(15);

    gpio_set_value(mHW.CTRL, 1); //min: 400 us, max:600 us
	udelay(450);

	spin_unlock_irqrestore(&my_lock, int_flags);
	do_gettimeofday(&tv2);
	Fout("tv:%d", tv2.tv_usec - tv1.tv_usec);
	return 0;
}
示例#23
0
void Aprendizagem_Reforco::loadMatrixH( int playerNum )
{
	char fileNumber[2]; // player number
	char dir[] = "matrizes/MatrizHXX.csv"; // better not change this

	switch( playerNum ){
	case 0:
		fileNumber[0] = '0';
		fileNumber[1] = '0';
		break;
	case 1:
		fileNumber[0] = '0';
		fileNumber[1] = '1';
		break;
	case 2:
		fileNumber[0] = '0';
		fileNumber[1] = '2';
		break;
	case 3:
		fileNumber[0] = '0';
		fileNumber[1] = '3';
		break;
	case 4:
		fileNumber[0] = '0';
		fileNumber[1] = '4';
		break;
	case 5:
		fileNumber[0] = '0';
		fileNumber[1] = '5';
		break;
	case 6:
		fileNumber[0] = '0';
		fileNumber[1] = '6';
		break;
	case 7:
		fileNumber[0] = '0';
		fileNumber[1] = '7';
		break;
	case 8:
		fileNumber[0] = '0';
		fileNumber[1] = '8';
		break;
	case 9:
		fileNumber[0] = '0';
		fileNumber[1] = '9';
		break;
	case 10:
		fileNumber[0] = '1';
		fileNumber[1] = '0';
		break;
	case 11:
		fileNumber[0] = '1';
		fileNumber[1] = '1';
		break;
	case 12:
		fileNumber[0] = '1';
		fileNumber[1] = '2';
		break;
	}

	dir[16] = fileNumber[0];
	dir[17] = fileNumber[1];

	ifstream Fin( dir, ios::in );
	if (!Fin) // "Tried to read but failed, recreating/overwriting file"
	{
		ofstream Fout( dir, ios::out );
		if (!Fout) // Couldn't open for writing! path doesn't exist ? (check dir)
		{
			cerr << "ERROR while creating MatrizH for player " << playerNum << "\n";
			for( int i=0; i<num_linesQ; i++ )
			{
				for( int j=0; j<num_acoes; j++ )
					MatrizH[i][j] = 0.0; // passing values to array MatrizH
			}
		}
		else // File successfully opened for writing
		{
			for( int i=0; i<num_linesQ; i++ )
			{
				for( int j=0; j<num_acoes; j++ )
				{
					Fout << "0 ";
					MatrizH[i][j] = 0.0; // passing values to array MatrizH
				}
				Fout << "\n";
			}
			cerr << "Successfully created Matrix for player " << playerNum << "\n";
		}
		Fout.close();
	}
	else // "Successful in reading, pass values to array MatrizH"
	{
		for( int i=0; i<num_linesQ; i++ )
		{
			for( int j=0; j<num_acoes; j++ )
			{
				Fin >> MatrizH[i][j];
			}
		}
		cerr << "Successfully read Matrix for player " << playerNum << "\n";
	}
	Fin.close();
}
示例#24
0
void test()
{
  // This function tests C++0x 5.16

  // p1 (contextually convert to bool)
  int i1 = ToBool() ? 0 : 1;

  // p2 (one or both void, and throwing)
  i1 ? throw 0 : throw 1;
  i1 ? test() : throw 1;
  i1 ? throw 0 : test();
  i1 ? test() : test();
  i1 = i1 ? throw 0 : 0;
  i1 = i1 ? 0 : throw 0;
  i1 ? 0 : test(); // expected-error {{right operand to ? is void, but left operand is of type 'int'}}
  i1 ? test() : 0; // expected-error {{left operand to ? is void, but right operand is of type 'int'}}
  (i1 ? throw 0 : i1) = 0; // expected-error {{expression is not assignable}}
  (i1 ? i1 : throw 0) = 0; // expected-error {{expression is not assignable}}

  // p3 (one or both class type, convert to each other)
  // b1 (lvalues)
  Base base;
  Derived derived;
  Convertible conv;
  Base &bar1 = i1 ? base : derived;
  Base &bar2 = i1 ? derived : base;
  Base &bar3 = i1 ? base : conv;
  Base &bar4 = i1 ? conv : base;
  // these are ambiguous
  BadBase bb;
  BadDerived bd;
  (void)(i1 ? bb : bd); // expected-error {{conditional expression is ambiguous; 'BadBase' can be converted to 'BadDerived' and vice versa}}
  (void)(i1 ? bd : bb); // expected-error {{conditional expression is ambiguous}}
  // curiously enough (and a defect?), these are not
  // for rvalues, hierarchy takes precedence over other conversions
  (void)(i1 ? BadBase() : BadDerived());
  (void)(i1 ? BadDerived() : BadBase());

  // b2.1 (hierarchy stuff)
  extern const Base constret();
  extern const Derived constder();
  // should use const overload
  A a1((i1 ? constret() : Base()).trick());
  A a2((i1 ? Base() : constret()).trick());
  A a3((i1 ? constret() : Derived()).trick());
  A a4((i1 ? Derived() : constret()).trick());
  // should use non-const overload
  i1 = (i1 ? Base() : Base()).trick();
  i1 = (i1 ? Base() : Base()).trick();
  i1 = (i1 ? Base() : Derived()).trick();
  i1 = (i1 ? Derived() : Base()).trick();
  // should fail: const lost
  (void)(i1 ? Base() : constder()); // expected-error {{incompatible operand types ('Base' and 'const Derived')}}
  (void)(i1 ? constder() : Base()); // expected-error {{incompatible operand types ('const Derived' and 'Base')}}

  Priv priv;
  Fin fin;
  (void)(i1 ? Base() : Priv()); // expected-error{{private base class}}
  (void)(i1 ? Priv() : Base()); // expected-error{{private base class}}
  (void)(i1 ? Base() : Fin()); // expected-error{{ambiguous conversion from derived class 'Fin' to base class 'Base':}}
  (void)(i1 ? Fin() : Base()); // expected-error{{ambiguous conversion from derived class 'Fin' to base class 'Base':}}
  (void)(i1 ? base : priv); // expected-error {{private base class}}
  (void)(i1 ? priv : base); // expected-error {{private base class}}
  (void)(i1 ? base : fin); // expected-error {{ambiguous conversion from derived class 'Fin' to base class 'Base':}}
  (void)(i1 ? fin : base); // expected-error {{ambiguous conversion from derived class 'Fin' to base class 'Base':}}

  // b2.2 (non-hierarchy)
  i1 = i1 ? I() : i1;
  i1 = i1 ? i1 : I();
  I i2(i1 ? I() : J());
  I i3(i1 ? J() : I());
  // "the type [it] woud have if E2 were converted to an rvalue"
  vfn pfn = i1 ? F() : test;
  pfn = i1 ? test : F();
  (void)(i1 ? A() : B()); // expected-error {{conversion from 'B' to 'A' is ambiguous}}
  (void)(i1 ? B() : A()); // expected-error {{conversion from 'B' to 'A' is ambiguous}}
  (void)(i1 ? 1 : Ambig()); // expected-error {{conversion from 'Ambig' to 'int' is ambiguous}}
  (void)(i1 ? Ambig() : 1); // expected-error {{conversion from 'Ambig' to 'int' is ambiguous}}
  // By the way, this isn't an lvalue:
  &(i1 ? i1 : i2); // expected-error {{address expression must be an lvalue or a function designator}}

  // p4 (lvalue, same type)
  Fields flds;
  int &ir1 = i1 ? flds.i1 : flds.i2;
  (i1 ? flds.b1 : flds.i2) = 0;
  (i1 ? flds.i1 : flds.b2) = 0;
  (i1 ? flds.b1 : flds.b2) = 0;

  // p5 (conversion to built-in types)
  // GCC 4.3 fails these
  double d1 = i1 ? I() : K();
  pfn = i1 ? F() : G();
  DFnPtr pfm;
  pfm = i1 ? DFnPtr() : &Base::fn1;
  pfm = i1 ? &Base::fn1 : DFnPtr();

  // p6 (final conversions)
  i1 = i1 ? i1 : ir1;
  int *pi1 = i1 ? &i1 : 0;
  pi1 = i1 ? 0 : &i1;
  i1 = i1 ? i1 : EVal;
  i1 = i1 ? EVal : i1;
  d1 = i1 ? 'c' : 4.0;
  d1 = i1 ? 4.0 : 'c';
  Base *pb = i1 ? (Base*)0 : (Derived*)0;
  pb = i1 ? (Derived*)0 : (Base*)0;
  pfm = i1 ? &Base::fn1 : &Derived::fn2;
  pfm = i1 ? &Derived::fn2 : &Base::fn1;
  pfm = i1 ? &Derived::fn2 : 0;
  pfm = i1 ? 0 : &Derived::fn2;
  const int (MixedFieldsDerived::*mp1) =
    i1 ? &MixedFields::ci : &MixedFieldsDerived::i;
  const volatile int (MixedFields::*mp2) =
    i1 ? &MixedFields::ci : &MixedFields::cvi;
  (void)(i1 ? &MixedFields::ci : &MixedFields::vi);
  // Conversion of primitives does not result in an lvalue.
  &(i1 ? i1 : d1); // expected-error {{address expression must be an lvalue or a function designator}}

  (void)&(i1 ? flds.b1 : flds.i1); // expected-error {{address of bit-field requested}}
  (void)&(i1 ? flds.i1 : flds.b1); // expected-error {{address of bit-field requested}}
  

  unsigned long test0 = 5;
  test0 = test0 ? (long) test0 : test0; // expected-warning {{operand of ? changes signedness: 'long' to 'unsigned long'}}
  test0 = test0 ? (int) test0 : test0; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
  test0 = test0 ? (short) test0 : test0; // expected-warning {{operand of ? changes signedness: 'short' to 'unsigned long'}}
  test0 = test0 ? test0 : (long) test0; // expected-warning {{operand of ? changes signedness: 'long' to 'unsigned long'}}
  test0 = test0 ? test0 : (int) test0; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
  test0 = test0 ? test0 : (short) test0; // expected-warning {{operand of ? changes signedness: 'short' to 'unsigned long'}}
  test0 = test0 ? test0 : (long) 10;
  test0 = test0 ? test0 : (int) 10;
  test0 = test0 ? test0 : (short) 10;
  test0 = test0 ? (long) 10 : test0;
  test0 = test0 ? (int) 10 : test0;
  test0 = test0 ? (short) 10 : test0;

  int test1;
  test0 = test0 ? EVal : test0;
  test1 = test0 ? EVal : (int) test0;

  test0 = test0 ? EVal : test1; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
  test0 = test0 ? test1 : EVal; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}

  test1 = test0 ? EVal : (int) test0;
  test1 = test0 ? (int) test0 : EVal;

  // Note the thing that this does not test: since DR446, various situations
  // *must* create a separate temporary copy of class objects. This can only
  // be properly tested at runtime, though.
}
bool FDirectInputJoystick::Init(const DIDEVICEINSTANCE& joyins, FDirectInputDriver& adapter, HWND hWnd, bool bBackGround)
{
	if(pDevice_) return true;

	auto driver = adapter.driver();

	HRESULT r = driver->CreateDevice(joyins.guidInstance, &pDevice_, NULL);
	if(r!=DI_OK)
	{
		UE_LOG(LogDirectInputPadPlugin, Error, TEXT("Joystick CreateDevice fail. : %x"),r);
		return false;
	}

	r = pDevice_->SetDataFormat(&c_dfDIJoystick);
	if(r!=DI_OK)
	{
		UE_LOG(LogDirectInputPadPlugin, Error, TEXT("Joystick SetDataformat fail. : %x"),r);
		Fin();
		return false;
	}

	// CooperativeLevelフラグ決定
	DWORD flags = 0;
	
	if(bBackGround) // ウインドウが非アクティブでも取得される
		flags = DISCL_BACKGROUND | DISCL_NONEXCLUSIVE;
	else
		flags = DISCL_FOREGROUND | DISCL_NONEXCLUSIVE;

	r = pDevice_->SetCooperativeLevel(hWnd, flags);
	if(r!=DI_OK)
	{
		UE_LOG(LogDirectInputPadPlugin, Error, TEXT("Joystick SetCooperativeLevel fail. : %x"), r);
		Fin();
		return false;
	}

	// 軸の設定

	// 絶対軸モードに設定
	DIPROPDWORD diprop;
	diprop.diph.dwSize			= sizeof(DIPROPDWORD);
	diprop.diph.dwHeaderSize	= sizeof(DIPROPHEADER);
	diprop.diph.dwHow			= DIPH_DEVICE;
	diprop.diph.dwObj			= 0;
	diprop.dwData				= DIPROPAXISMODE_ABS;

	r = pDevice_->SetProperty(DIPROP_AXISMODE, &diprop.diph);
	if(r!=DI_OK)
	{
		UE_LOG(LogDirectInputPadPlugin, Error, TEXT("Joystick AxisMode Setup fail. : %x"), r);
		Fin();
		return false;
	}

	// 軸の範囲を設定
	std::tuple<HRESULT, LPDIRECTINPUTDEVICE8> axisResult(DI_OK, pDevice_);
	pDevice_->EnumObjects(&FDirectInputJoystick::OnEnumAxis, reinterpret_cast<void*>(&axisResult), DIDFT_AXIS);

	if(std::get<0>(axisResult)!=DI_OK)
	{
		Fin();
		return false;
	}

	// 軸の反転フラグ設定
	//AxisReverseFlagMap_.SetNumUninitialized(DIGamePad_ROT_Z+1);
	//for(uint32 i=DIGamePad_AXIS_X; i<=DIGamePad_ROT_Z; ++i)
	//	AxisReverseFlagMap_[i] = false;

	AxisReverseFlagMap_.Init(false,DIGamePad_ROT_Z+1);
	AxisReverseFlagMap_[DIGamePad_AXIS_Y] = true; // Y軸はXInputと合わせるためにデフォルトで反転

	// 初期化
	memset(&InitialJoyBuf_,0,sizeof(DIJOYSTATE));
	memset(&joyBuf_[0],0,sizeof(DIJOYSTATE));
	memset(&joyBuf_[1],0,sizeof(DIJOYSTATE));

	// 初期値を得る
	int loopcount=0;
	do{
		FPlatformProcess::Sleep(0.2);
		if(Input())
		{
			InitialJoyBuf_ = joyBuf_[nCurIndex_];
			if(++loopcount>10) break;
		}
		if(loopcount>100)
		{
			UE_LOG(LogDirectInputPadPlugin, Log, TEXT("DirectInput Joystick Create Fail. : %s"), joyins.tszProductName);
			return false;
		}
	}while(true);

	//	const string sFlag = (flags&DISCL_BACKGROUND)>0 ? "BACKGROUND" : "FOREGROUND";
	UE_LOG(LogDirectInputPadPlugin, Log, TEXT("DirectInput Joystick Create Success. : %s"), joyins.tszProductName);
	//UE_LOG(LogDirectInputPadPlugin, Log, TEXT("Init: %d"), InitialJoyBuf_.lRx);

	return true;
}
示例#26
0
void Aprendizagem_Reforco::loadInfo( int playerNum )
{
	char fileNumber[2]; // player number
	char dir[] = "info/InfoXX.csv"; // better not change this

	switch( playerNum ){
	case 0:
		fileNumber[0] = '0';
		fileNumber[1] = '0';
		break;
	case 1:
		fileNumber[0] = '0';
		fileNumber[1] = '1';
		break;
	case 2:
		fileNumber[0] = '0';
		fileNumber[1] = '2';
		break;
	case 3:
		fileNumber[0] = '0';
		fileNumber[1] = '3';
		break;
	case 4:
		fileNumber[0] = '0';
		fileNumber[1] = '4';
		break;
	case 5:
		fileNumber[0] = '0';
		fileNumber[1] = '5';
		break;
	case 6:
		fileNumber[0] = '0';
		fileNumber[1] = '6';
		break;
	case 7:
		fileNumber[0] = '0';
		fileNumber[1] = '7';
		break;
	case 8:
		fileNumber[0] = '0';
		fileNumber[1] = '8';
		break;
	case 9:
		fileNumber[0] = '0';
		fileNumber[1] = '9';
		break;
	case 10:
		fileNumber[0] = '1';
		fileNumber[1] = '0';
		break;
	case 11:
		fileNumber[0] = '1';
		fileNumber[1] = '1';
		break;
	case 12:
		fileNumber[0] = '1';
		fileNumber[1] = '2';
		break;
	}

	dir[9] = fileNumber[0];
	dir[10] = fileNumber[1];

	ifstream Fin( dir, ios::in );
	if (!Fin) // "Tried to read but failed, recreating/overwriting file"
	{
		ofstream Fout( dir, ios::out );
		if (!Fout) // Couldn't open for writing! path doesn't exist ? (check dir)
		{
			cerr << "ERROR while creating Info for player " << playerNum << "\n";
		}
		else // File successfully opened for writing
		{
			Fout << 0 << "\n" << 0 << "\n";
			Num_Jogos = 0;
			Num_Itera = 0;
		}
		Fout.close();
	}
	else
	{
		Fin >> Num_Jogos;
		Fin >> Num_Itera;
	}
	Fin.close();
}
示例#27
0
void Aprendizagem_Reforco::loadReport( int playerNum )
{
	char fileNumber[2]; // player number
	char dir[] = "report/ReportXX.csv"; // better not change this

	switch( playerNum ){
	case 0:
		fileNumber[0] = '0';
		fileNumber[1] = '0';
		break;
	case 1:
		fileNumber[0] = '0';
		fileNumber[1] = '1';
		break;
	case 2:
		fileNumber[0] = '0';
		fileNumber[1] = '2';
		break;
	case 3:
		fileNumber[0] = '0';
		fileNumber[1] = '3';
		break;
	case 4:
		fileNumber[0] = '0';
		fileNumber[1] = '4';
		break;
	case 5:
		fileNumber[0] = '0';
		fileNumber[1] = '5';
		break;
	case 6:
		fileNumber[0] = '0';
		fileNumber[1] = '6';
		break;
	case 7:
		fileNumber[0] = '0';
		fileNumber[1] = '7';
		break;
	case 8:
		fileNumber[0] = '0';
		fileNumber[1] = '8';
		break;
	case 9:
		fileNumber[0] = '0';
		fileNumber[1] = '9';
		break;
	case 10:
		fileNumber[0] = '1';
		fileNumber[1] = '0';
		break;
	case 11:
		fileNumber[0] = '1';
		fileNumber[1] = '1';
		break;
	case 12:
		fileNumber[0] = '1';
		fileNumber[1] = '2';
		break;
	}

	dir[13] = fileNumber[0];
	dir[14] = fileNumber[1];

	ifstream Fin( dir, ios::in );
	if (!Fin) // "Tried to read but failed, recreating/overwriting file"
	{
		ofstream Fout( dir, ios::out );
		if (!Fout) // Couldn't open for writing! path doesn't exist ? (check dir)
		{
			cerr << "ERROR while creating Report for player " << playerNum << "\n";
		}
		else // File successfully opened for writing
		{
			Fout << "Num_Jogo ";
			Fout << "Num_Acoes ";
			for( int i = 0; i<num_acoes; i++ )
			{
				Fout << "A" << i+1 << " ";
			}
			Fout << "Gols_Feitos ";
			Fout << "Gols_Sofridos ";
			Fout << "Epsilon ";
			Fout << "Exp_Q(%) ";
			Fout << "Exp_H(%) ";
			Fout << "\n";
		}
		Fout.close();
	}
	Fin.close();
}