Skip to content

Commit

Permalink
Add cppcheck and fix evdev issue
Browse files Browse the repository at this point in the history
Signed-off-by: Slendi <slendi@socopon.com>
  • Loading branch information
xslendix committed Sep 20, 2024
1 parent e54be27 commit 0a1d186
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ else
CFLAGS += -O3
endif

VERSION = 0x010200
VERSION = 0x010201

SRC = src/libvinput.c

Expand Down Expand Up @@ -120,6 +120,8 @@ clean:
del /F /Q libvinput.dll vinput.lib libvinput.obj windows_emu.obj windows.obj
endif

.PHONY: all clean
cppcheck:
cppcheck --enable=warning --check-level=exhaustive --inconclusive --std=c99 --force --quiet -i src/ext/vec.c $(SRC) wordlogger.c test_emu.c

.PHONY: all clean cppcheck install

.PHONY: install clean
6 changes: 3 additions & 3 deletions src/linux_evdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void handle_key_event(
event.keychar = 0;
event.timestamp = ev.time.tv_sec * 1000 + ev.time.tv_usec / 1000;

callback(event);
if (callback) callback(event);
}
}
}
Expand All @@ -172,7 +172,7 @@ void handle_mouse_event(struct libevdev *dev, MouseButtonCallback button_callbac
}

event.kind = ev.value == 1 ? MousePressEvent : MouseReleaseEvent;
button_callback(event);
if (button_callback) button_callback(event);
} else if (ev.type == EV_REL) {
MouseMoveEvent move_event;
switch (ev.code) {
Expand All @@ -187,7 +187,7 @@ void handle_mouse_event(struct libevdev *dev, MouseButtonCallback button_callbac
move_event.velocity = sqrt(move_event.velocity_x * move_event.velocity_x
+ move_event.velocity_y * move_event.velocity_y);

move_callback(move_event);
if (move_callback) move_callback(move_event);
}
}
}
Expand Down

0 comments on commit 0a1d186

Please sign in to comment.