Joypad / hal_input - detects changes only?
- frogandspanner
- Offline
- Senior Member
Less
More
- Posts: 65
- Thank you received: 2
27 Dec 2022 21:08 #260432
by frogandspanner
Joypad / hal_input - detects changes only? was created by frogandspanner
I have been developing some ideas based on a Joypad, using hal_input to detect button positions. (I want to use the Potent Iometers, so having spare input pins when they are so scarce on a parallel port seemed useful).
I connected switches to where the btn-base2 and btn-pinkie buttons would short to gnd, but hal_input seems to detect the switch position only when its position changes.
e.g. if I have the switch across btn-pinkie set to closed, and look at the detected value it is FALSE until I cycle the switch.
This is what I say to halcmd:
loadusr -W hal_input -KRAL Gamepad
start
show pin input.0.btn-base2 input.0.btn-pinkie
shows the pins as FALSE, but cycling pinkie (open/close) result in it now showing TRUE when I say
show pin input.0.btn-base2 input.0.btn-pinkie
Is this to do with the way the Joypad works, or the way that hal_input works?
Is there anything I can do to alter the behaviour?
I connected switches to where the btn-base2 and btn-pinkie buttons would short to gnd, but hal_input seems to detect the switch position only when its position changes.
e.g. if I have the switch across btn-pinkie set to closed, and look at the detected value it is FALSE until I cycle the switch.
This is what I say to halcmd:
loadusr -W hal_input -KRAL Gamepad
start
show pin input.0.btn-base2 input.0.btn-pinkie
shows the pins as FALSE, but cycling pinkie (open/close) result in it now showing TRUE when I say
show pin input.0.btn-base2 input.0.btn-pinkie
Is this to do with the way the Joypad works, or the way that hal_input works?
Is there anything I can do to alter the behaviour?
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23162
- Thank you received: 4860
31 Dec 2022 16:52 #260660
by andypugh
Replied by andypugh on topic Joypad / hal_input - detects changes only?
Are you saying that the button operates as a latching switch?
Try "loadusr halmeter pin input.0.btn-base2 input.0.btn-pinkie" in the HAL file to view the live status of the input.
Try "loadusr halmeter pin input.0.btn-base2 input.0.btn-pinkie" in the HAL file to view the live status of the input.
Please Log in or Create an account to join the conversation.
- frogandspanner
- Offline
- Senior Member
Less
More
- Posts: 65
- Thank you received: 2
31 Dec 2022 20:01 #260676
by frogandspanner
Replied by frogandspanner on topic Joypad / hal_input - detects changes only?
No - not toggling - just that it appears to edge detect.
I have tried your suggestion.
When I leave the switch in a position where both input.0s should be TRUE, then load my hal file (including your suggestions - didn't work as a single line, so I split it into two lines) the inputs are both FALSE. If I change the switch so it should show FALSE, then back to TRUE it shows TRUE.
I am beginning the think the joypad buttons edge-detect. That's OK - I'll just rework how I do things a little.
Many Thanks
Tony Chabot
I have tried your suggestion.
When I leave the switch in a position where both input.0s should be TRUE, then load my hal file (including your suggestions - didn't work as a single line, so I split it into two lines) the inputs are both FALSE. If I change the switch so it should show FALSE, then back to TRUE it shows TRUE.
I am beginning the think the joypad buttons edge-detect. That's OK - I'll just rework how I do things a little.
Many Thanks
Tony Chabot
Please Log in or Create an account to join the conversation.
- frogandspanner
- Offline
- Senior Member
Less
More
- Posts: 65
- Thank you received: 2
31 Dec 2022 20:46 #260678
by frogandspanner
Replied by frogandspanner on topic Joypad / hal_input - detects changes only?
The switch is actually a multipole rotary switch as I was intending to use it to select four possible states. Once rotated into each position the connections are maintained - as in a toggle switch.
Please Log in or Create an account to join the conversation.
Time to create page: 0.055 seconds