diff --git a/src/proto.h b/src/proto.h index 7efa85e..15fdc70 100644 --- a/src/proto.h +++ b/src/proto.h @@ -87,6 +87,8 @@ enum { REQ_GCFG_GRAB, /* get device grabbing: R[0] state R[6] status */ REQ_SCFG_SERDEV, /* set serial device path: Q[0-5] next 24 bytes Q[6] remaining length - R[6] status */ REQ_GCFG_SERDEV, /* get serial device path: R[0-5] next 24 bytes R[6] remaining length or -1 for failure */ + REQ_SCFG_REPEAT, /* set repeat interval: Q[0] interval (msec) - R[6] status */ + REQ_GCFG_REPEAT, /* get repeat interval: R[0] interval (msec) R[6] status */ /* TODO ... more */ REQ_CFG_SAVE = 0x3ffe, /* save config file: R[6] status */ REQ_CFG_RESTORE, /* load config from file: R[6] status */ @@ -174,7 +176,9 @@ const char *spnav_reqnames_3000[] = { "SCFG_GRAB", "GCFG_GRAB", "SCFG_SERDEV", - "GCFG_SERDEV" + "GCFG_SERDEV", + "SCFG_REPEAT", + "GCFG_REPEAT" }; const int spnav_reqnames_1000_size = sizeof spnav_reqnames_1000 / sizeof *spnav_reqnames_1000; diff --git a/src/spnav.c b/src/spnav.c index 9c5c511..d48b625 100644 --- a/src/spnav.c +++ b/src/spnav.c @@ -1,6 +1,6 @@ /* This file is part of libspnav, part of the spacenav project (spacenav.sf.net) -Copyright (C) 2007-2022 John Tsiombikas +Copyright (C) 2007-2023 John Tsiombikas Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -1094,3 +1094,23 @@ int spnav_cfg_get_serial(char *buf, int bufsz) { return request_str(REQ_GCFG_SERDEV, buf, bufsz, TIMEOUT); } + +int spnav_cfg_set_repeat(int msec) +{ + struct reqresp rr = {0}; + + if(msec < 0) msec = -1; + + rr.data[0] = msec; + return request(REQ_SCFG_REPEAT, &rr, TIMEOUT); +} + +int spnav_cfg_get_repeat(void) +{ + struct reqresp rr = {0}; + + if(request(REQ_GCFG_REPEAT, &rr, TIMEOUT) == -1) { + return -1; + } + return rr.data[0]; +} diff --git a/src/spnav.h b/src/spnav.h index 7115fc4..8c501e7 100644 --- a/src/spnav.h +++ b/src/spnav.h @@ -1,6 +1,6 @@ /* This file is part of libspnav, part of the spacenav project (spacenav.sf.net) -Copyright (C) 2007-2022 John Tsiombikas +Copyright (C) 2007-2023 John Tsiombikas Redistribution and use in source and binary forms, with or without 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 */ int spnav_cfg_set_serial(const char *devpath); int spnav_cfg_get_serial(char *buf, int bufsz); +int spnav_cfg_set_repeat(int msec); +int spnav_cfg_get_repeat(void); + #ifdef __cplusplus } #endif