2 registered members (dr_panther, 7th_zorro),
1,203
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Keybinds
[Re: Kartoffel]
#461064
07/24/16 09:45
07/24/16 09:45
|
Malice
Unregistered
|
Malice
Unregistered
|
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.htmAnd 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
OP
Expert
|
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: ]
#461067
07/24/16 10:04
07/24/16 10:04
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
you're right, thanks a lot 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
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
a bit hacky but if anybody needs it:
#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
|
Malice
Unregistered
|
Malice
Unregistered
|
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: Kartoffel]
#461075
07/24/16 12:03
07/24/16 12:03
|
Malice
Unregistered
|
Malice
Unregistered
|
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
OP
Expert
|
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
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
Okay, so if anyone needs it this one gets the job done:
#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
|
|
|
|