Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard keys not detected #873

Closed
lordloki opened this issue Oct 6, 2018 · 1 comment
Closed

Keyboard keys not detected #873

lordloki opened this issue Oct 6, 2018 · 1 comment

Comments

@lordloki
Copy link
Member

lordloki commented Oct 6, 2018

Using code from UPBGE python API doesn't work. Tested in current master.
With always sensor:

# The all keys thing without a keyboard sensor (but you will
# need an always sensor with pulse mode on)
import bge

# Just shortening names here
keyboard = bge.logic.keyboard
JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED

if JUST_ACTIVATED in keyboard.inputs[bge.events.WKEY].queue:
     print("Activate Forward!")

With keyboard sensor "Q":

import bge

co = bge.logic.getCurrentController()
# 'Keyboard' is a keyboard sensor
sensor = co.sensors["Keyboard"]

for key, input in sensor.inputs:
     # key[0] == bge.events.keycode = event.type, key[1] = input
     if bge.logic.KX_INPUT_JUST_ACTIVATED in input.queue:
             if key == bge.events.SKEY:
                     print("Activate Back!")

Test blend: http://pasteall.org/blend/index.php?id=50473

panzergame added a commit that referenced this issue Oct 6, 2018
EXP_ListWrapper wasn't constructed with flag FLAG_FIND_VALUE which is
allowing to do python comparaison when searching for a value in a container.

List such as queue, values and status are most of the times used this
way.
The flag is restored.

Fix issue #873.
@panzergame
Copy link
Contributor

Fixed by 0513b96.

youle31 pushed a commit that referenced this issue May 26, 2019
EXP_ListWrapper wasn't constructed with flag FLAG_FIND_VALUE which is
allowing to do python comparaison when searching for a value in a container.

List such as queue, values and status are most of the times used this
way.
The flag is restored.

Fix issue #873.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants