[go: nahoru, domu]

Skip to content

Commit

Permalink
Merge pull request #59 from recalbox/58-const-mcp-max
Browse files Browse the repository at this point in the history
using const for mcp max buttons
  • Loading branch information
digitalLumberjack authored Aug 15, 2017
2 parents 8c8b615 + 3f494cf commit 39b0094
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mk_arcade_joystick_rpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ static struct mk *mk_base;
static const int mk_data_size = 16;

static const int mk_max_arcade_buttons = 12;
static const int mk_max_mcp_arcade_buttons = 16;

// Map of the gpios : up, down, left, right, start, select, a, b, tr, y, x, tl
static const int mk_arcade_gpio_maps[] = { 4, 17, 27, 22, 10, 9, 25, 24, 23, 18, 15, 14 };
Expand Down Expand Up @@ -329,7 +330,7 @@ static void mk_input_report(struct mk_pad * pad, unsigned char * data) {
input_report_abs(dev, ABS_Y, !data[0]-!data[1]);
input_report_abs(dev, ABS_X, !data[2]-!data[3]);
if (pad->type == MK_ARCADE_MCP23017) { // check if MCP23017 and extend with 4.
for (j = 4; j < (mk_max_arcade_buttons + 4); j++) {
for (j = 4; j < (mk_max_mcp_arcade_buttons); j++) {
input_report_key(dev, mk_arcade_gpio_btn[j - 4], data[j]);
}
}
Expand Down Expand Up @@ -462,7 +463,7 @@ static int __init mk_setup_pad(struct mk *mk, int idx, int pad_type_arg) {
__set_bit(mk_arcade_gpio_btn[i], input_dev->keybit);
}
else { //Checking for MCP23017 so it gets 4 more buttons registered to it.
for (i = 0; i < mk_max_arcade_buttons + 4; i++)
for (i = 0; i < mk_max_mcp_arcade_buttons; i++)
__set_bit(mk_arcade_gpio_btn[i], input_dev->keybit);
}

Expand Down

0 comments on commit 39b0094

Please sign in to comment.