mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2024-11-27 16:00:52 +01:00
Properly save/load the new analog invert option
This commit is contained in:
parent
f37f216c69
commit
329d6a80a3
@ -49,6 +49,7 @@ static INT_PTR analog_ui_handle_init(HWND hwnd, struct analog_def *def);
|
|||||||
static void analog_ui_handle_init_label(HWND hwnd);
|
static void analog_ui_handle_init_label(HWND hwnd);
|
||||||
static void analog_ui_handle_init_dev(HWND hwnd);
|
static void analog_ui_handle_init_dev(HWND hwnd);
|
||||||
static void analog_ui_handle_init_sensitivity(HWND hwnd);
|
static void analog_ui_handle_init_sensitivity(HWND hwnd);
|
||||||
|
static void analog_ui_handle_init_invert(HWND hwnd);
|
||||||
static bool analog_ui_match_device(struct hid_stub *hid);
|
static bool analog_ui_match_device(struct hid_stub *hid);
|
||||||
static void analog_ui_populate_controls(HWND hwnd);
|
static void analog_ui_populate_controls(HWND hwnd);
|
||||||
static INT_PTR analog_ui_handle_device_change(HWND hwnd);
|
static INT_PTR analog_ui_handle_device_change(HWND hwnd);
|
||||||
@ -258,6 +259,7 @@ static INT_PTR analog_ui_handle_init(HWND hwnd, struct analog_def *def)
|
|||||||
analog_ui_handle_init_label(hwnd);
|
analog_ui_handle_init_label(hwnd);
|
||||||
analog_ui_handle_init_dev(hwnd);
|
analog_ui_handle_init_dev(hwnd);
|
||||||
analog_ui_handle_init_sensitivity(hwnd);
|
analog_ui_handle_init_sensitivity(hwnd);
|
||||||
|
analog_ui_handle_init_invert(hwnd);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -353,6 +355,17 @@ static void analog_ui_handle_init_sensitivity(HWND hwnd)
|
|||||||
EnableWindow(slider, !mapper_is_analog_absolute(ui->def->tag));
|
EnableWindow(slider, !mapper_is_analog_absolute(ui->def->tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void analog_ui_handle_init_invert(HWND hwnd)
|
||||||
|
{
|
||||||
|
struct analog_ui *ui;
|
||||||
|
|
||||||
|
ui = (struct analog_ui *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||||
|
|
||||||
|
if (mapper_get_analog_invert(ui->def->tag)) {
|
||||||
|
SendMessage(GetDlgItem(hwnd, IDC_ANALOG_INVERT), BM_SETCHECK, BST_CHECKED, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool analog_ui_match_device(struct hid_stub *hid)
|
static bool analog_ui_match_device(struct hid_stub *hid)
|
||||||
{
|
{
|
||||||
struct hid_control *controls;
|
struct hid_control *controls;
|
||||||
|
@ -35,6 +35,7 @@ EXPORTS
|
|||||||
mapper_get_action_map
|
mapper_get_action_map
|
||||||
mapper_get_analog_map
|
mapper_get_analog_map
|
||||||
mapper_get_analog_sensitivity
|
mapper_get_analog_sensitivity
|
||||||
|
mapper_get_analog_invert
|
||||||
mapper_get_npages
|
mapper_get_npages
|
||||||
mapper_get_nanalogs
|
mapper_get_nanalogs
|
||||||
mapper_get_nlights
|
mapper_get_nlights
|
||||||
|
@ -15,6 +15,7 @@ bool mapper_get_action_map(
|
|||||||
uint8_t action, uint8_t page, struct mapped_action *ma);
|
uint8_t action, uint8_t page, struct mapped_action *ma);
|
||||||
bool mapper_get_analog_map(uint8_t analog, struct mapped_analog *ma);
|
bool mapper_get_analog_map(uint8_t analog, struct mapped_analog *ma);
|
||||||
int32_t mapper_get_analog_sensitivity(uint8_t analog);
|
int32_t mapper_get_analog_sensitivity(uint8_t analog);
|
||||||
|
bool mapper_get_analog_invert(uint8_t analog);
|
||||||
uint8_t mapper_get_nanalogs(void);
|
uint8_t mapper_get_nanalogs(void);
|
||||||
uint8_t mapper_get_nlights(void);
|
uint8_t mapper_get_nlights(void);
|
||||||
uint8_t mapper_get_npages(void);
|
uint8_t mapper_get_npages(void);
|
||||||
|
@ -144,6 +144,11 @@ int32_t mapper_get_analog_sensitivity(uint8_t analog)
|
|||||||
return mapper_impl_get_analog_sensitivity(mapper_inst, analog);
|
return mapper_impl_get_analog_sensitivity(mapper_inst, analog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool mapper_get_analog_invert(uint8_t analog)
|
||||||
|
{
|
||||||
|
return mapper_impl_get_analog_invert(mapper_inst, analog);
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t mapper_get_nanalogs(void)
|
uint8_t mapper_get_nanalogs(void)
|
||||||
{
|
{
|
||||||
return mapper_impl_get_nanalogs(mapper_inst);
|
return mapper_impl_get_nanalogs(mapper_inst);
|
||||||
|
@ -74,6 +74,7 @@ static bool mapper_impl_config_load_analogs(struct mapper *m, FILE *f)
|
|||||||
char *dev_node;
|
char *dev_node;
|
||||||
struct mapped_analog ma;
|
struct mapped_analog ma;
|
||||||
int32_t sensitivity;
|
int32_t sensitivity;
|
||||||
|
bool invert;
|
||||||
uint8_t nanalogs;
|
uint8_t nanalogs;
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
||||||
@ -101,8 +102,13 @@ static bool mapper_impl_config_load_analogs(struct mapper *m, FILE *f)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!read_u8(f, &invert)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mapper_impl_set_analog_map(m, i, &ma);
|
mapper_impl_set_analog_map(m, i, &ma);
|
||||||
mapper_impl_set_analog_sensitivity(m, i, sensitivity);
|
mapper_impl_set_analog_sensitivity(m, i, sensitivity);
|
||||||
|
mapper_impl_set_analog_invert(m, i, invert);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(dev_node);
|
free(dev_node);
|
||||||
@ -211,6 +217,7 @@ static void mapper_impl_config_save_analogs(struct mapper *m, FILE *f)
|
|||||||
{
|
{
|
||||||
struct mapped_analog ma;
|
struct mapped_analog ma;
|
||||||
int32_t sensitivity;
|
int32_t sensitivity;
|
||||||
|
bool invert;
|
||||||
uint8_t nanalogs;
|
uint8_t nanalogs;
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
||||||
@ -224,10 +231,12 @@ static void mapper_impl_config_save_analogs(struct mapper *m, FILE *f)
|
|||||||
write_str(f, "");
|
write_str(f, "");
|
||||||
} else {
|
} else {
|
||||||
sensitivity = mapper_impl_get_analog_sensitivity(m, i);
|
sensitivity = mapper_impl_get_analog_sensitivity(m, i);
|
||||||
|
invert = mapper_impl_get_analog_invert(m, i);
|
||||||
|
|
||||||
write_str(f, hid_stub_get_dev_node(ma.hid));
|
write_str(f, hid_stub_get_dev_node(ma.hid));
|
||||||
write_u32(f, &ma.control_no);
|
write_u32(f, &ma.control_no);
|
||||||
write_u32(f, &sensitivity);
|
write_u32(f, &sensitivity);
|
||||||
|
write_u8(f, &invert);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,6 @@ static void analog_mapping_bind(struct analog_mapping *am)
|
|||||||
am->analog_max = ctl->value_max;
|
am->analog_max = ctl->value_max;
|
||||||
am->inv_analog_range = 1.0 / ((int64_t)ctl->value_max - ctl->value_min);
|
am->inv_analog_range = 1.0 / ((int64_t)ctl->value_max - ctl->value_min);
|
||||||
am->absolute = !(ctl->flags & HID_FLAG_RELATIVE);
|
am->absolute = !(ctl->flags & HID_FLAG_RELATIVE);
|
||||||
am->invert = false;
|
|
||||||
am->valid = true;
|
am->valid = true;
|
||||||
|
|
||||||
read_fail:
|
read_fail:
|
||||||
@ -425,6 +424,15 @@ int32_t mapper_impl_get_analog_sensitivity(struct mapper *m, uint8_t analog)
|
|||||||
return m->analogs[analog].sensitivity;
|
return m->analogs[analog].sensitivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool mapper_impl_get_analog_invert(struct mapper* m, uint8_t analog)
|
||||||
|
{
|
||||||
|
if (analog >= m->nanalogs) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m->analogs[analog].invert;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t mapper_impl_get_nanalogs(struct mapper *m)
|
uint8_t mapper_impl_get_nanalogs(struct mapper *m)
|
||||||
{
|
{
|
||||||
return m->nanalogs;
|
return m->nanalogs;
|
||||||
|
@ -57,6 +57,7 @@ bool mapper_impl_get_analog_map(
|
|||||||
bool mapper_impl_get_action_map(
|
bool mapper_impl_get_action_map(
|
||||||
struct mapper *m, uint8_t action, uint8_t page, struct mapped_action *ma);
|
struct mapper *m, uint8_t action, uint8_t page, struct mapped_action *ma);
|
||||||
int32_t mapper_impl_get_analog_sensitivity(struct mapper *m, uint8_t analog);
|
int32_t mapper_impl_get_analog_sensitivity(struct mapper *m, uint8_t analog);
|
||||||
|
bool mapper_impl_get_analog_invert(struct mapper *m, uint8_t analog);
|
||||||
uint8_t mapper_impl_get_nanalogs(struct mapper *m);
|
uint8_t mapper_impl_get_nanalogs(struct mapper *m);
|
||||||
uint8_t mapper_impl_get_nlights(struct mapper *m);
|
uint8_t mapper_impl_get_nlights(struct mapper *m);
|
||||||
uint8_t mapper_impl_get_npages(struct mapper *m);
|
uint8_t mapper_impl_get_npages(struct mapper *m);
|
||||||
|
Loading…
Reference in New Issue
Block a user