ERLEDIGT
JA
JA
ANTWORTEN
1
1
ZUGRIFFE
282
282
EMPFEHLEN
-
28.12.08 12:15 #1
- Registriert seit
- Jun 2008
- Ort
- Nah bei Köln
- Beiträge
- 252
Hallo,
wollte einen Button programmieren der mir ermittelt welcher Joystick Knopf gedrückt wird, sobald einer gedrückt wird. So wie in den Spielen halt, wenn man z.B. definiert auf welcher Taste die Hupe liegt.
Sieht bis jetzt so aus:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
// Find all the GameControl devices that are attached. DeviceList^ conList = Manager::GetDevices(DeviceClass::GameControl, EnumDevicesFlags::AttachedOnly); // check that we have at least one device. if(conList->Count > 0){ conList->MoveNext(); DeviceInstance^ devInst = (DeviceInstance)conList->Current; Device^ joy = gcnew Device(devInst->InstanceGuid); joy->SetCooperativeLevel(this, CooperativeLevelFlags::Background | CooperativeLevelFlags::NonExclusive); joy->SetDataFormat(DeviceDataFormat::Joystick); // Finally, acquire the device. joy->Acquire(); DeviceCaps cps = joy->Caps; // Name of JoyStick MessageBox::Show("Chosen Device: " + joy->DeviceInformation.ProductName); // number of Axes MessageBox::Show("Joystick Axis: " + cps.NumberAxes); // number of Buttons MessageBox::Show("Joystick Buttons: " + cps.NumberButtons); // number of PoV hats MessageBox::Show("Joystick PoV hats: " + cps.NumberPointOfViews); try { joy->Poll(); // update the joystick state field JoystickState state = joy->CurrentJoystickState; // cli::array<bool>^ buttons = gcnew array< bool>(joy->Caps.NumberButtons); bool pressed = false; while(!pressed){ for(int i = 0; i < joy->Caps.NumberButtons; i++){ state = joy->CurrentJoystickState; if(state.GetButtons()[i] >= 128){ pressed = true; MessageBox::Show("Blubb"); } } } } catch (Exception^ err) { MessageBox::Show(err->Message); } }
Aber sobald er in die while-Schleife geht ist Ende - Endlosschleife
Ich denke es ist die Zeile:
Code :1
if(state.GetButtons()[i] >= 128){
Aber in nem anderen Fall geht die Zeile ohne Probleme...
da heissts nämlich:
bool buttonA = state.GetButtons()[0] >= 128;
und dann kann ich halt if(buttonA){ .... } blubb blah blah machen....
Bitte helft mir.
Danke im Vorraus!
WRGeändert von WorldRacer (28.12.08 um 12:21 Uhr)
-
29.12.08 01:17 #2
- Registriert seit
- Jun 2008
- Ort
- Nah bei Köln
- Beiträge
- 252
Mein Gott, dass ihr da net drauf kommt...
Ich hab nun die Lösung selbst gefunden...
in der while-Schleife zusätzlich noch joy-Poll(); ausführen und schon gehts....
Ähnliche Themen
-
IE - Button background image wiederholt sich & Button verrutscht
Von Fantasmo im Forum CSSAntworten: 2Letzter Beitrag: 03.03.09, 16:15 -
Hilfe ! Wenn man Button 3 anklickt soll Button 4 nicht mehr funktionieren.
Von SilentTigeR im Forum Visual Basic 6.0Antworten: 1Letzter Beitrag: 23.05.08, 21:23 -
Submit-Button nach Klick auf Radio-Button aktivieren
Von altox-de im Forum PHPAntworten: 8Letzter Beitrag: 30.04.06, 16:46 -
Wert von Radio Button auf einen Submit Button weiterleiten
Von ImperatorAres im Forum Flash PlattformAntworten: 8Letzter Beitrag: 20.09.05, 07:19 -
Anderer Button wenn die Maus ueber einen Button geht.
Von Daniel im Forum HTML & XHTMLAntworten: 2Letzter Beitrag: 23.11.00, 13:14





Zitieren
Login





