Skip to content
Snippets Groups Projects
Commit 7f885123 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Add toggle to invert mouse wheel.

It actually inverts buttons four and five, but we're not going to
tell people that.

Implements feature request 75.
parent 992a93a8
No related branches found
No related tags found
No related merge requests found
Pipeline #8046 passed
......@@ -82,6 +82,7 @@ CIOLIBEXPORT const void * ciolib_initial_icon = syncicon64;
CIOLIBEXPORT size_t ciolib_initial_icon_width = SYNCICON64_WIDTH;
CIOLIBEXPORT const char *ciolib_initial_program_name = "CIOLIB";
CIOLIBEXPORT const char *ciolib_initial_program_class = "CIOLIB";
CIOLIBEXPORT bool ciolib_swap_mouse_butt45 = false;
static int initialized=0;
......
......@@ -422,6 +422,7 @@ CIOLIBEXPORTVAR const void * ciolib_initial_icon;
CIOLIBEXPORTVAR size_t ciolib_initial_icon_width;
CIOLIBEXPORTVAR const char *ciolib_initial_program_name;
CIOLIBEXPORTVAR const char *ciolib_initial_program_class;
CIOLIBEXPORTVAR bool ciolib_swap_mouse_butt45;
CIOLIBEXPORT int initciolib(int mode);
CIOLIBEXPORT void suspendciolib(void);
......@@ -679,6 +680,7 @@ enum {
,CIOLIB_BUTTON_5_DRAG_END /* 45 */
};
// If these macros change, the handling of swapping buttons 4/5 is impacted.
#define CIOLIB_BUTTON_PRESS(x) ((x-1)*9+1)
#define CIOLIB_BUTTON_RELEASE(x) ((x-1)*9+2)
#define CIOLIB_BUTTON_CLICK(x) ((x-1)*9+3)
......
......@@ -208,6 +208,37 @@ void add_outevent(int event, int x, int y, int xres, int yres)
ome->endy_res=yres;
ome->nextevent=(struct out_mouse_event *)NULL;
if (ciolib_swap_mouse_butt45) {
int orig_bstate = ome->bstate;
int orig_kbsm = ome->kbsm;
int orig_event = ome->event;
switch (CIOLIB_BUTTON_NUMBER(orig_event)) {
case 4:
ome->event += 9;
break;
case 5:
ome->event -= 9;
break;
}
if (orig_bstate & CIOLIB_BUTTON(4))
ome->bstate &= ~(CIOLIB_BUTTON(4));
if (orig_bstate & CIOLIB_BUTTON(5))
ome->bstate &= ~(CIOLIB_BUTTON(5));
if (orig_bstate & CIOLIB_BUTTON(4))
ome->bstate |= CIOLIB_BUTTON(5);
if (orig_bstate & CIOLIB_BUTTON(5))
ome->bstate |= CIOLIB_BUTTON(4);
if (orig_kbsm & CIOLIB_BUTTON(4))
ome->kbsm &= ~(CIOLIB_BUTTON(4));
if (orig_kbsm & CIOLIB_BUTTON(5))
ome->kbsm &= ~(CIOLIB_BUTTON(5));
if (orig_kbsm & CIOLIB_BUTTON(4))
ome->kbsm |= CIOLIB_BUTTON(5);
if (orig_kbsm & CIOLIB_BUTTON(5))
ome->kbsm |= CIOLIB_BUTTON(4);
}
listPushNode(&state.output,ome);
}
......
......@@ -3,6 +3,8 @@ Version 1.5b
Fix Prestel regressions
Use the SAA5050 font for Prestel mode
Prestel mode is 25 rows, not 24
Add setting to invert mouse wheel
Support web-based dialing directories
Version 1.5a
------------
......
......@@ -2193,8 +2193,8 @@ change_settings(int connected)
char inipath[MAX_PATH + 1];
FILE *inifile;
str_list_t inicontents;
char opts[14][1049];
char *opt[15];
char opts[15][1049];
char *opt[16];
char *subopts[10];
char audio_opts[1024];
int i, j, k, l;
......@@ -2209,7 +2209,7 @@ change_settings(int connected)
else
inicontents = strListInit();
for (i = 0; i < 13; i++)
for (i = 0; i < 14; i++)
opt[i] = opts[i];
opt[i] = NULL;
......@@ -2270,10 +2270,11 @@ change_settings(int connected)
SAFEPRINTF(opts[10], "List Path %s", settings.stored_list_path);
SAFEPRINTF(opts[11], "TERM For Shell %s", settings.TERM);
sprintf(opts[12], "Scaling %s", scaling_names[settings_to_scale()]);
sprintf(opts[13], "Invert Mouse Wheel %s", settings.invert_wheel ? "Yes" : "No");
if (connected)
opt[13] = NULL;
opt[14] = NULL;
else
sprintf(opts[13], "Custom Screen Mode");
sprintf(opts[14], "Custom Screen Mode");
switch (uifc.list(WIN_MID | WIN_SAV | WIN_ACT, 0, 0, 0, &cur, NULL, "Program Settings", opt)) {
case -1:
check_exit(false);
......@@ -2553,6 +2554,11 @@ change_settings(int connected)
setscaling_type(settings.extern_scale ? CIOLIB_SCALING_EXTERNAL : CIOLIB_SCALING_INTERNAL);
break;
case 13:
settings.invert_wheel = !settings.invert_wheel;
ciolib_swap_mouse_butt45 = settings.invert_wheel;
iniSetBool(&inicontents, "SyncTERM", "InvertMouseWheel", settings.invert_wheel, &ini_style);
break;
case 14:
uifc.helpbuf = "`Custom Screen Mode`\n\n"
"~ Rows ~\n"
" Sets the number of rows in the custom screen mode\n"
......
......@@ -1545,6 +1545,7 @@ load_settings(struct syncterm_settings *set)
set->scaling_factor = iniReadFloat(inifile, "SyncTERM", "ScalingFactor", 0);
set->blocky = iniReadBool(inifile, "SyncTERM", "BlockyScaling", true);
set->extern_scale = iniReadBool(inifile, "SyncTERM", "ExternalScaling", false);
set->invert_wheel = iniReadBool(inifile, "SyncTERM", "InvertMouseWheel", false);
// TODO: Add this to the UI somewhere.
set->left_just = iniReadBool(inifile, "SyncTERM", "LeftJustify", false);
......@@ -1894,6 +1895,7 @@ main(int argc, char **argv)
}
load_settings(&settings);
ciolib_swap_mouse_butt45 = settings.invert_wheel;
cvmode = find_vmode(CIOLIB_MODE_CUSTOM);
vparams[cvmode].cols = settings.custom_cols;
vparams[cvmode].rows = settings.custom_rows;
......
......@@ -80,6 +80,7 @@ struct syncterm_settings {
int blocky;
int extern_scale;
uint audio_output_modes;
bool invert_wheel;
};
extern ini_bitdesc_t audio_output_bits[];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment