Autor Beitrag
Tilman
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1405
Erhaltene Danke: 51

Win 7, Android
Turbo Delphi, Eclipse
BeitragVerfasst: Di 20.11.07 15:09 
Ich möchte den Zustand des Joystick-POVs auswerten, und zwar so als würde es sich um 4 Tasten (so wie beim Steuerkreuz eines Gamepads) handeln. Allerdings soll die Auswertung auch funktionieren wenn ein Controller mit Continuous POV angeschlossen ist. Bisher funzt es so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
   joyGetPosEx(jid,@jie);

   shape1.Brush.Color := clWhite;
   shape2.Brush.Color := clWhite;
   shape3.Brush.Color := clWhite;
   shape4.Brush.Color := clWhite;

   if ((jie.dwPOV > JOY_POVLEFT)  or (jie.dwPOV < JOY_POVRIGHT)) and (jie.dwPOV <> 65535then shape1.Brush.Color := clRed;
   if (jie.dwPOV > JOY_PovForward)  and (jie.dwPOV < JOY_PovBackward) then shape2.Brush.Color := clRed;
   if (jie.dwPOV > JOY_PovRight)  and (jie.dwPOV < JOY_POVLeft) then shape3.Brush.Color := clRed;
   if (jie.dwPOV > JOY_POVbackward) and (jie.dwPOV <> 65535then shape4.Brush.Color := clRed;


aber irgendwie finde ich das Ergebnis unbefriedigend... daher wollte ich fragen ob jemand eine elegantere Lösung kennt.

_________________
Bringe einen Menschen zum grübeln, dann kannst du heimlich seinen Reis essen.
(Koreanisches Sprichwort)
Andreas Pfau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: So 06.01.08 01:30 
Hi,

laut MSDN ist dwPOV = -1 wenn der POV losgelassen wurde, ansonsten der Auslenkungswinkel durch 100.

Also würd ich eine TPaintBox nehmen, welche einen Pfeil darstellt. Wenn dwPOV = -1, dann zeichne nix, ansonsten einen Pfeil mit den Koordinaten:
ausblenden Delphi-Quelltext
1:
2:
dX := NullpunktX + Round(Laenge * Cos(Pi / 2 - jie.dwPOV * PI / 50));
dY := NullpunktX + Round(Laenge * Sin(Pi / 2 - jie.dwPOV * PI / 50));

_________________
Life is a bad adventure, but the graphic is really good!
Tilman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1405
Erhaltene Danke: 51

Win 7, Android
Turbo Delphi, Eclipse
BeitragVerfasst: So 06.01.08 12:59 
Danke, aber es läuft jetzt gut und den Code sieht ja keiner mehr, werde daher nix mehr ändern ;)

_________________
Bringe einen Menschen zum grübeln, dann kannst du heimlich seinen Reis essen.
(Koreanisches Sprichwort)