Skip to content

Commit

Permalink
feat: allow active overlay values to be updated with arrow and WASD keys
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm committed Apr 8, 2022
1 parent fce3f93 commit dbb30c9
Showing 1 changed file with 36 additions and 22 deletions.
58 changes: 36 additions & 22 deletions lib/events.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
def capture_modifier_keys(cls, event=None):
cls.key_no_modifiers = True if event is None else not event.ctrl and not event.alt
cls.key_ctrl = False if event is None else event.ctrl and not event.alt
cls.key_shift_ctrl = False if event is None else event.shift and cls.key_ctrl
cls.key_alt = False if event is None else not event.ctrl and event.alt
cls.key_shift_alt = False if event is None else event.shift and cls.key_alt
cls.key_ctrl_alt = False if event is None else event.ctrl and event.alt
cls.key_shift_ctrl_alt = False if event is None else event.shift and cls.key_ctrl_alt
cls.key_shift =False if event is None else event.shift
cls.key_shift_no_modifiers = False if event is None else event.shift and cls.key_no_modifiers
cls.key_toggle_pin_overlay = False if event is None else event.type == 'P' and event.value == 'PRESS'
cls.key_one = False if event is None else event.type == 'ONE' and event.value == 'PRESS'
cls.key_two = False if event is None else event.type == 'TWO' and event.value == 'PRESS'
cls.key_three = False if event is None else event.type == 'THREE' and event.value == 'PRESS'
cls.key_toggle_operator_passthrough = False if event is None else event.type == 'BACK_SLASH' and event.value == 'PRESS'
cls.key_increase_factor = False if event is None else event.type in {'PLUS', 'EQUAL', 'NUMPAD_PLUS'} and event.value == 'PRESS'
cls.key_decrease_factor = False if event is None else event.type in {'MINUS', 'NUMPAD_MINUS'} and event.value == 'PRESS'
cls.key_step_up = False if event is None else event.type == 'WHEELUPMOUSE'
cls.key_step_down = False if event is None else event.type == 'WHEELDOWNMOUSE'
cls.key_confirm = False if event is None else event.type == 'LEFTMOUSE'
cls.key_confirm_alternative = False if event is None else event.type == 'SPACE'
cls.key_cancel = False if event is None else event.type in {'RIGHTMOUSE', 'ESC'}
cls.key_movement_passthrough = False if event is None else event.type == 'MIDDLEMOUSE' or (event.alt and event.type in {'LEFTMOUSE', 'RIGHTMOUSE'}) or event.type.startswith('NDOF')
cls.key_no_modifiers = False if event == None else not event.ctrl and not event.alt
cls.key_ctrl = False if event == None else event.ctrl and not event.alt
cls.key_shift_ctrl = False if event == None else event.shift and cls.key_ctrl
cls.key_alt = False if event == None else not event.ctrl and event.alt
cls.key_shift_alt = False if event == None else event.shift and cls.key_alt
cls.key_ctrl_alt = False if event == None else event.ctrl and event.alt
cls.key_shift_ctrl_alt = False if event == None else event.shift and cls.key_ctrl_alt
cls.key_shift = False if event == None else event.shift
cls.key_shift_no_modifiers = False if event == None else event.shift and cls.key_no_modifiers
cls.key_toggle_pin_overlay = False if event == None else event.type == 'P' and event.value == 'PRESS'
cls.key_one = False if event == None else event.type == 'ONE' and event.value == 'PRESS'
cls.key_two = False if event == None else event.type == 'TWO' and event.value == 'PRESS'
cls.key_three = False if event == None else event.type == 'THREE' and event.value == 'PRESS'
cls.key_toggle_operator_passthrough = False if event == None else event.type == 'BACK_SLASH' and event.value == 'PRESS'
cls.key_toggle_mouse_values = False if event == None else event.type == 'Q' and event.value == 'PRESS'
cls.key_increase_factor = False if event == None else event.type in {'PLUS', 'EQUAL', 'NUMPAD_PLUS'} and event.value == 'PRESS'
cls.key_decrease_factor = False if event == None else event.type in {'MINUS', 'NUMPAD_MINUS'} and event.value == 'PRESS'

cls.key_step_up = False if event == None else event.type == 'WHEELUPMOUSE' or (
event.value == 'PRESS' and event.type == 'UP_ARROW') or (
event.value == 'PRESS' and event.type == 'RIGHT_ARROW') or (
event.value == 'PRESS' and event.type == 'D') or (
event.value == 'PRESS' and event.type == 'W')

cls.key_step_down = False if event == None else event.type == 'WHEELDOWNMOUSE' or (
event.value == 'PRESS' and event.type == 'DOWN_ARROW') or (
event.value == 'PRESS' and event.type == 'LEFT_ARROW') or (
event.value == 'PRESS' and event.type == 'A') or (
event.value == 'PRESS' and event.type == 'S')

cls.key_confirm = False if event == None else event.type == 'LEFTMOUSE'
cls.key_confirm_alternative = False if event == None else event.type == 'SPACE'
cls.key_cancel = False if event == None else event.type in {'RIGHTMOUSE', 'ESC'}

cls.key_movement_passthrough = False if event == None else event.type == 'MIDDLEMOUSE' or (
event.alt and event.type in {'LEFTMOUSE', 'RIGHTMOUSE'}) or event.type.startswith('NDOF')

0 comments on commit dbb30c9

Please sign in to comment.