Skip to content

Commit

Permalink
add invert-y support
Browse files Browse the repository at this point in the history
Close #71
  • Loading branch information
xtreme8000 committed Apr 4, 2019
1 parent 8132915 commit 7ad3230
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/config.c
Expand Up @@ -63,6 +63,7 @@ void config_save() {
config_seti("show_fps",settings.show_fps);
config_seti("voxlap_models",settings.voxlap_models);
config_seti("force_displaylist",settings.force_displaylist);
config_seti("inverty",settings.invert_y);

for(int k=0;k<list_size(&config_keys);k++) {
struct config_key_pair* e = list_get(&config_keys,k);
Expand Down Expand Up @@ -134,6 +135,9 @@ static int config_read_key(void* user, const char* section, const char* name, co
if(!strcmp(name,"force_displaylist")) {
settings.force_displaylist = atoi(value);
}
if(!strcmp(name,"inverty")) {
settings.invert_y = atoi(value);
}
}
if(!strcmp(section,"controls")) {
for(int k=0;k<list_size(&config_keys);k++) {
Expand Down Expand Up @@ -389,6 +393,13 @@ void config_reload() {
.name="Show fps",
.help="show your current fps and ping"
});
list_add(&config_settings,&(struct config_setting){
.value=&settings_tmp.invert_y,
.type=CONFIG_TYPE_INT,
.max=1,
.name="Invert y",
.help="Invert vertical mouse movement"
});
list_add(&config_settings,&(struct config_setting){
.value=&settings_tmp.show_news,
.type=CONFIG_TYPE_INT,
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Expand Up @@ -43,6 +43,7 @@ extern struct RENDER_OPTIONS {
int volume;
int voxlap_models;
int force_displaylist;
int invert_y;
} settings, settings_tmp;

extern struct list config_keys;
Expand Down
3 changes: 3 additions & 0 deletions src/hud.c
Expand Up @@ -933,6 +933,9 @@ static void hud_ingame_mouselocation(double x, double y) {
s = 0.5F;
}

if(settings.invert_y)
dy *= -1.0F;

camera_rot_x -= dx*settings.mouse_sensitivity/5.0F*MOUSE_SENSITIVITY*s;
camera_rot_y += dy*settings.mouse_sensitivity/5.0F*MOUSE_SENSITIVITY*s;

Expand Down
1 change: 1 addition & 0 deletions src/main.c
Expand Up @@ -580,6 +580,7 @@ int main(int argc, char** argv) {
settings.volume = 10;
settings.voxlap_models = 0;
settings.force_displaylist = 0;
settings.invert_y = 0;
strcpy(settings.name,"DEV_CLIENT");

if(!file_dir_exists("logs"))
Expand Down

0 comments on commit 7ad3230

Please sign in to comment.