Skip to content

Commit

Permalink
Quanta coisa
Browse files Browse the repository at this point in the history
  • Loading branch information
Humberto committed Jun 8, 2009
1 parent cfee6ad commit 973b5cd
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions prx/hidmouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define PSP_USB_MOUSE "pspmouse"
#define PSP_USB_MOUSE_PID 0x7d

static char g_inputs[4] __attribute__ ((aligned(64))) = { 0x00, 0x01, 0x02, 0x00 };
static char g_inputs[4] __attribute__ ((aligned(64))) = { 0x00, 0x00, 0x00, 0x00 };
static struct UsbbdDeviceRequest g_request;
static struct UsbbdDeviceRequest g_reportrequest;
static SceUID g_mainalarm = -1;
Expand Down Expand Up @@ -318,8 +318,26 @@ static void send_inputs (void);
static
SceUInt alarm_handler (void *common)
{
SceCtrlData pad;
sceCtrlSetSamplingCycle (0);
sceCtrlSetSamplingMode (1);
if (sceCtrlReadBufferPositive (&pad, 1) >= 0) {
g_inputs[1] = (pad.Lx >> 4) - 8;
g_inputs[2] = (pad.Ly >> 4) - 8;
g_inputs[0] = g_inputs[3] = 0;
if (pad.Buttons & PSP_CTRL_UP)
g_inputs[3] = +1;
if (pad.Buttons & PSP_CTRL_DOWN)
g_inputs[3] = -1;
if (pad.Buttons & PSP_CTRL_CROSS)
g_inputs[0] |= 1;
if (pad.Buttons & PSP_CTRL_CIRCLE)
g_inputs[0] |= 2;
if (pad.Buttons & PSP_CTRL_SQUARE)
g_inputs[0] |= 4;
}
send_inputs ();
return 10000;
return 50000;
}

static
Expand Down Expand Up @@ -371,7 +389,7 @@ static
int usb_attach (int usb_version)
{
Kprintf ("usb_attach %d\n", usb_version);
if (g_mainalarm < 0) g_mainalarm = sceKernelSetAlarm (10000, &alarm_handler, NULL);
if (g_mainalarm < 0) g_mainalarm = sceKernelSetAlarm (50000, &alarm_handler, NULL);
return 0;
}

Expand Down Expand Up @@ -438,6 +456,9 @@ int mouse_start (void)
ret = sceUsbActivate (PSP_USB_MOUSE_PID);
if (ret < 0) return ret;

sceCtrlSetSamplingCycle (0);
sceCtrlSetSamplingMode (1);

return ret;
}

Expand Down

0 comments on commit 973b5cd

Please sign in to comment.