added cfg_swapyz support

pull/15/head
John Tsiombikas 2022-03-22 11:46:45 +02:00
rodzic 75aea89e55
commit 39de17356a
3 zmienionych plików z 28 dodań i 1 usunięć

Wyświetl plik

@ -63,6 +63,8 @@ enum {
REQ_GCFG_BNACTION, /* get button action: Q[0] bidx - R[0] bidx R[1] action R[6] status */
REQ_SCFG_KBMAP, /* set keyboard mapping: Q[0] bidx Q[1] keysym - R[6] status */
REQ_GCFG_KBMAP, /* get keyboard mapping: Q[0] bidx - R[0] bidx R[1] keysym R[6] status */
REQ_SCFG_SWAPYZ, /* set Y-Z axis swap: Q[0] swap - R[6] status */
REQ_GCFG_SWAPYZ, /* get Y-Z axis swap: R[0] swap R[6] status */
REQ_SCFG_LED, /* set LED state: Q[0] state - R[6] status */
REQ_GCFG_LED, /* get LED state: R[0] state R[6] status */
REQ_SCFG_GRAB, /* set device grabbing: Q[0] state - R[6] status */

24
spnav.c
Wyświetl plik

@ -50,6 +50,9 @@ OF SUCH DAMAGE.
static Window get_daemon_window(Display *dpy);
static int catch_badwin(Display *dpy, XErrorEvent *err);
static int read_event(int s, spnav_event *event);
static int proc_event(int *data, spnav_event *event);
static int wait_resp(void *buf, int sz, int timeout_ms);
static int request(int req, struct reqresp *rr, int timeout_ms);
@ -363,7 +366,7 @@ static int event_pending(int s)
*/
static int read_event(int s, spnav_event *event)
{
int i, rd;
int rd;
int data[8];
/* if we have a queued event, deliver that one */
@ -395,6 +398,8 @@ static int read_event(int s, spnav_event *event)
static int proc_event(int *data, spnav_event *event)
{
int i;
if(data[0] < 0 || data[0] >= MAX_UEV) {
return 0;
}
@ -993,6 +998,23 @@ int spnav_cfg_get_kbmap(int bn)
return rr.data[1];
}
int spnav_cfg_set_swapyz(int swap)
{
struct reqresp rr = {0};
rr.data[0] = swap;
return request(REQ_SCFG_SWAPYZ, &rr, TIMEOUT);
}
int spnav_cfg_get_swapyz(void)
{
struct reqresp rr = {0};
if(request(REQ_GCFG_SWAPYZ, &rr, TIMEOUT) == -1) {
return -1;
}
return rr.data[0];
}
int spnav_cfg_set_led(int state)
{

Wyświetl plik

@ -310,6 +310,9 @@ int spnav_cfg_get_bnaction(int bn);
int spnav_cfg_set_kbmap(int bn, int key);
int spnav_cfg_get_kbmap(int bn);
int spnav_cfg_set_swapyz(int swap);
int spnav_cfg_get_swapyz(void);
/* Control device LED
* SPNAV_CFG_LED_OFF | SPNAV_CFG_LED_ON | SPNAV_CFG_LED_AUTO
* cfgfile option: led