Skip to content
This repository has been archived by the owner on Oct 11, 2020. It is now read-only.

Commit

Permalink
Fix issue with controls and some other fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
gameblabla committed Oct 7, 2019
1 parent 41fd9b9 commit 3f13265
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
16 changes: 13 additions & 3 deletions src/pad.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,16 @@ unsigned char PAD1_poll(unsigned char value) {

if (g.CurByte1 == 0) {
uint64_t n;
CurCmd = value;
g.CurByte1++;

n = pad_read(0);
// Don't enable Analog/Vibration for a standard pad
if (buf[0] == 0x41) {
CurCmd = CMD_READ_DATA_AND_VIBRATE;
} else {
CurCmd = value;
}

g.CmdLen1 = 8;

switch (CurCmd)
Expand Down Expand Up @@ -124,7 +130,11 @@ unsigned char PAD1_poll(unsigned char value) {
// else FALLTHROUGH
case CMD_READ_DATA_AND_VIBRATE:
default:
if (buf[0] == 0x41) size_buf = 4;
if (buf[0] == 0x41)
{
g.CmdLen1 = 4;
size_buf = 4;
}
for(uint32_t i=0;i<size_buf;i=i+2)
{
buf[i] = (n >> ((7-i-1) * 8)) & 0xFF;
Expand Down Expand Up @@ -191,7 +201,7 @@ unsigned char PAD2_poll(unsigned char value) {
uint64_t n;
g.CurByte2++;

n = pad_read(0);
n = pad_read(1);
for(int i=0;i<8;i=i+2)
{
buf[i] = (n >> ((7-i-1) * 8)) & 0xFF;
Expand Down
20 changes: 3 additions & 17 deletions src/port/sdl/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ uint8_t use_speedup = 0;
static uint16_t id=0x5A41,joy_l = 0x8080,joy_r = 0x8080;
SDL_Joystick * sdl_joy1;
SDL_Joystick * sdl_joy2;
#define joy_commit_range 3276
#define joy_commit_range 2048
enum
{
ANALOG_UP = 1,
Expand Down Expand Up @@ -630,14 +630,8 @@ void pad_update(void)
analog1 |= ANALOG_LEFT;
}
} else {
#ifdef DEBUG
printf("jx 0x%x ",joy_l);
#endif
tmp_axis = (axisval + 32768) / 256;
joy_l = (joy_l & 0xFF00) | tmp_axis;
#ifdef DEBUG
printf("jx 0x%x tx 0x%x\n",joy_l,tmp_axis);
#endif
}
break;
case 1: /* Y axis*/
Expand All @@ -653,14 +647,8 @@ void pad_update(void)
analog1 |= ANALOG_UP;
}
} else {
#ifdef DEBUG
printf("jy 0x%x ",joy_l);
#endif
tmp_axis = (axisval + 32768) / 256;
joy_l = (joy_l & 0x00FF) | (tmp_axis << 8);
#ifdef DEBUG
printf("jy 0x%x ty 0x%x\n",joy_l,tmp_axis);
#endif
}
break;
case 2: /* X axis */
Expand Down Expand Up @@ -823,10 +811,6 @@ void pad_update(void)
#endif

pad1 = (uint64_t)id<<48 | (uint64_t)buttons<<32 | (uint32_t) joy_r <<16 | (joy_l);
#ifdef DEBUG
printf("id: 0x%x buttons: 0x%x, joy_r: 0x%x joy_l: 0x%x\n",id,buttons,joy_r,joy_l);
printf("pad1: 0x%llx\n",pad1);
#endif
}

uint64_t pad_read(int num)
Expand Down Expand Up @@ -935,6 +919,7 @@ int main (int argc, char **argv)
Config.FrameLimit = 1;
Config.FrameSkip = FRAMESKIP_OFF;
Config.AnalogArrow = 0;
Config.Analog_Mode = 0;

//zear - Added option to store the last visited directory.
strncpy(Config.LastDir, homedir, MAXPATHLEN); /* Defaults to home directory. */
Expand Down Expand Up @@ -1032,6 +1017,7 @@ int main (int argc, char **argv)

// Load config from file.
config_load();
if (Config.Analog_Mode < 0 || Config.Analog_Mode > 2) Config.Analog_Mode = 0;

// Check if LastDir exists.
probe_lastdir();
Expand Down

0 comments on commit 3f13265

Please sign in to comment.