Gamestudio Links
Zorro Links
Newest Posts
Zorro version 3.0 prerelease!
by Grant. 02/24/26 22:21
WFO Training with parallel cores Zorro64
by Martin_HH. 02/24/26 19:51
ZorroGPT
by TipmyPip. 02/23/26 21:52
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
5 registered members (TipmyPip, clint000, Grant, chsmac85, Martin_HH), 5,858 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Joysick Buttons abfragen? #236480
11/14/08 13:42
11/14/08 13:42
Joined: Aug 2005
Posts: 512
Bayern
Schmerzmittel Offline OP
User
Schmerzmittel  Offline 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: Schmerzmittel] #236500
11/14/08 14:58
11/14/08 14:58
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl


"empty"
Re: Joysick Buttons abfragen? [Re: flits] #236578
11/14/08 23:29
11/14/08 23:29
Joined: Aug 2005
Posts: 512
Bayern
Schmerzmittel Offline OP
User
Schmerzmittel  Offline 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 Offline
Expert
Uhrwerk  Offline
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:
Code:
// 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.
Code:
// 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 Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Quote:

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.

Quote:

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 Offline OP
User
Schmerzmittel  Offline 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

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1