Hard Light Productions Forums

Off-Topic Discussion => Programming => Topic started by: Bobboau on September 25, 2017, 11:39:33 pm

Title: Python raw input/keyboard polling
Post by: Bobboau on September 25, 2017, 11:39:33 pm
I'm working on a small personal project that requires python (something technically similar to this (https://www.youtube.com/watch?v=8HZFY4Xti7k)) and I would like to use raw unbuffered keybord input to control it.
What I would ideally like would be a method that returns a set of key codes for all keys being pressed on the system, (again ideally) redirects all keyboard input to it so it doesn't print to the terminal, and (while I'm making unreasonable demands) you can specify which keyboard on the system it will attach to.
This will be on a Raspberry pi (original model B) running the latest Raspian. There is no need to worry about portability.

any ideas? Python is not a language I have used much.
Title: Re: Python raw input/keyboard polling
Post by: AdmiralRalwood on September 26, 2017, 07:31:47 pm
What library are you using to handle input?
Title: Re: Python raw input/keyboard polling
Post by: Bobboau on September 26, 2017, 10:56:57 pm
Nothing at the momemt, so far I've just been focusing on the output, I've started looking into termios, but the main goal of this thread is figuring out what to use.
Title: Re: Python raw input/keyboard polling
Post by: AdmiralRalwood on September 28, 2017, 02:20:43 am
There are at least as many different ways to handle input in Python as there are libraries to choose from; usually you pick something that handles both input and output (e.g. pyglet), but you can probably find something solely for raw input if you want.
Title: Re: Python raw input/keyboard polling
Post by: Bobboau on October 04, 2017, 06:36:01 am
well this is going to be running in a headless environment, so output would be at best useless and at worse a source of failure. so that's why I have been avoiding all inclusive game apis.