Skip to content
Permalink
Browse files

Fix compilation with gcc 9. Add -Werror.

  • Loading branch information
matlo committed Sep 21, 2019
1 parent 12a114f commit 453afa746044ed922bf5408229cd8a2981e7d8f1
@@ -7,19 +7,25 @@
LD = $(CXX)

ifneq ($(DEBUG),1)
CFLAGS += -Wall -Wextra -O3
CXXFLAGS += -Wall -Wextra -O3
CFLAGS += -Wall -Wextra -Werror -O3
CXXFLAGS += -Wall -Wextra -Werror -O3
else
ifneq ($(OS),Windows_NT)
CFLAGS += -Wall -Wextra -O0 -g -fsanitize=address -fno-omit-frame-pointer
CXXFLAGS += -Wall -Wextra -O0 -g -fsanitize=address -fno-omit-frame-pointer
CFLAGS += -Wall -Wextra -Werror -O0 -g -fsanitize=address -fno-omit-frame-pointer
CXXFLAGS += -Wall -Wextra -Werror -O0 -g -fsanitize=address -fno-omit-frame-pointer
LDFLAGS += -fsanitize=address
else
CFLAGS += -Wall -Wextra -O0 -g -fno-omit-frame-pointer
CXXFLAGS += -Wall -Wextra -O0 -g -fno-omit-frame-pointer
CFLAGS += -Wall -Wextra -Werror -O0 -g -fno-omit-frame-pointer
CXXFLAGS += -Wall -Wextra -Werror -O0 -g -fno-omit-frame-pointer
endif
endif

ifeq ($(PROFILE),1)
CFLAGS += -pg
CXXFLAGS += -pg
LDFLAGS += -pg
endif

CPPFLAGS += -I../shared

GIMXFILE_LDFLAGS = $(GIMXLOG_LDFLAGS) -L../shared/gimxfile
@@ -7,7 +7,7 @@ endif

NAME=$(shell basename "$(shell pwd)")

CPPFLAGS += `wx-config --cflags` -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wno-unused-local-typedefs
CPPFLAGS += `wx-config --cflags` -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wno-cast-function-type -Wno-deprecated-copy -Wno-ignored-qualifiers
LDLIBS += `wx-config --libs` -lstdc++ -lm

