Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, VoroneTZ), 831 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 3 1 2 3
Re: Keybinds [Re: Reconnoiter] #461016
07/22/16 17:58
07/22/16 17:58
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Well, I'm not a big fan of the on_...-events and I don't think that there's an event for all keys on a normal Keyboard.

Using a custom input system seems more elegant and cleaner to me.

@Reconnoiter: The method I'm going to use is similar to the one you posted. However, I think using strings as keycodes adds unnecessary complexity (parsing the string on every poll...) and makes it harder to implement actual ingame binding (which is important to me aswell).

Edit: I just saw that theres a reverse function for key_for_str() (str_for_key(), I searched for key_to_str()...)
So ingame binding with your method wouldn't be a problem. But it's still just wasted performance imo.. going from the scancode to the key-string just to do the reverse for every key poll crazy

Last edited by Kartoffel; 07/22/16 18:24.

POTATO-MAN saves the day! - Random
Re: Keybinds [Re: Kartoffel] #461019
07/22/16 19:29
07/22/16 19:29
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Originally Posted By: Kartoffel
@Reconnoiter: The method I'm going to use is similar to the one you posted. However, I think using strings as keycodes adds unnecessary complexity (parsing the string on every poll...) and makes it harder to implement actual ingame binding (which is important to me aswell).

Edit: I just saw that theres a reverse function for key_for_str() (str_for_key(), I searched for key_to_str()...)
So ingame binding with your method wouldn't be a problem. But it's still just wasted performance imo.. going from the scancode to the key-string just to do the reverse for every key poll crazy
, does your method allow modifying mouse buttons? (if so could you post a simple example how you do it now? (pretty please with sugar ontop))

Re: Keybinds [Re: Reconnoiter] #461021
07/22/16 19:54
07/22/16 19:54
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
you have all the key related variables sorted by scancode into arrays already.

Code:
int _i = 1;
for ( ; _i<89; _i+=1 )
{
	key_set ( _i, myEvent );
	if ( *(&on_esc+_i-1) != myEvent )
		error ( str_cat ( str_for_key ( NULL, _i ), " is not into an array???" ) );
	key_set ( _i, NULL );
}

while ( !key_esc )
{
	for ( _i=1; _i<89; _i+=1 )
	{
		if ( *(&key_esc+_i-1) == 1 )
			draw_text ( str_cat ( str_for_key ( NULL, _i ), " key pressed" ), 10, 10, COLOR_WHITE );
	}
	wait(1);
}



but those arrays are not public and due to engines frequent updates and constant evolution use these things is a high risk [buahahaha]

Anyway, if it is a matter of customization, you can use pointers for actions.

Code:
var *keyUp = &key_w;
...
if ( *keyUp ) {...}



Quote:
I don't think that there's an event for all keys on a normal Keyboard.

there are...

Last edited by txesmi; 07/22/16 20:21.
Re: Keybinds [Re: txesmi] #461022
07/22/16 20:24
07/22/16 20:24
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Quote:
but those arrays are not public and due to engines frequent updates and constant evolution use these things is a high risk [buahahaha]
shots fired laugh

@Reconnoiter: I haven't even started writing the code but it shouldn't be too different when using mouse buttons...


POTATO-MAN saves the day! - Random
Re: Keybinds [Re: txesmi] #461025
07/22/16 21:46
07/22/16 21:46
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
@txesmi, ty!

Originally Posted By: txesmi

but those arrays are not public and due to engines frequent updates and constant evolution use these things is a high risk [buahahaha]
, [black van stopping at the door]

Re: Keybinds [Re: Reconnoiter] #461029
07/22/16 23:37
07/22/16 23:37
Joined: Jul 2016
Posts: 9
J
JackPell Offline
Newbie
JackPell  Offline
Newbie
J

Joined: Jul 2016
Posts: 9
I have an init_keys() function that loads the scan codes for the control keys from external file and set them to variables with meaningful names (like key_jump_scan, key_shoot_scan .. etc.) ,then update_keys() that runs every frame that sets the state of every key to another kind of variable (like: key_jump, key_shoot ... etc.) using key_pressed(scan_code) function:

Code:
while(1)
{
   ...
   key_jump = key_pressed(key_jump_scan); //key_jump_scan was already set to the scan code of the desired key in the previous init_keys() function
   
   ...
   wait(1);
}



Then, inside the main code that controls whatever kind of key-based behaviour, i use the key_something variable like:

Code:
...
movement_speed.x = (key_forward-key_backward)*10*time_step;
...


Re: Keybinds [Re: JackPell] #461030
07/22/16 23:57
07/22/16 23:57

M
Malice
Unregistered
Malice
Unregistered
M



Key_pressed with the -1 ability and also key_pressed to key_lastpressed and key_any(x) == X and also the key_hit.

But if you have the pre-mapped key in a array if(i[0]) jump and if(i[1]) walk
then you can remap by recording on the menu page the replacement string i[0]=key_for_str() then forever cycle your array in each frame. But remember to reset key_pressed with the -1 where needed or compare to key_last where needed. And key any() actually helps at times.


Last edited by Malice; 07/22/16 23:59.
Re: Keybinds [Re: ] #461045
07/23/16 17:31
07/23/16 17:31
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
another related question:

Does anyone know how to get the input from a gamepad's d-pad?


POTATO-MAN saves the day! - Random
Re: Keybinds [Re: Kartoffel] #461057
07/24/16 04:09
07/24/16 04:09
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
I'm using superKu's Xinput dll


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: Keybinds [Re: alibaba] #461060
07/24/16 08:58
07/24/16 08:58
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Originally Posted By: alibaba
I'm using superKu's Xinput dll
yes, I'm using this one, too (thanks again, superku smile)

However, I also want to support older DirectInput game controllers...


POTATO-MAN saves the day! - Random
Page 2 of 3 1 2 3

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

Gamestudio download | chip programmers | 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