-
Notifications
You must be signed in to change notification settings - Fork 146
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
Add New Function GetReleased #55
base: master
Are you sure you want to change the base?
Conversation
Adding new functionality for Released key like the GetPressed key
Update for GetReleased
Update for GetReleased
Should I not take a look at this code? |
HI Anders, i am loacket at home after a broken leg so i take time to understand FreePie and C#!! i have closed the pullrequest but i have reopened it
so a problem exist because you are using dict to save last state key, stickbutton ... but during the same frame if you do 2 tests of getPressed if Keyboard.getPressed(Key.S): when the first test is ok, so if we are using variable to stock state there is no problem maybe it will be better to use OldBuffer to stock laststate and Buffer to stock current state m_KeyboardStateLast = m_KeyboardStateCurrent; ans same for stick and mouse but that needs some change in source code.. i have reanimed the pull if you want to see.. another modification is arriving getHeldDown(key, lapse): true when key down during lapse and a list of functions Regards ----- Mail original ----- De: "Anders Malmgren" [email protected] Should I not take a look at this code? |
Yes I know, I'm not the orginal author of the code, and I have not had time to rewrite it. What it should do is to check state only once per iteration of the script. This could be done similar to the SetPressedStretegy, having a method that triggers each iteration and clears the state |
Its okay, i have time to rewrite the code and fix that thierry ----- Mail original ----- De: "Anders Malmgren" [email protected] Yes I know, I'm not the orginal author of the code, and I have not had time to rewrite it. What it should do is to check state only once per iteration of the script. This could be done similar to the SetPressedStretegy, haveing a method that triggers each iteration and cleares the state |
Ouch, not nice with broken leg, but nice to learn C# :D I'm looking at fixing so that you can inject a IScriptContext and listen to when the script loop is updating. That way you do not need to forward the state from the plugin etc |
btw, held down could be achived by doing if filters.stopWatch(keyboard.getKeyDown(Key.A), 5000):
diagnostics.debug("Key pressedn for 5 seconds") |
ist okay but my helddown function will be slighty different it accepts to test more timer different for same key or button if filters. stopWatch (keyboard. getKeyDown (Key.D), 2000 ): if filters. stopWatch (keyboard. getKeyDown (Key.D), 4000 ): so this coding is not functional with that! i know, in French we say "i am looking after the small beast" but no problem.. ----- Mail original ----- De: "Anders Malmgren" [email protected] btw, held down could be achived by doing |
Hmm, the NeedIndexer part uses the whole argument as indexer, so it should work, whats the outcome? Btw, the NeedIndexer part of FreePIE is not 100% bulletproof too, I got a thread going about it here http://stackoverflow.com/questions/30682752/iterate-the-ast edit: I tried this script if filters.stopWatch(keyboard.getKeyDown(Key.D), 2000):
diagnostics.debug("Key pressedn for 2 seconds")
if filters.stopWatch(keyboard.getKeyDown(Key.D), 4000):
diagnostics.debug("Key pressedn for 4 seconds") And it correctly fires the two at correct times |
Hi, 3 questions please for stick which have poor number of button its interesting to have multiple configuration so the code (nevermind of the function) If (released(key C held during 2sec) then conf=1 but it s interesting to have a signal to valid the new conf Beep(Frequency, timelapse) is interesting If (released(key C held during 2sec) then conf=1 ; Beep(500, 500) so we have diff tonality following the conf. the problem is : the fonction beep (from import winsound) so Beep(500, 2000) make a bi during 2 second and the program is stopped during this lapse. the solution: is it possible to use thread possibility to launch BeepFunction in another thread C# when this function is called from python script (example FreePie.Bip function) ? in C++ i know to do that but i dont know how to implement this in C# is it possible to have global variable FreePie.FrameCount, FreePie.FrameRate, or FreePie.Interval to modify the FrameRate of the program
----- Mail original ----- De: "Anders Malmgren" [email protected] ah, thats an easy fix though. the code need to include the milliseconds in the indexer
— |
if starting:
system.setThreadTiming(TimingTypes.HighresSystemTimer)
system.threadExecutionInterval = 2 This will select the HIghres system timer stategy and set the sleep between script iterations to 2 ms
if starting:
ticks = 0
ticks += 1 |
Hi Anders, New file Added: FreePIE.Core.Plugins\Strategies\GetHeldDownStrategy.cs contains all functions needed for getHeldDown and getPressedHeldDown The file FreePIE.Core.Plugins\Strategies\GetPressedStrategy.cs is now just used by WiiMote, Keyboard, joystick and mouse dont use it now Files about devices modified New functions: getHeldDown, getPressedHeldDown far all devices (excepted wiimote)
File modified New function: speech.beep(frequency, duration) |
Sorry I cant pull this code, it breakes too many code conventions that we have. But I will see what i can take and what not. Thanks |
No problem Anders, i understand that.. i am not expert in dev and i understand you have some rules to respect ----- Mail original ----- De: "Anders Malmgren" [email protected] Sorry I cant pull this code, it breakes too many code conventions that we have. But I will see what i can take and what not. Thanks |
I'm working on a new mechanis for script state, it can be used like this, sorry I screwed up tab/space somehow, will have to fix that |
I'm trying to understand a bit more the code for |
hi josé,
the function is not directly in the plugin because this function could be used for lot of plugin.., to keep the same logic
fyi i am working on new release of freepie to include new function and new plugin
https://github.com/Frenchy62620/NewFreepie
regards
Thierry
De: "José María Riego" <[email protected]>
À: "AndersMalmgren/FreePIE" <[email protected]>
Cc: "tkiel" <[email protected]>, "State change" <[email protected]>
Envoyé: Mardi 8 Janvier 2019 12:22:53
Objet: Re: [AndersMalmgren/FreePIE] Add New Function GetReleased (#55)
I'm trying to understand a bit more the code for GetPressedStrategy . What is the purpose of it and why not having the getPressed function directly in the plugins? I'm trying to figure out the best way to add the functionality that this pull request is trying to add
—
You are receiving this because you modified the open/close state.
Reply to this email directly, [ #55 (comment) | view it on GitHub ] , or [ https://github.com/notifications/unsubscribe-auth/AE8729ax8GJSw5RDr7f9XNLOOFwcuatuks5vBH-NgaJpZM4E5p_3 | mute the thread ] .
|
That makes sense. Good luck with the project and thanks a lot for your help! |
Hi Anders, sorry ist the first time i am using github, that seems a good tool for sharing project..!!
i am not expert in C# but i have unsderstood some tips from your program.. and so i propose an addon
maybe its more clever to have only one class in strategy folder (fusion with GetPressed and getrelease strategy file and create one class with 2 method isPressed and isReleased)
like the function Getpressed
state before: key is Down and State current: key is UP = Key is Released
state before: key is UP and State current: key is DOWN = Key is Pressed
so the Python script is functional:
if keyboard.getPressed(Key.S):
diagnostics.debug("key pressed")
if keyboard.getReleased(Key.S):
diagnostics.debug("key released")
if joystick[1].getPressed(0):
diagnostics.debug("joy button pressed")
if joystick[1].getReleased(0):
diagnostics.debug("joy button released")
if mouse.getPressed(0):
diagnostics.debug("mouse button pressed")
if mouse.getReleased(0):
diagnostics.debug("mouse button released")