|
|
Joysick Buttons abfragen?
#236480
11/14/08 13:42
11/14/08 13:42
|
Joined: Aug 2005
Posts: 512 Bayern
Schmerzmittel
OP
User
|
OP
User
Joined: Aug 2005
Posts: 512
Bayern
|
Hiho an alle,
ich hätt da gern mal ein Problem.
Mit key_lastpressed kann man ja die Tastatur abfragen, welche Taste gedrückt wurde.
Geht das auch mit einem Joystick? Habe nämlich keinen Befehl dafür gefunden.
Ich schreibe gerade einen Menücode, indem man seine Steuerung selber einstellen kann. Da aber das spiel auch mit Joystick, bzw. Joypad spielbar sein soll, möchte ich auch diese Abfragen.
Mit der Sufu hab ich nichts gefunden.
Grüße Schmerzmittel
A7 Com V7.80
|
|
|
Re: Joysick Buttons abfragen?
[Re: flits]
#236578
11/14/08 23:29
11/14/08 23:29
|
Joined: Aug 2005
Posts: 512 Bayern
Schmerzmittel
OP
User
|
OP
User
Joined: Aug 2005
Posts: 512
Bayern
|
Jo die kenne ich die Liste.
Mir geht es um folgendes:
Wenn ich in einem Menü die Steuerung eingeben will, und diese dann in eine ini speichere, wird sie ja über key_lastpressed in einen String gespeichert (also die zuletzt gedrückte Taste).
Aber den Joystick erkennt die Funktion nicht. Daher meine Frage, ob das überhaupt möglich ist, abzufragen, welcher Joystick Button gedrückt wurde, um diesen dann in einen String zu schreiben.
Hoffe das war einigermaßen verständlich geschrieben.
A7 Com V7.80
|
|
|
Re: Joysick Buttons abfragen?
[Re: Schmerzmittel]
#236594
11/15/08 02:15
11/15/08 02:15
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Also ich würde mir da einfach selber eine key_lastpressed Funktion schreiben. Vielleicht ungefähr so: // Returns 0 in case no key is pressed at all, else the key code.
fixed getkeypressed()
{
fixed i;
for (i = 1; i < 280; i++)
if (key_pressed(i))
return i;
return 0;
}Diese Funktion könntest Du dann ganz bequem in Deinem Menü verwenden.
// show your key prompt
fixed key;
for (key = 0; key == 0; key = getkeypressed())
wait(1);
STRING* s = str_for_num(str_create("#3"),key);
// Now the string s contains the scancode of the key last pressed - including joystick buttons.Beware of bugs in the code above. I've only proven it correct, not tested it. ;-)
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Joysick Buttons abfragen?
[Re: Uhrwerk]
#236605
11/15/08 07:04
11/15/08 07:04
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
Expert
|
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
key_lastpressed
This variable contains the scancode of the last key or button pressed. The scancodes are listed in the "key functions" chapter.
key_lastpressed thus does NOT contain a string but the scan code of the key that was pressed last. So instead of saving key names you'd better save the scan codes and use them together with key_set to map your keys to user specified buttons. key_set (number, function);
Sets the given function to the key with the given scancode. This way keyboard remapping can be done very easily.
|
|
|
Re: Joysick Buttons abfragen?
[Re: Xarthor]
#236638
11/15/08 14:39
11/15/08 14:39
|
Joined: Aug 2005
Posts: 512 Bayern
Schmerzmittel
OP
User
|
OP
User
Joined: Aug 2005
Posts: 512
Bayern
|
Uhrwerk auf diese Idee bin ich noch gar nicht gekommen.
Ich werds ausprobieren.
Danke für die Hilfe.
A7 Com V7.80
|
|
|
|