Skip to content

Commit

Permalink
[G29 emulation] Add +,-, enter and scroll ontrols #399
Browse files Browse the repository at this point in the history
  • Loading branch information
matlo committed Oct 24, 2017
1 parent f4c0a08 commit b8b9423
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion shared/controller/include/g29_ps4.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ typedef struct GIMX_PACKED
unsigned short clutchPedal; //unsigned, released = 0xFFFF
unsigned char Buttons2;
unsigned short unknown3; //0xFFFF
unsigned char unused1[10];
unsigned char Buttons3;
unsigned char unused1[9];
} s_report_g29Ps4;

#endif /* G29_PS4_H_ */
23 changes: 13 additions & 10 deletions shared/controller/src/g29_ps4.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
#define G29_GEAR_SHIFTER_6_MASK 0x20
#define G29_GEAR_SHIFTER_R_MASK 0x80

#define G29_PLUS_MASK 0x0200
#define G29_MINUS_MASK 0x0400
#define G29_DIAL_UP_MASK 0x0800
#define G29_DIAL_DOWN_MASK 0x1000
#define G29_ENTER_MASK 0x2000
#define G29_ENTER_MASK 0x01
#define G29_DIAL_DOWN_MASK 0x02
#define G29_DIAL_UP_MASK 0x04
#define G29_MINUS_MASK 0x08
#define G29_PLUS_MASK 0x10

static s_axis axes[AXIS_MAX] =
{
Expand Down Expand Up @@ -137,6 +137,7 @@ static s_report_g29Ps4 default_report =
.clutchPedal = MAX_AXIS_VALUE_16BITS,
.Buttons2 = 0x00,
.unknown3 = MAX_AXIS_VALUE_16BITS,
.Buttons3 = 0x00,
.unused1 = {},
};

Expand Down Expand Up @@ -287,25 +288,27 @@ static unsigned int build_report(int axis[AXIS_MAX], s_report_packet report[MAX_
g29Ps4->Buttons2 |= G29_GEAR_SHIFTER_R_MASK;
}

g29Ps4->Buttons3 = 0x00;

if (axis[g29Ps4a_plus])
{
g29Ps4->Buttons2 |= G29_PLUS_MASK;
g29Ps4->Buttons3 = G29_PLUS_MASK;
}
if (axis[g29Ps4a_minus])
{
g29Ps4->Buttons2 |= G29_MINUS_MASK;
g29Ps4->Buttons3 = G29_MINUS_MASK;
}
if (axis[g29Ps4a_dialUp])
{
g29Ps4->Buttons2 |= G29_DIAL_UP_MASK;
g29Ps4->Buttons3 = G29_DIAL_UP_MASK;
}
if (axis[g29Ps4a_dialDown])
{
g29Ps4->Buttons2 |= G29_DIAL_DOWN_MASK;
g29Ps4->Buttons3 = G29_DIAL_DOWN_MASK;
}
if (axis[g29Ps4a_enter])
{
g29Ps4->Buttons2 |= G29_ENTER_MASK;
g29Ps4->Buttons3 = G29_ENTER_MASK;
}

return index;
Expand Down

0 comments on commit b8b9423

Please sign in to comment.