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

Tune up for using under Linux (possible by WA) #8

Closed
Edios opened this issue Jan 16, 2023 · 5 comments
Closed

Tune up for using under Linux (possible by WA) #8

Edios opened this issue Jan 16, 2023 · 5 comments
Labels
backlog bug Something isn't working

Comments

@Edios
Copy link
Owner

Edios commented Jan 16, 2023

Is your feature request related to a problem? Please describe.
Keyboard module have issue which cant suppress button events on Linux. This feature need to be implemented to add WA for Linux.

Describe the solution you'd like
Determine os. If linux - use WA method with deleting typed numpad character else use suppress method in keyboard module.

Describe alternatives you've considered
Use only windows envirorment

@Edios
Copy link
Owner Author

Edios commented Jan 16, 2023

boppreh/keyboard#22

@Edios
Copy link
Owner Author

Edios commented Jan 16, 2023

Consider switching to pynput:

Stackoverflow urls:
Suppressing keyboard input
Detecting if thats a numpad key

Solution based on them:
`from pynput import keyboard

def keyboard_listener():
global key
global keyboard_listener

def on_press(key):
    if hasattr(key, 'vk') and 96 <= key.vk <= 105:
        print('You entered a number from the numpad: ', key.char)
    else:
        print('normal key', key)

def on_release(key):
    print('on release', key)
    if key == keyboard.Key.esc:
        return False

def win32_event_filter(msg, data):
    #if(msg == 257 or msg == 256) and (data.vkCode == 38 or data.vkCode == 40):
    if hasattr(data, 'vkCode') and 96 <= data.vkCode <= 105:
        listener._suppress = True
    else:
        listener._suppress = False
    return True

#it suppress only numpad
return  keyboard.Listener(
    on_press=on_press,
    on_release=on_release,
    win32_event_filter=win32_event_filter,
    suppress=True
)`

listener = keyboard_listener()

if name== "main":
with listener as ml:
ml.join()

@Edios
Copy link
Owner Author

Edios commented Jan 21, 2023

Pynput will probably fix issue with systems differentiation- it would not be needed.
This is PR for this: Input / output engine

@Edios
Copy link
Owner Author

Edios commented Jan 21, 2023

Failed - Same code do not work on Linux: Different vk Linux vs Windows

@Edios Edios added bug Something isn't working backlog labels Jan 21, 2023
@Edios Edios changed the title Determine Linux and Windows envirorment Tune up for using under Linux (if that is even possible) Jan 21, 2023
@Edios
Copy link
Owner Author

Edios commented Jan 21, 2023

Pynput will probably fix issue with systems differentiation- it would not be needed. This is PR for this: Input / output engine

For now Windows will be treated as main envirorment.
Tuning up for linux is low priority task. Could be done by switching back to keyboard module (detecting key strokes) and WA for supressing with backspace.

@Edios Edios closed this as completed Jan 21, 2023
@Edios Edios changed the title Tune up for using under Linux (if that is even possible) Tune up for using under Linux (possible by WA) Jan 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant