Skip to content

Commit

Permalink
Mouse clicks and double clicks
Browse files Browse the repository at this point in the history
  • Loading branch information
Timo Aho committed Nov 5, 2015
1 parent 4f6877d commit 4ed4e7d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 38 deletions.
38 changes: 19 additions & 19 deletions client/etc/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,30 @@ timeout: 2000
actions:
mouse1Down:
type: 'mouse'
action: 'hold'
action: 'down'
target: 'left'
feedback:
audio: 'asset/audio/mousedown.ogg'
mouse1Up:
type: 'mouse'
action: 'release'
action: 'up'
target: 'left'
feedback:
audio: 'asset/audio/mouseup.ogg'
mouse2Down:
type: 'mouse'
action: 'hold'
action: 'down'
target: 'right'
feedback:
audio: 'asset/audio/mousedown.ogg'
mouse2Up:
type: 'mouse'
action: 'release'
action: 'up'
target: 'right'
mouse2Click:
type: 'mouse'
action: 'click'
target: 'right'
feedback:
audio: 'asset/audio/mouseup.ogg'
audio: 'asset/audio/mallet.ogg'
mouseMove:
type: 'mouse'
action: 'move'
Expand All @@ -40,15 +42,15 @@ signs:
freeHand:
grab:
max: 0.4
peaceHeld:
extendedFingers:
indexFinger: true
middleFinger: true
ringFinger: false
pinky: false
minTime: 2000000
feedback:
audio: 'asset/audio/mallet.ogg'
# peaceHeld:
# extendedFingers:
# indexFinger: true
# middleFinger: true
# ringFinger: false
# pinky: false
# minTime: 2000000
# feedback:
# audio: 'asset/audio/mallet.ogg'
# surpriseHand:
# grab:
# max: 0.4
Expand All @@ -66,9 +68,7 @@ recipes:
- 'pinchIndex'
action: 'mouse1Down'
tearDown: 'mouse1Up'
#tearDownDelay: 2000
mouseButton2:
signs:
- 'pinchRing'
action: 'mouse2Down'
tearDown: 'mouse2Up'
action: 'mouse2Click'
42 changes: 23 additions & 19 deletions client/src/ActionController.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -44,35 +44,35 @@ class ActionController
@robot.moveMouse(moveTo.x, moveTo.y)

# down: up|down, button: left|right
mouseButton: (buttonState, button) =>
mouseButton: (buttonAction, button) =>
feedback = window.feedback
if(buttonState == 'up')
@robot.mouseToggle buttonState, button
#if(@mouseState.button != buttonState)
#window.feedback.audioNotification 'asset/audio/mouseup.ogg'
else if(buttonState == 'down')
if(@mouseState.button != buttonState)
@robot.mouseToggle buttonState, button
#window.feedback.audioNotification 'asset/audio/mousedown.ogg'
window.feedback.mouseStatus button, buttonState
@mouseState.button = buttonState
if(buttonAction == 'up')
@robot.mouseToggle buttonAction, button
@mouseState[button] = 'up'
else if(buttonAction == 'down')
if(@mouseState.button != buttonAction)
@robot.mouseToggle buttonAction, button
@mouseState[button] = 'down'
else if(buttonAction == 'click')
@robot.mouseClick button, false
@mouseState[button] = 'up'
else if(buttonAction == 'doubleClick')
@robot.mouseClick button, true
@mouseState[button] = 'up'
#window.feedback.mouseStatus button, @mouseState[button] # This shouldn't be here..

executeAction: (action) =>
#console.log "Execute action: ", action
console.log "Execute action: ", action
cmd = @actions[action]
#console.log "cmd: ", cmd
console.log "cmd: ", cmd

if(cmd.feedback)
if(cmd.feedback.audio)
window.feedback.audioNotification cmd.feedback.audio

if(cmd.type == 'mouse')
if(cmd.action == 'hold')
button = cmd.target
@mouseButton 'down', button
if(cmd.action == 'release')
button = cmd.target
@mouseButton 'up', button
if(cmd.action in ['up', 'down', 'click', 'doubleClick'])
@mouseButton cmd.action, cmd.target
if(cmd.action == 'move')
@mouseMove(@position)
if(cmd.type == 'keyboardTest')
Expand All @@ -97,7 +97,11 @@ class ActionController
tearDownRecipe: (recipeName) =>
recipe = @recipes[recipeName]
actionName = recipe.tearDown

# Apathy!
if(!actionName)
@recipeState[recipeName].status = 'inactive'
@recipeState[recipeName].timerID = null
return false
if(@recipeState[recipeName].status == 'active')
if(!@recipeState[recipeName].timerID)
Expand Down
1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"dependencies": {
"coffee-script": "~1.10.0",
"gutil": "^1.6.4",
"leapjs": "~0.6.4",
"yamljs": "^0.2.4",
"zmq": "^2.13.0"
Expand Down

0 comments on commit 4ed4e7d

Please sign in to comment.