AndersMalmgren / FreePIE

Programmable Input Emulator
650 stars 144 forks source link

add indexer to keyboard plugin to allow easier script syntax #138

Closed drowhunter closed 1 month ago

drowhunter commented 6 years ago

example: keyboard[Key.W] = xbox360[0].y bIsPressed = keyboard[Key.B]

drowhunter commented 6 years ago

only issue with this is that the intellisense doesn't work for these indexers, but the scripting is so much nicer

AndersMalmgren commented 6 years ago

Another issue is that its not clear which funtction you get since we have three

keyboard.getKeyDown
keyboard.getKeyUp
keyboard.getPressed

I dont really see the problem using get/set methods for the keyboard?

drowhunter commented 6 years ago

not a big deal. but i find the naming of the setter/getters for the keypesses confusing

setpressed sounds like you are setting the key down. it doesn't imply that the key is released immediately after.

most buttons are either pressed or not. which means they are natural booleans

the setpressed should be called "tap"

once you get used to the idea that buttons are bools its really easy to bind the states of various inputs to outputs using logical operators

eg keyboard [Key.A] = xbox360 [0].a && xbox360 [0].b means that keyboard a is true when 360 a and b are pressed

do you see where im going with this? i think this syntax would be nice if it extended beyond just this plugin and was used globally (such as the joystick and others too..not a minor change i know)

anyways this was just a suggestion...no big deal

AndersMalmgren commented 6 years ago

we could mark them as deprecated and add new tap methods. Then remove the old ones after a year or so. While routing button down states is not a uncommon use case sending taps are not uncommon either so it needs to work well for both. Which I think the get/set system does.

drowhunter commented 6 years ago

yes i agree tap is very common

eg needing to send a complete keypress on release of a button or voice command.

i think its just the naming that i dont like

perhaps instead if getpressed, which sounds like get me the keys that are pressed . We could call it wasReleased() which implies that the key was previously pressed but currently isnt

and set

drowhunter commented 6 years ago

on the topic of keyboard plugin improvement i had an idea to add a toggle function.

internally it would just do

keyboard [Key.L] =!keyboard[Key.L]