@@ -201,6 +201,19 @@ def _simulate_eye_tracking_data(in_file, out_file):
201
201
"SAMPLES\t PUPIL\t LEFT\t VEL\t RES\t HTARGET\t RATE\t 1000.00"
202
202
"\t TRACKING\t CR\t FILTER\t 2\t INPUT"
203
203
)
204
+
205
+ # Define your known BUTTON events
206
+ button_events = [
207
+ (5488529 , 1 , 0 ),
208
+ (5488532 , 1 , 1 ),
209
+ (5488540 , 1 , 0 ),
210
+ (5488543 , 1 , 1 ),
211
+ (5488550 , 1 , 0 ),
212
+ (5488553 , 1 , 1 ),
213
+ (5488571 , 1 , 0 ),
214
+ ]
215
+ button_idx = 0
216
+
204
217
with out_file .open ("w" ) as fp :
205
218
in_recording_block = False
206
219
events = []
@@ -214,7 +227,7 @@ def _simulate_eye_tracking_data(in_file, out_file):
214
227
if event_type .isnumeric (): # samples
215
228
tokens [4 :4 ] = ["100" , "20" , "45" , "45" , "127.0" ] # vel, res, DIN
216
229
tokens .extend (["1497.0" , "5189.0" , "512.5" , "............." ])
217
- elif event_type in ("EFIX" , "ESACC" ):
230
+ elif event_type in ("EFIX" , "ESACC" , "BUTTON" ):
218
231
if event_type == "ESACC" :
219
232
tokens [5 :7 ] = ["." , "." ] # pretend start pos is unknown
220
233
tokens .extend (["45" , "45" ]) # resolution
@@ -224,6 +237,15 @@ def _simulate_eye_tracking_data(in_file, out_file):
224
237
tokens .append ("INPUT" )
225
238
elif event_type == "EBLINK" :
226
239
continue # simulate no blink events
240
+ elif event_type == "BUTTON" :
241
+ # simulate a button event
242
+ tokens [1 ] = "BUTTON" # simulate button press
243
+ tokens [2 ] = "1" # simulate button 1
244
+ tokens [3 ] = "1" # simulate button pressed
245
+ tokens [4 :4 ] = ["100" , "20" , "45" , "45" , "127.0" ]
246
+ tokens .extend (["1497.0" , "5189.0" , "512.5" , "............." ])
247
+
248
+ continue
227
249
elif event_type == "END" :
228
250
pass
229
251
else :
@@ -245,6 +267,18 @@ def _simulate_eye_tracking_data(in_file, out_file):
245
267
f"{ timestamp } \t -2434.0\t -1760.0\t 840.0\t 100\t 20\t 45\t 45\t 127.0\t "
246
268
"...\t 1497\t 5189\t 512.5\t .............\n "
247
269
)
270
+
271
+ for timestamp in np .arange (5488500 , 5488600 ): # 100 samples
272
+ # Write sample line
273
+ fp .write (
274
+ f"{ timestamp } \t -2434.0\t -1760.0\t 840.0\t 100\t 20\t 45\t 45\t 127.0\t "
275
+ "...\t 1497\t 5189\t 512.5\t .............\n "
276
+ )
277
+ # Check and insert button events at this timestamp
278
+ while button_idx < len (button_events ) and button_events [button_idx ][0 ] == timestamp :
279
+ t , btn_id , state = button_events [button_idx ]
280
+ fp .write (f"BUTTON\t { t } \t { btn_id } \t { state } \n " )
281
+ button_idx += 1
248
282
249
283
fp .write ("END\t 7453390\t RIGHT\t SAMPLES\t EVENTS\n " )
250
284
0 commit comments