swayfx/sway/commands/input/pointer_accel.c

32 lines
936 B
C
Raw Normal View History

2018-11-18 06:31:33 +11:00
#include <math.h>
2017-12-11 20:17:14 +11:00
#include <stdlib.h>
#include <string.h>
2017-12-17 04:14:24 +11:00
#include "sway/config.h"
2017-12-11 20:17:14 +11:00
#include "sway/commands.h"
#include "sway/input/input-manager.h"
2018-11-18 06:31:33 +11:00
#include "util.h"
2017-12-11 20:17:14 +11:00
struct cmd_results *input_cmd_pointer_accel(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "pointer_accel", EXPECTED_AT_LEAST, 1))) {
return error;
}
2018-09-24 09:56:52 +10:00
struct input_config *ic = config->handler_context.input_config;
if (!ic) {
2017-12-13 01:02:30 +11:00
return cmd_results_new(CMD_FAILURE,
"pointer_accel", "No input device defined.");
2017-12-11 20:17:14 +11:00
}
2018-11-18 06:31:33 +11:00
float pointer_accel = parse_float(argv[0]);
if (isnan(pointer_accel)) {
return cmd_results_new(CMD_INVALID, "pointer_accel",
"Invalid pointer accel; expected float.");
} if (pointer_accel < -1 || pointer_accel > 1) {
2017-12-13 01:02:30 +11:00
return cmd_results_new(CMD_INVALID, "pointer_accel",
"Input out of range [-1, 1]");
2017-12-11 20:17:14 +11:00
}
2018-09-24 09:56:52 +10:00
ic->pointer_accel = pointer_accel;
2017-12-11 20:17:14 +11:00
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}