Joystickabfrage mit DirectX



  • Hallo,

    ich habe vor in einer Windowas Formas Anwendung einen Joystick mittels DirectX abzufragen.
    ZUm Testen haben ich einfach einmal einen Button auf das Form gelegt und folgendes versucht:

    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
    			 {
    				DeviceList^ gameControllerList = Manager::GetDevices(DeviceClass::GameControl, EnumDevicesFlags::AllDevices);
    				if (gameControllerList->Count > 0)
    				{
    					// Move to the first device
    					gameControllerList->MoveNext();
    					deviceInstance = (DeviceInstance)
    						gameControllerList->Current;
    					// create a device from this controller.
    					joystickDevice = gcnew Device(deviceInstance.InstanceGuid);
    					joystickDevice->SetCooperativeLevel(this, CooperativeLevelFlags::Background |  CooperativeLevelFlags::NonExclusive);
    					// Tell DirectX that this is a Joystick.
    					joystickDevice->SetDataFormat(DeviceDataFormat::Joystick); 
    					// Finally, acquire the device.
    					joystickDevice->Acquire();
    					//Pollen
    					joystickDevice->Poll();
    					//Status auffrischen
    					state = joystickDevice->CurrentJoystickState;
    MessageBox::Show(state->ToString());
    MessageBox::Show(joystickDevice->DeviceInformation.ProductName);
    
    				}
    			 }
    

    Die zweite MessageBox gibt den Namen "USB Joystick" aus. Daraus schliese ich, dass der angeschlossene Joystick richtig als solcher erkannt wurde.

    Die erste MessageBox gibt einen Liste mit Joystickzuständen aus die aber, auch wenn ich am Joystick Tasten zum Abfragezeitpunkt gedrückt halte, nur "0" bzw. "32767" sind.

    Hat jemand eine Idee was ich falsch mache?

    Gruss
    Steffen


Anmelden zum Antworten