diff --git a/database/create.sql b/database/create.sql index a552a78..d93f456 100644 --- a/database/create.sql +++ b/database/create.sql @@ -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; \ No newline at end of file diff --git a/src/game/GameWindow.py b/src/game/GameWindow.py index 4db2279..7fe26a7 100644 --- a/src/game/GameWindow.py +++ b/src/game/GameWindow.py @@ -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 @@ -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) diff --git a/src/input/database.py b/src/input/database.py index 2d85e19..98c7ca0 100644 --- a/src/input/database.py +++ b/src/input/database.py @@ -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) diff --git a/src/tobii/GazeElement.py b/src/tobii/GazeElement.py index 03b330d..c4cd464 100644 --- a/src/tobii/GazeElement.py +++ b/src/tobii/GazeElement.py @@ -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) diff --git a/src/tobii/tracker.py b/src/tobii/tracker.py index f0e2073..81ddec7 100644 --- a/src/tobii/tracker.py +++ b/src/tobii/tracker.py @@ -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 @@ -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) @@ -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 @@ -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") +