Skip to content
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 toggle for cursor movement #21

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ docs/_build/
# PyBuilder
target/

# PyCharm
.idea/

# Jupyter Notebook
.ipynb_checkpoints

Expand Down
93 changes: 0 additions & 93 deletions CODE_OF_CONDUCT.md

This file was deleted.

29 changes: 0 additions & 29 deletions CONTRIBUTING

This file was deleted.

15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# How to Contribute

We'd love to accept your patches and contributions to this project. There are
just a few small guidelines you need to follow.

## Code Reviews

All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose. Consult
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
information on using pull requests.

## Community Guidelines

Be a decent human being, bot, or whatever.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Project Gameface
Project Gameface helps gamers control their mouse cursor using their head movement and facial gestures.
# Grimassist
Grimassist helps gamers control their mouse cursor using their head movement and facial gestures.



Expand Down
1 change: 1 addition & 0 deletions configs/default/cursor.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"tick_interval_ms": 16,
"hold_trigger_ms": 500,
"auto_play": false,
"enable": 1,
"mouse_acceleration": false,
"use_transformation_matrix": false
}
13 changes: 7 additions & 6 deletions configs/profile_1/cursor.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
"tracking_vert_idxs": [
8
],
"spd_up": 41,
"spd_down": 41,
"spd_left": 41,
"spd_right": 41,
"pointer_smooth": 15,
"spd_up": 40,
"spd_down": 40,
"spd_left": 40,
"spd_right": 40,
"pointer_smooth": 6,
"shape_smooth": 10,
"tick_interval_ms": 16,
"hold_trigger_ms": 500,
"auto_play": false,
"mouse_acceleration": false,
"enable": 1,
"mouse_acceleration": false,
"use_transformation_matrix": false
}
1 change: 1 addition & 0 deletions configs/profile_2/cursor.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"tick_interval_ms": 16,
"hold_trigger_ms": 500,
"auto_play": false,
"enable": 1,
"mouse_acceleration": false,
"use_transformation_matrix": false
}
14 changes: 0 additions & 14 deletions src/accel_graph.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import abc
import math

Expand Down
18 changes: 2 additions & 16 deletions src/camera_manager.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import concurrent.futures as futures
import logging
import threading
Expand All @@ -25,7 +11,7 @@

import src.utils as utils
from src.config_manager import ConfigManager
from src.controllers import MouseController
from src.controllers import Keybinder
from src.singleton_meta import Singleton

MAX_SEARCH_CAMS = 5
Expand Down Expand Up @@ -123,7 +109,7 @@ def draw_overlay(self, track_loc):
self.frame_buffers["debug"] = self.frame_buffers["raw"].copy()

# Disabled
if not MouseController().is_active.get():
if not Keybinder().is_active.get():
self.frame_buffers["debug"] = add_overlay(
self.frame_buffers["debug"], self.overlay_disabled, 0, 0, 640,
108)
Expand Down
14 changes: 0 additions & 14 deletions src/config_manager.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import copy
import json
import logging
Expand Down
13 changes: 0 additions & 13 deletions src/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from .keybinder import *
from .mouse_controller import *
33 changes: 17 additions & 16 deletions src/controllers/keybinder.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import copy
import logging
Expand All @@ -19,10 +6,10 @@

import pydirectinput
import win32api
import tkinter as tk

import src.shape_list as shape_list
from src.config_manager import ConfigManager
from src.controllers.mouse_controller import MouseController
from src.singleton_meta import Singleton

logger = logging.getLogger("Keybinder")
Expand All @@ -42,6 +29,7 @@ def __init__(self) -> None:
self.holding = False
self.is_started = False
self.last_know_keybinds = {}
self.is_active = None

def start(self):
if not self.is_started:
Expand All @@ -51,6 +39,9 @@ def start(self):
self.monitors = self.get_monitors()
self.is_started = True

self.is_active = tk.BooleanVar()
self.is_active.set(ConfigManager().config["auto_play"])

def init_states(self) -> None:
"""Re initializes the state of the keybinder.
If new keybinds are added.
Expand Down Expand Up @@ -177,13 +168,13 @@ def act(self, blendshape_values) -> dict:
if mon_id is None:
return

MouseController().toggle_active()
self.toggle_active()

self.key_states[state_name] = True
elif (val < thres) and (self.key_states[state_name] is True):
self.key_states[state_name] = False

elif MouseController().is_active.get():
elif self.is_active.get():

if device == "mouse":

Expand Down Expand Up @@ -223,6 +214,16 @@ def act(self, blendshape_values) -> dict:
elif device == "keyboard":
self.keyboard_action(val, action, thres, mode)

def set_active(self, flag: bool) -> None:
self.is_active.set(flag)
if flag:
self.delay_count = 0

def toggle_active(self):
logging.info("Toggle active")
curr_state = self.is_active.get()
self.set_active(not curr_state)

def destroy(self):
"""Destroy the keybinder"""
return
Loading