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
1 registered members (AndrewAMD), 945 guests, and 8 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 3 of 3 1 2 3
Re: Keybinds [Re: Kartoffel] #461064
07/24/16 09:45
07/24/16 09:45

M
Malice
Unregistered
Malice
Unregistered
M



If I remember - acknex uses 12 up to 32 buttons on the joy and 4 are the dpad.
In the past to get the button numbers i believe I used a calibration app in the windows control panel.

You should be able to use a function to debug_var the joy button numbers.

Check out joy button http://www.conitec.net/beta/joy_buttons.htm
And joy_pressed in key.c

Last edited by Malice; 07/24/16 09:54.
Re: Keybinds [Re: ] #461065
07/24/16 09:56
07/24/16 09:56
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
I already tested it, the dpad is not included in these 12 buttons.
They only include: 4 buttons on the right (ABXY), 4 shoulder buttons, 2 in the middle (Select/Start) and the 2 thumbstick-buttons


POTATO-MAN saves the day! - Random
Re: Keybinds [Re: Kartoffel] #461066
07/24/16 10:01
07/24/16 10:01

M
Malice
Unregistered
Malice
Unregistered
M



Hummm... Well there is 32 . LOL then it's joy_hat http://www.conitec.net/beta/ajoy_hat.htm

Edits to come

Re: Keybinds [Re: ] #461067
07/24/16 10:04
07/24/16 10:04
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
you're right, thanks a lot laugh

but instead of using two variables they used one which stores the angle of the dpad... weird stuff


POTATO-MAN saves the day! - Random
Re: Keybinds [Re: Kartoffel] #461068
07/24/16 10:21
07/24/16 10:21
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
a bit hacky but if anybody needs it:
Code:
#define joy_dpad_up (joy_hat != -1 && (joy_hat < 67.5 || joy_hat > 292.5))
#define joy_dpad_down (joy_hat != -1 && joy_hat > 112.5 && joy_hat < 247.5)
#define joy_dpad_left (joy_hat != -1 && joy_hat > 202.5 && joy_hat < 337.5)
#define joy_dpad_right (joy_hat != -1 && joy_hat > 22.5 && joy_hat < 157.5)

#define joy2_dpad_up (joy2_hat != -1 && joy2_hat < 67.5 || joy2_hat > 292.5)
#define joy2_dpad_down (joy2_hat != -1 && joy2_hat > 112.5 && joy2_hat < 247.5)
#define joy2_dpad_left (joy2_hat != -1 && joy2_hat > 202.5 && joy2_hat < 337.5)
#define joy2_dpad_right (joy2_hat != -1 && joy2_hat > 22.5 && joy2_hat < 157.5)

the only problem left is that gamepads without a d-pad seem to always have joy_hat = 0... (which would be dpad-up)


POTATO-MAN saves the day! - Random
Re: Keybinds [Re: Kartoffel] #461069
07/24/16 10:44
07/24/16 10:44

M
Malice
Unregistered
Malice
Unregistered
M



No they should have a value of joy_hat == -1; or otherwise 'centered'

If not --->> That's a bug.

Last edited by Malice; 07/24/16 10:45.
Re: Keybinds [Re: ] #461072
07/24/16 11:28
07/24/16 11:28
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 the center position is -1... but on my second gamepad (which has no dpad) joy_hat is always 0. However, there are no problems in any games I played with it, yet. smirk


POTATO-MAN saves the day! - Random
Re: Keybinds [Re: Kartoffel] #461075
07/24/16 12:03
07/24/16 12:03

M
Malice
Unregistered
Malice
Unregistered
M



Well just speaking from general programming logic [Not that I can say much], 0 should not be a valid value and a returned value for the detection of an invalid.

0/1 are common returns for valid/invalid -success/fail but 0 than is both up and invalid in this case. That's kind of poor logic even to a half-a** code want-to-be like me...

Last edited by Malice; 07/24/16 12:04.
Re: Keybinds [Re: ] #461079
07/24/16 14:07
07/24/16 14:07
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Yeah, but this might be a problem with direct input itself and not the implementation.

Anyway... thinking about it, a simple workaround would be disabling the dpad's input on startup and only enabling it after the dpad is centered (joy_hat == -1)


POTATO-MAN saves the day! - Random
Re: Keybinds [Re: Kartoffel] #461080
07/24/16 14:42
07/24/16 14:42
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Okay, so if anyone needs it this one gets the job done:
Code:
#define joy_available (num_joysticks >= 1)
#define joy_dpad_center (joy_available && joy_hat == -1)
#define joy_dpad_up (joy_available && joy_dpad_available && joy_hat != -1 && (joy_hat < 67.5 || joy_hat > 292.5))
#define joy_dpad_down (joy_available && joy_dpad_available && joy_hat != -1 && joy_hat > 112.5 && joy_hat < 247.5)
#define joy_dpad_left (joy_available && joy_dpad_available && joy_hat != -1 && joy_hat > 202.5 && joy_hat < 337.5)
#define joy_dpad_right (joy_available && joy_dpad_available && joy_hat != -1 && joy_hat > 22.5 && joy_hat < 157.5)

#define joy2_available (num_joysticks >= 2)
#define joy2_dpad_center (joy2_available && joy2_hat == -1)
#define joy2_dpad_up (joy2_available && joy2_dpad_available && joy2_hat != -1 && joy2_hat < 67.5 || joy2_hat > 292.5)
#define joy2_dpad_down (joy2_available && joy2_dpad_available && joy2_hat != -1 && joy2_hat > 112.5 && joy2_hat < 247.5)
#define joy2_dpad_left (joy2_available && joy2_dpad_available && joy2_hat != -1 && joy2_hat > 202.5 && joy2_hat < 337.5)
#define joy2_dpad_right (joy2_available && joy2_dpad_available && joy2_hat != -1 && joy2_hat > 22.5 && joy2_hat < 157.5)

byte joy_dpad_available = false;
byte joy2_dpad_available = false;

// no need to call this function yourself!! the engine will do this automatically on startup due to the '_startup' suffix
void __joy_dpad_check_startup()
{
	if(num_joysticks <= 0) // no direct input game controllers connected
		return;
	
	while(!joy_dpad_available || (joy2_available && !joy2_dpad_available))
	{
		if(joy_dpad_center) joy_dpad_available = true;
		if(joy2_dpad_center && joy2_available) joy2_dpad_available = true;
		
		wait(-1);
	}
}

Note that it only checks if a dpad is available every second. If you want it to check every frame you can use wait(1) instead.

edit#3: oops, forgot that there's no 'bool' in standard lite-c so I changed it to byte
also added some safety checks that prevent joy_dpad_up to be true when no gamepad is connected

Last edited by Kartoffel; 07/24/16 14:56.

POTATO-MAN saves the day! - Random
Page 3 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