All these start with KEY_ to differentiate between the regular remappable controls (like Input::L)
They are considered "separate" keys, so when you press W on a QWERTY keyboard with default mappings, both Input::R and Input::KEY_W would count as pressed
Note some of these keys might not work the way you expect, be careful when using them and ask me or test ingame before using, for example:
There is no KEY_SHIFT, you should check for KEY_LSHIFT and KEY_RSHIFT separately. Same with ctrl or shift.
Keys like KEY_ASTERISK don't work. On a traditional QWERTY keyboard, check for LSHIFT being held and the 8 key being pressed instead.
Keys like KEY_F1 that have special meaning in ModShot may not work properly
The KEY_EXECUTE key has been removed because Windows is using that name for something else (thanks microsoft), fortunately 99% of keyboards don't even have this key
Input.press? and Input.trigger? now work on all KEY_ keys
Input.repeat? will always return false (let me know if you want to change this behavior)
Added Input.modkeys, which returns an integer representing the status of modifier keys (ctrl, shift, windows key, etc)
# Note the `!= 0` is needed, ruby doesn't autocast ints to bools and it does super weird stuff
if Input.modkeys & Input::CTRL != 0 and Input.modkeys & Input::ALT != 0 and Input.press?(Input::KEY_T)
puts "Ctrl+Alt+T pressed!"
end
Added ability to get text input
Use the Input::start_text_input function to start reading input. It takes the maximum input size as an optional argument (4096 if not specified).
During text input mode, all normal keypresses are NOT intercepted (e.g. when you press 'Z' you would still trigger Input::Action, you should make sure your code can handle that.
After that, the Input::text_input function returns a UTF-8 string, representing the current input since you called start_text_input.
If backspace is pressed, a character is automatically deleted from this
It should also automatically handle Unicode stuff, along with capitalization and other oddities
It does NOT handle newlines, you should check for the Enter key manually if you want to stop the input after a newline
It does NOT handle rendering the text, it's up to you to read the text every frame and update your graphics accordingly
Finally when you are done with it, call Input.stop_text_input to clean up.
This PR adds the following to the
Input
module:KEY_
to differentiate between the regular remappable controls (likeInput::L
)W
on a QWERTY keyboard with default mappings, bothInput::R
andInput::KEY_W
would count as pressedKEY_SHIFT
, you should check forKEY_LSHIFT
andKEY_RSHIFT
separately. Same with ctrl or shift.KEY_ASTERISK
don't work. On a traditional QWERTY keyboard, check forLSHIFT
being held and the8
key being pressed instead.KEY_F1
that have special meaning in ModShot may not work properlyKEY_EXECUTE
key has been removed because Windows is using that name for something else (thanks microsoft), fortunately 99% of keyboards don't even have this keyInput.press?
andInput.trigger?
now work on allKEY_
keysInput.repeat?
will always return false (let me know if you want to change this behavior)Input.modkeys
, which returns an integer representing the status of modifier keys (ctrl, shift, windows key, etc)Input::start_text_input
function to start reading input. It takes the maximum input size as an optional argument (4096 if not specified).Input::Action
, you should make sure your code can handle that.Input::text_input
function returns a UTF-8 string, representing the current input since you calledstart_text_input
.Enter
key manually if you want to stop the input after a newlineInput.stop_text_input
to clean up.