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

use setRawButtonDown/UpEvent #619

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions ursina/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def __init__(self, title='ursina', icon='textures/ursina.ico', borderless=True,

# input
if application.window_type == 'onscreen':
self.buttonThrowers[0].node().setButtonDownEvent('buttonDown')
self.buttonThrowers[0].node().setButtonUpEvent('buttonUp')
self.buttonThrowers[0].node().setRawButtonDownEvent('buttonDown')
self.buttonThrowers[0].node().setRawButtonUpEvent('buttonUp')
self.buttonThrowers[0].node().setButtonRepeatEvent('buttonHold')
self.buttonThrowers[0].node().setKeystrokeEvent('keystroke')
self._input_name_changes = {
Expand All @@ -94,7 +94,11 @@ def __init__(self, title='ursina', icon='textures/ursina.ico', borderless=True,
for e in keyboard_keys:
self.accept(f'raw-{e}', self.input, [e, True])
self.accept(f'raw-{e}-up', self.input_up, [e, True])
self.accept(f'raw-{e}-repeat', self.input_hold, [e, True])

for e in ('control', 'shift', 'alt'):
for s in ('l', 'r'):
self.accept(f'raw-{s}{e}', self.input, [e, True])
self.accept(f'raw-{s}{e}-up', self.input_up, [e, True])

self.accept('buttonDown', self.input)
self.accept('buttonUp', self.input_up)
Expand Down Expand Up @@ -221,15 +225,6 @@ def input(self, key, is_raw=False): # internal method for handling input
if not is_raw and key in keyboard_keys:
return

if 'mouse' not in key:
for prefix in ('control-', 'shift-', 'alt-'):
if key.startswith(prefix):
key = key.replace('control-', '')
key = key.replace('shift-', '')
key = key.replace('alt-', '')
if key in keyboard_keys:
return

if key in self._input_name_changes:
key = self._input_name_changes[key]

Expand Down