LDLIBS += $(GIMXCONFIGEDITOR_LDLIBS) $(GIMXUPDATER_LDLIBS)
@@ -1082,8 +1082,8 @@ void update_residue(double axis_scale, const s_mapper * mapper_x, const s_mapper
s_vector input_trunk = { .x = 0, .y = 0 };
if (axis_x != 0 || axis_y != 0)
{
double zx = fabs(axis_x);
double zy = fabs(axis_y);
double zx = abs(axis_x);
double zy = abs(axis_y);

s_vector dead_zones =
{
@@ -2,8 +2,8 @@
OUT = ff_lg_test
OBJS = ../../haptic/common/ff_lg.o ../../haptic/haptic_tweaks.o
BINS = ff_lg_test
CFLAGS = -I../../include -I../../../shared -I../../../shared -Wall -Wextra -g -O0
CXXFLAGS = -Wall -Wextra -g -O0
CFLAGS = -I../../include -I../../../shared -I../../../shared -Wall -Wextra -Werror -g -O0
CXXFLAGS = -Wall -Wextra -Werror -g -O0

ifeq ($(OS),Windows_NT)
CPPFLAGS += $(shell sdl2-config --cflags)
@@ -7,7 +7,7 @@ endif

NAME=$(shell basename "$(shell pwd)")

CPPFLAGS += `wx-config --cflags` -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wno-unused-local-typedefs
CPPFLAGS += `wx-config --cflags` -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wno-cast-function-type -Wno-deprecated-copy -Wno-ignored-qualifiers
LDLIBS += `wx-config --libs` -lstdc++ -lm

LDLIBS += $(GIMXCONFIGEDITOR_LDLIBS) $(GIMXUPDATER_LDLIBS)
@@ -10,7 +10,7 @@ NAME=$(shell basename "$(shell pwd)")
ifeq ($(OS),Windows_NT)
CPPFLAGS += `sdl2-config --cflags`
endif
CPPFLAGS += `wx-config --cflags` -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wno-unused-local-typedefs
CPPFLAGS += `wx-config --cflags` -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wno-cast-function-type -Wno-deprecated-copy -Wno-ignored-qualifiers
LDLIBS += `wx-config --libs` -lstdc++

LDLIBS += $(GIMXCONFIGEDITOR_LDLIBS) $(GIMXUPDATER_LDLIBS) $(GIMXCONFIGUPDATER_LDLIBS) $(GIMXHID_LDLIBS) $(GIMXGPP_LDLIBS) $(GIMXSERIAL_LDLIBS)
@@ -8,7 +8,7 @@ endif

NAME=$(shell basename "$(shell pwd)")

CPPFLAGS += `wx-config --cflags` -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wno-unused-local-typedefs
CPPFLAGS += `wx-config --cflags` -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wno-cast-function-type -Wno-deprecated-copy -Wno-ignored-qualifiers
LDLIBS += `wx-config --libs` -lstdc++

OBJECTS := $(patsubst %.cpp,%.o,$(wildcard *.cpp))
@@ -5,18 +5,24 @@ libdir = $(exec_prefix)/lib
endif

ifneq ($(DEBUG),1)
CFLAGS += -Wall -Wextra -O3
CXXFLAGS += -Wall -Wextra -O3
CFLAGS += -Wall -Wextra -Werror -O3
CXXFLAGS += -Wall -Wextra -Werror -O3
else
ifneq ($(OS),Windows_NT)
CFLAGS += -Wall -Wextra -O0 -g -fsanitize=address -fno-omit-frame-pointer
CXXFLAGS += -Wall -Wextra -O0 -g -fsanitize=address -fno-omit-frame-pointer
CFLAGS += -Wall -Wextra -Werror -O0 -g -fsanitize=address -fno-omit-frame-pointer
CXXFLAGS += -Wall -Wextra -Werror -O0 -g -fsanitize=address -fno-omit-frame-pointer
else
CFLAGS += -Wall -Wextra -O0 -g -fno-omit-frame-pointer
CXXFLAGS += -Wall -Wextra -O0 -g -fno-omit-frame-pointer
CFLAGS += -Wall -Wextra -Werror -O0 -g -fno-omit-frame-pointer
CXXFLAGS += -Wall -Wextra -Werror -O0 -g -fno-omit-frame-pointer
endif
endif

ifeq ($(PROFILE),1)
CFLAGS += -pg
CXXFLAGS += -pg
LDFLAGS += -pg
endif

CPPFLAGS += -I../

LIBNAME=lib$(shell basename "$(shell pwd)")
@@ -90,109 +90,110 @@ static void init_report(s_report * report)
memcpy(report, &default_report, sizeof(default_report));
}

#define dfPs2 report[index].value.dfPs2

static unsigned int build_report(int axis[AXIS_MAX], s_report_packet report[MAX_REPORTS])
{
unsigned int index = 0;
report[index].length = sizeof(s_report_dfPs2);
s_report_dfPs2* dfPs2 = &report[index].value.dfPs2;

dfPs2->buttonsAndWheel = clamp(0, axis[dfPs2a_wheel] + CENTER_AXIS_VALUE_10BITS, MAX_AXIS_VALUE_10BITS);
dfPs2->gasPedal = clamp(0, MAX_AXIS_VALUE_8BITS - axis[dfPs2a_gasPedal], MAX_AXIS_VALUE_8BITS);
dfPs2->brakePedal = clamp(0, MAX_AXIS_VALUE_8BITS - axis[dfPs2a_brakePedal], MAX_AXIS_VALUE_8BITS);
dfPs2.buttonsAndWheel = clamp(0, axis[dfPs2a_wheel] + CENTER_AXIS_VALUE_10BITS, MAX_AXIS_VALUE_10BITS);
dfPs2.gasPedal = clamp(0, MAX_AXIS_VALUE_8BITS - axis[dfPs2a_gasPedal], MAX_AXIS_VALUE_8BITS);
dfPs2.brakePedal = clamp(0, MAX_AXIS_VALUE_8BITS - axis[dfPs2a_brakePedal], MAX_AXIS_VALUE_8BITS);

dfPs2->buttons = 0x00;
dfPs2.buttons = 0x00;

if (axis[dfPs2a_right])
{
if (axis[dfPs2a_down])
{
dfPs2->hat = 0x03;
dfPs2.hat = 0x03;
}
else if (axis[dfPs2a_up])
{
dfPs2->hat = 0x01;
dfPs2.hat = 0x01;
}
else
{
dfPs2->hat = 0x02;
dfPs2.hat = 0x02;
}
}
else if (axis[dfPs2a_left])
{
if (axis[dfPs2a_down])
{
dfPs2->hat = 0x05;
dfPs2.hat = 0x05;
}
else if (axis[dfPs2a_up])
{
dfPs2->hat = 0x07;
dfPs2.hat = 0x07;
}
else
{
dfPs2->hat = 0x06;
dfPs2.hat = 0x06;
}
}
else if (axis[dfPs2a_down])
{
dfPs2->hat = 0x04;
dfPs2.hat = 0x04;
}
else if (axis[dfPs2a_up])
{
dfPs2->hat = 0x0;
dfPs2.hat = 0x0;
}
else
{
dfPs2->hat = 0x08;
dfPs2.hat = 0x08;
}

if (axis[dfPs2a_square])
{
dfPs2->buttonsAndWheel |= DF_SQUARE_MASK;
dfPs2.buttonsAndWheel |= DF_SQUARE_MASK;
}
if (axis[dfPs2a_cross])
{
dfPs2->buttonsAndWheel |= DF_CROSS_MASK;
dfPs2.buttonsAndWheel |= DF_CROSS_MASK;
}
if (axis[dfPs2a_triangle])
{
dfPs2->buttonsAndWheel |= DF_TRIANGLE_MASK;
dfPs2.buttonsAndWheel |= DF_TRIANGLE_MASK;
}
if (axis[dfPs2a_circle])
{
dfPs2->buttonsAndWheel |= DF_CIRCLE_MASK;
dfPs2.buttonsAndWheel |= DF_CIRCLE_MASK;
}
if (axis[dfPs2a_r1])
{
dfPs2->buttonsAndWheel |= DF_R1_MASK;
dfPs2.buttonsAndWheel |= DF_R1_MASK;
}
if (axis[dfPs2a_l1])
{
dfPs2->buttonsAndWheel |= DF_L1_MASK;
dfPs2.buttonsAndWheel |= DF_L1_MASK;
}

if (axis[dfPs2a_l3])
{
dfPs2->buttons |= DF_L3_MASK;
dfPs2.buttons |= DF_L3_MASK;
}
if (axis[dfPs2a_r3])
{
dfPs2->buttons |= DF_R3_MASK;
dfPs2.buttons |= DF_R3_MASK;
}
if (axis[dfPs2a_start])
{
dfPs2->buttons |= DF_START_MASK;
dfPs2.buttons |= DF_START_MASK;
}
if (axis[dfPs2a_select])
{
dfPs2->buttons |= DF_SELECT_MASK;
dfPs2.buttons |= DF_SELECT_MASK;
}
if (axis[dfPs2a_l2])
{
dfPs2->buttons |= DF_L2_MASK;
dfPs2.buttons |= DF_L2_MASK;
}
if (axis[dfPs2a_r2])
{
dfPs2->buttons |= DF_R2_MASK;
dfPs2.buttons |= DF_R2_MASK;
}

return index;
@@ -91,19 +91,11 @@ static void init_report(s_report * report)
memcpy(report, &default_report, sizeof(default_report));
}

static inline void axis2button(int axis[AXIS_MAX], e_x360_axis_index index,
unsigned short* buttons, unsigned short button_mask)
{
if (axis[index])
{
(*buttons) |= button_mask;
}
}
#define axis2button(axis, index, buttons, button_mask) \
if (axis[index]) { buttons |= button_mask; }

static inline void axis2axis(int from, short * to)
{
*to = clamp(SHRT_MIN, from, SHRT_MAX);
}
#define axis2axis(from, to) \
to = clamp(SHRT_MIN, from, SHRT_MAX)

static unsigned int build_report(int axis[AXIS_MAX], s_report_packet report[MAX_REPORTS])
{
@@ -113,32 +105,32 @@ static unsigned int build_report(int axis[AXIS_MAX], s_report_packet report[MAX_

x360->buttons = 0x0000;

axis2button(axis, x360a_up, &x360->buttons, X360_UP_MASK);
axis2button(axis, x360a_down, &x360->buttons, X360_DOWN_MASK);
axis2button(axis, x360a_left, &x360->buttons, X360_LEFT_MASK);
axis2button(axis, x360a_right, &x360->buttons, X360_RIGHT_MASK);
axis2button(axis, x360a_up, x360->buttons, X360_UP_MASK);
axis2button(axis, x360a_down, x360->buttons, X360_DOWN_MASK);
axis2button(axis, x360a_left, x360->buttons, X360_LEFT_MASK);
axis2button(axis, x360a_right, x360->buttons, X360_RIGHT_MASK);

axis2button(axis, x360a_start, &x360->buttons, X360_START_MASK);
axis2button(axis, x360a_back, &x360->buttons, X360_BACK_MASK);
axis2button(axis, x360a_LS, &x360->buttons, X360_LS_MASK);
axis2button(axis, x360a_RS, &x360->buttons, X360_RS_MASK);
axis2button(axis, x360a_start, x360->buttons, X360_START_MASK);
axis2button(axis, x360a_back, x360->buttons, X360_BACK_MASK);
axis2button(axis, x360a_LS, x360->buttons, X360_LS_MASK);
axis2button(axis, x360a_RS, x360->buttons, X360_RS_MASK);

axis2button(axis, x360a_LB, &x360->buttons, X360_LB_MASK);
axis2button(axis, x360a_RB, &x360->buttons, X360_RB_MASK);
axis2button(axis, x360a_guide, &x360->buttons, X360_GUIDE_MASK);
axis2button(axis, x360a_LB, x360->buttons, X360_LB_MASK);
axis2button(axis, x360a_RB, x360->buttons, X360_RB_MASK);
axis2button(axis, x360a_guide, x360->buttons, X360_GUIDE_MASK);

axis2button(axis, x360a_A, &x360->buttons, X360_A_MASK);
axis2button(axis, x360a_B, &x360->buttons, X360_B_MASK);
axis2button(axis, x360a_X, &x360->buttons, X360_X_MASK);
axis2button(axis, x360a_Y, &x360->buttons, X360_Y_MASK);
axis2button(axis, x360a_A, x360->buttons, X360_A_MASK);
axis2button(axis, x360a_B, x360->buttons, X360_B_MASK);
axis2button(axis, x360a_X, x360->buttons, X360_X_MASK);
axis2button(axis, x360a_Y, x360->buttons, X360_Y_MASK);

x360->ltrigger = clamp(0, axis[x360a_LT], UCHAR_MAX);
x360->rtrigger = clamp(0, axis[x360a_RT], UCHAR_MAX);

axis2axis(axis[x360a_lstick_x], &x360->xaxis);
axis2axis(-axis[x360a_lstick_y], &x360->yaxis);
axis2axis(axis[x360a_rstick_x], &x360->zaxis);
axis2axis(-axis[x360a_rstick_y], &x360->taxis);
axis2axis(axis[x360a_lstick_x], x360->xaxis);
axis2axis(-axis[x360a_lstick_y], x360->yaxis);
axis2axis(axis[x360a_rstick_x], x360->zaxis);
axis2axis(-axis[x360a_rstick_y], x360->taxis);

return index;
}

0 comments on commit 453afa7

Please sign in to comment.
You can’t perform that action at this time.