push layer key

Official forum for open source FreePIE discussion and development.
Post Reply
fland
One Eyed Hopeful
Posts: 3
Joined: Fri May 19, 2017 5:38 am

push layer key

Post by fland »

Hi, I have some scripts in glovepie that I use a lot and I would like to replicate them in freepie but I need help with the syntax,

The first example: Two variables, the first one is active but pressing a key activates the second

With glovepie would be:

if Pressed(key.a){
say("a")
}
if Pressed(key.b){
say("b")
}
if Pressed(key.c){
say("c")
}
if Pressed(key.d){
say("d")
}

if starting{
var.layout1=1
var.layout2=0
}
if var.layout1{
key.a=key.1
key.b=key.2
}
if var.layout2{
key.c=key.1
key.d=key.2
}
if pressed (key.3){
var.layout1=0
var.layout2=1
}
if released (key.3){
var.layout1=1
var.layout2=0
}

Thank you
fland
One Eyed Hopeful
Posts: 3
Joined: Fri May 19, 2017 5:38 am

Re: push layer key

Post by fland »

First question solved:

if starting:
mode = "layout1"

if (mode == "layout1"):
if keyboard.getPressed(Key.D1):
keyboard.setPressed(Key.A)
speech.say("a")
if keyboard.getPressed(Key.D2):
keyboard.setPressed(Key.B)
speech.say("b")

if (mode == "layout2"):
if keyboard.getPressed(Key.D1):
keyboard.setPressed(Key.C)
speech.say("c")
if keyboard.getPressed(Key.D2):
keyboard.setPressed(Key.D)
speech.say("d")

if keyboard.getKeyDown(Key.D3):
mode = "layout2"
else:
mode = "layout1"

diagnostics.watch(mode)




The second question, I need to use the layer push key to launch commands with doubleclick. I've been investigating for days but I can not get it :(


Glovepie example:
if doubleclicked (Key.3)then
say("e")
endif

please help me with this
fland
One Eyed Hopeful
Posts: 3
Joined: Fri May 19, 2017 5:38 am

Re: push layer key

Post by fland »

I have found the way but it does not work as it should:

from System.Timers import Timer
import time

def update(s, e):
global counter
diagnostics.debug("Pressing key " + str(counter))
counter = 0
t.Stop()

if starting:
t = Timer(250)
t.Elapsed += update
counter = 0

if stopping:
cancel()

def cancel():
diagnostics.debug("canceling")
t.Stop()

if keyboard.getPressed(Key.D3):
t.Stop()
counter = counter + 1
t.Start()

if counter == 2:
speech.say("e")
keyboard.setKeyDown(Key.E)
time.sleep(0.1);
keyboard.setKeyUp(Key.E)

if counter == 3:
speech.say("f")
keyboard.setKeyDown(Key.F)
time.sleep(0.1);
keyboard.setKeyUp(Key.F)


in this way when triple-click action is launched also execute the double-click command.

HELP please
Post Reply

Return to “FreePIE”