From 412c1a42eba83ad8f4505c69ec3fb572316859a7 Mon Sep 17 00:00:00 2001 From: Raphael Assenat Date: Sun, 8 Jan 2017 10:48:03 -0500 Subject: [PATCH] ifdef unused rawdata fields to save memory Save 32 bytes. --- gamecube.c | 3 +++ gamepads.h | 6 ++++++ n64.c | 2 ++ 3 files changed, 11 insertions(+) diff --git a/gamecube.c b/gamecube.c index 4bf2e63..e9c3b59 100644 --- a/gamecube.c +++ b/gamecube.c @@ -92,7 +92,10 @@ void gc_decodeAnswer(unsigned char chn, unsigned char data[8]) cy = data[5]; last_built_report[chn].gc.lt = data[6]; last_built_report[chn].gc.rt = data[7]; + +#ifdef PAD_DATA_HAS_RAW memcpy(last_built_report[chn].gc.raw_data, data, 8); +#endif if (origins_set[chn]) { last_built_report[chn].gc.x = ((int)x-(int)orig_x[chn]); diff --git a/gamepads.h b/gamepads.h index 5a2eaaa..2b62481 100644 --- a/gamepads.h +++ b/gamepads.h @@ -1,6 +1,8 @@ #ifndef _gamepads_h__ #define _gamepads_h__ +#undef PAD_DATA_HAS_RAW + #define PAD_TYPE_NONE 0 #define PAD_TYPE_N64 4 #define PAD_TYPE_GAMECUBE 5 @@ -12,7 +14,9 @@ typedef struct _n64_pad_data { unsigned char pad_type; // PAD_TYPE_N64 char x,y; unsigned short buttons; +#ifdef PAD_DATA_HAS_RAW unsigned char raw_data[N64_RAW_SIZE]; +#endif } n64_pad_data; #define N64_BTN_A 0x8000 @@ -38,7 +42,9 @@ typedef struct _gc_pad_data { char x,y,cx,cy; unsigned char lt,rt; unsigned short buttons; +#ifdef PAD_DATA_HAS_RAW unsigned char raw_data[GC_RAW_SIZE]; +#endif } gc_pad_data; #define GC_BTN_A 0x0001 diff --git a/n64.c b/n64.c index 1c6a651..2be6730 100644 --- a/n64.c +++ b/n64.c @@ -218,11 +218,13 @@ static char n64Update(unsigned char chn) last_built_report[chn].n64.x = x; last_built_report[chn].n64.y = y; +#ifdef PAD_DATA_HAS_RAW /* Copy all the data as-is for the raw field */ last_built_report[chn].n64.raw_data[0] = btns1; last_built_report[chn].n64.raw_data[1] = btns2; last_built_report[chn].n64.raw_data[2] = x; last_built_report[chn].n64.raw_data[3] = y; +#endif /* Some cheap non-official controllers * use the full 8 bit range instead of the