Skip to content

Commit 51c220a

Browse files
committed
added missing requests for the repeat interval
1 parent 130cbe7 commit 51c220a

3 files changed

Lines changed: 30 additions & 3 deletions

File tree

src/proto.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ enum {
8787
REQ_GCFG_GRAB, /* get device grabbing: R[0] state R[6] status */
8888
REQ_SCFG_SERDEV, /* set serial device path: Q[0-5] next 24 bytes Q[6] remaining length - R[6] status */
8989
REQ_GCFG_SERDEV, /* get serial device path: R[0-5] next 24 bytes R[6] remaining length or -1 for failure */
90+
REQ_SCFG_REPEAT, /* set repeat interval: Q[0] interval (msec) - R[6] status */
91+
REQ_GCFG_REPEAT, /* get repeat interval: R[0] interval (msec) R[6] status */
9092
/* TODO ... more */
9193
REQ_CFG_SAVE = 0x3ffe, /* save config file: R[6] status */
9294
REQ_CFG_RESTORE, /* load config from file: R[6] status */
@@ -174,7 +176,9 @@ const char *spnav_reqnames_3000[] = {
174176
"SCFG_GRAB",
175177
"GCFG_GRAB",
176178
"SCFG_SERDEV",
177-
"GCFG_SERDEV"
179+
"GCFG_SERDEV",
180+
"SCFG_REPEAT",
181+
"GCFG_REPEAT"
178182
};
179183

180184
const int spnav_reqnames_1000_size = sizeof spnav_reqnames_1000 / sizeof *spnav_reqnames_1000;

src/spnav.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of libspnav, part of the spacenav project (spacenav.sf.net)
3-
Copyright (C) 2007-2022 John Tsiombikas <nuclear@member.fsf.org>
3+
Copyright (C) 2007-2023 John Tsiombikas <nuclear@member.fsf.org>
44
55
Redistribution and use in source and binary forms, with or without
66
modification, are permitted provided that the following conditions are met:
@@ -1094,3 +1094,23 @@ int spnav_cfg_get_serial(char *buf, int bufsz)
10941094
{
10951095
return request_str(REQ_GCFG_SERDEV, buf, bufsz, TIMEOUT);
10961096
}
1097+
1098+
int spnav_cfg_set_repeat(int msec)
1099+
{
1100+
struct reqresp rr = {0};
1101+
1102+
if(msec < 0) msec = -1;
1103+
1104+
rr.data[0] = msec;
1105+
return request(REQ_SCFG_REPEAT, &rr, TIMEOUT);
1106+
}
1107+
1108+
int spnav_cfg_get_repeat(void)
1109+
{
1110+
struct reqresp rr = {0};
1111+
1112+
if(request(REQ_GCFG_REPEAT, &rr, TIMEOUT) == -1) {
1113+
return -1;
1114+
}
1115+
return rr.data[0];
1116+
}

src/spnav.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of libspnav, part of the spacenav project (spacenav.sf.net)
3-
Copyright (C) 2007-2022 John Tsiombikas <nuclear@member.fsf.org>
3+
Copyright (C) 2007-2023 John Tsiombikas <nuclear@member.fsf.org>
44
55
Redistribution and use in source and binary forms, with or without
66
modification, are permitted provided that the following conditions are met:
@@ -376,6 +376,9 @@ int spnav_cfg_get_grab(void); /* returns 0:no-grab/1:grab, or -1 on error */
376376
int spnav_cfg_set_serial(const char *devpath);
377377
int spnav_cfg_get_serial(char *buf, int bufsz);
378378

379+
int spnav_cfg_set_repeat(int msec);
380+
int spnav_cfg_get_repeat(void);
381+
379382
#ifdef __cplusplus
380383
}
381384
#endif

0 commit comments

Comments
 (0)