-
Notifications
You must be signed in to change notification settings - Fork 1
/
mouse.c
76 lines (65 loc) · 2.21 KB
/
mouse.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <stdio.h>
#include <stdlib.h>
#include <iup.h>
Ihandle *IupQuakeSetToggle(char *title, char *key, char *val1, char *val2, int checked)
{
Ihandle *tmp = IupToggle(title, "ACTION");
IupStoreAttribute(tmp, "VALUE", (checked ? "ON" : "OFF"));
return tmp;
}
int IupQuakeScaleUpdate(Ihandle *ih)
{
char buf[16];
Ihandle *label_value = IupGetChild(IupGetChild(IupGetParent(ih), 1), 1);
snprintf(buf, 16, "%.1f", atof(IupGetAttribute(ih, "VALUE")));
IupStoreAttribute(label_value, "TITLE", buf);
}
Ihandle *IupQuakeScale(char *title, float min, float max, float step, char *key, float def)
{
Ihandle *scale,*label_value,*label_min,*label_max;
char buf[128];
scale = IupVal("HORIZONTAL");
snprintf(buf, 128, "EXPAND=HORIZONTAL, MIN=%.1f, MAX=%.1f, VALUE=%.1f, STEP=0.01", min, max, def);
IupSetAttributes(scale, buf);
IupSetCallback(scale, "VALUECHANGED_CB", (Icallback)IupQuakeScaleUpdate);
snprintf(buf, 16, "%.1f", def);
label_value = IupLabel(buf);
IupStoreAttribute(label_value, "EXPAND", "HORIZONTAL");
IupStoreAttribute(label_value, "ALIGNMENT", "ACENTER:ACENTER");
snprintf(buf, 16, "%.1f", min);
label_min = IupLabel(buf);
IupStoreAttribute(label_min, "ALIGNMENT", "ACENTER:ACENTER");
snprintf(buf, 16, "%.1f", max);
label_max = IupLabel(buf);
IupStoreAttribute(label_max, "ALIGNMENT", "ACENTER:ACENTER");
return IupVbox(
IupLabel(title),
IupHbox(
label_min,
label_value,
label_max,
NULL
),
scale,
NULL
);
}
Ihandle *IupQuakeMouseLayout()
{
Ihandle *tab;
tab = IupSetAttributes(
IupHbox(
IupVbox(
IupQuakeSetToggle("Reverse mouse", "m_pitch", "-0.022", "0.022", 0),
IupQuakeSetToggle("Use automatic sensitivity scaling", "m_autosens", "1", "0", 1),
IupQuakeScale("Mouse sensitivity", 1.00, 20.00, 0.1, "sensitivity", 3.00),
NULL
),
IupFill(),
NULL
),
"HOMOGENEOUS=YES"
);
IupSetAttributes(tab, "GAP=5");
return tab;
}