Skip to content

Commit

Permalink
feat: wandering keyboard event
Browse files Browse the repository at this point in the history
  • Loading branch information
Yejining committed Feb 13, 2020
1 parent 3cc1be7 commit 07d7370
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion database/create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ CREATE TABLE `game` (
`right_pupil_diameter` double DEFAULT NULL,
`right_pupil_validity` int(11) DEFAULT NULL,
`average_pupil_diameter` double DEFAULT NULL,
`average_pupil_validity` int(11) DEFAULT NULL
`average_pupil_validity` int(11) DEFAULT NULL,
`is_wandering` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
6 changes: 6 additions & 0 deletions src/game/GameWindow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import sys

from PyQt5 import QtGui
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QMainWindow, QApplication

from gui.game import Ui_GameWindow
Expand Down Expand Up @@ -52,6 +54,10 @@ def on_finish(self):
self.deleteLater()
self.main.on_game_finish(data)

def keyPressEvent(self, event: QtGui.QKeyEvent):
if event.key() == Qt.Key_Space:
self.tobii.is_wandering = True

def start(self, status, page):
self.change_status(status)
self.change_page(page)
Expand Down
3 changes: 2 additions & 1 deletion src/input/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ def save(self, result, parser):
'card_width': width,
'card_height': height,
'card_horizontal_margin': horizontal_margin,
'card_vertical_margin': vertical_margin
'card_vertical_margin': vertical_margin,
'is_wandering': 1 if result.data[i].is_wandering else 0
}

dbconn.insert(table=dbconstant.TABLE, data=tuple)
Expand Down
1 change: 1 addition & 0 deletions src/tobii/GazeElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def __init__(self, raw_data):
self.left_pupil = Pupil(0, 0)
self.right_pupil = Pupil(0, 0)
self.average_pupil = Pupil(0, 0)
self.is_wandering = False

def initialize(self, screen_size):
self.screen_size.set(screen_size)
Expand Down
9 changes: 9 additions & 0 deletions src/tobii/tracker.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import tobii_research as tr
from PyQt5 import QtGui
from PyQt5.QtCore import Qt
from PyQt5.QtCore import QThread, pyqtSignal

from src.tobii.RawData import RawData
Expand All @@ -14,6 +16,7 @@ def __init__(self, GameWindow):
self.data = []
self.plot_thread = PlotThread(self.window)
self.plot_thread.signal.connect(self.on_plot)
self.is_wandering = False

def run(self):
self.tobii.subscribe_to(tr.EYETRACKER_GAZE_DATA, self.plot_thread.gaze_data_callback, as_dictionary=True)
Expand All @@ -26,7 +29,9 @@ def end(self):
return organize_data

def on_plot(self, element):
element.is_wandering = self.is_wandering
self.data.append(element)
self.is_wandering = False

# if self.data[-1].is_validate(constant.AVERAGE):
# self.paint.left = self.data.data[-1].left_point
Expand All @@ -51,5 +56,9 @@ def gaze_data_callback(self, gaze_data):
element = raw.gaze_data_callback(gaze_data)
self.signal.emit(element)

# def keyPressEvent(self, event: QtGui.QKeyEvent):
# if event.key() == Qt.Key_Space:
# print("pressed")



0 comments on commit 07d7370

Please sign in to comment.