So I'm trying to make a simple debounce and I just can't figure out where I messed up. Here is the code:
def debounce(var, db):
if var == 1 and db == 0:
db = 1
elif var == 0:
db = 0
else:
var = 0
return var, db
while True:
mouse_buttons = get_mouse_buttons() # -This is the fuction that if the mouse's buttons are pressed
pressed, db = debounce(mouse_buttons[0], db)
mouse_buttons = (pressed, 0, 0)
print(mouse_buttons[0])
My expected output would be if I press the mouse button, then it would be a 1 for once, then turn 0 untill I release and press it again. The current code gives out a 1 for the first time, and no matter what, it only gives out 0 after. (I tested it, it has nothing to do with the function that returns the pressed buttons on the mouse.)