- Tested with Final Doom. Worked great.
int in_analog_left[8][2] = { { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 } };
int in_analog_right[8][2] = { { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 } };
unsigned short in_keystate[PORTS_NUMBER];
+int in_mouse[8][2];
int multitap1 = 0;
int multitap2 = 0;
int in_enable_vibration = 1;
in_type[port] = PSE_PAD_TYPE_NEGCON;
else if (strcmp(var.value, "guncon") == 0)
in_type[port] = PSE_PAD_TYPE_GUNCON;
+ else if (strcmp(var.value, "mouse") == 0)
+ in_type[port] = PSE_PAD_TYPE_MOUSE;
else if (strcmp(var.value, "none") == 0)
in_type[port] = PSE_PAD_TYPE_NONE;
// else 'default' case, do nothing
case PSE_PAD_TYPE_NEGCON:
update_input_negcon(i, ret);
break;
+ case PSE_PAD_TYPE_MOUSE:
+ {
+ /* mouse x/y movement, range -128 to +127 */
+ float accum_x = 0, accum_y = 0;
+
+ float x = input_state_cb(i, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
+ float y = input_state_cb(i, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y);
+
+ accum_x += x;
+ accum_y += y;
+
+ if (accum_x > 127)
+ accum_x = 127;
+ else if (accum_x < -128)
+ accum_x = -128;
+
+ if (accum_y > 127)
+ accum_y = 127;
+ else if (accum_y < -128)
+ accum_y = -128;
+
+ in_mouse[i][0] = (int)accum_x;
+ in_mouse[i][1] = (int)accum_y;
+
+ /* mouse button state */
+ if (input_state_cb(i, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT))
+ in_keystate[i] |= 1 << 11;
+
+ if (input_state_cb(i, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT))
+ in_keystate[i] |= 1 << 10;
+
+ break;
+ }
default:
// Query digital inputs
for (j = 0; j < RETRO_PSX_MAP_LEN; j++)
{ "dualshock", NULL },
{ "negcon", NULL },
{ "guncon", NULL },
+ { "mouse", NULL },
{ "none", NULL },
{ NULL, NULL },
},
{ "dualshock", NULL },
{ "negcon", NULL },
{ "guncon", NULL },
+ { "mouse", NULL },
{ "none", NULL },
{ NULL, NULL },
},
{ "dualshock", NULL },
{ "negcon", NULL },
{ "guncon", NULL },
+ { "mouse", NULL },
{ "none", NULL },
{ NULL, NULL },
},
{ "dualshock", NULL },
{ "negcon", NULL },
{ "guncon", NULL },
+ { "mouse", NULL },
{ "none", NULL },
{ NULL, NULL },
},
{ "dualshock", NULL },
{ "negcon", NULL },
{ "guncon", NULL },
+ { "mouse", NULL },
{ "none", NULL },
{ NULL, NULL },
},
{ "dualshock", NULL },
{ "negcon", NULL },
{ "guncon", NULL },
+ { "mouse", NULL },
{ "none", NULL },
{ NULL, NULL },
},
{ "dualshock", NULL },
{ "negcon", NULL },
{ "guncon", NULL },
+ { "mouse", NULL },
{ "none", NULL },
{ NULL, NULL },
},
{ "dualshock", NULL },
{ "negcon", NULL },
{ "guncon", NULL },
+ { "mouse", NULL },
{ "none", NULL },
{ NULL, NULL },
},
{ "analog", NULL },
{ "dualshock", NULL },
{ "negcon", NULL },
+ { "guncon", NULL },
+ { "mouse", NULL },
{ "none", "hiçbiri" },
{ NULL, NULL },
},
{ "analog", NULL },
{ "dualshock", NULL },
{ "negcon", NULL },
+ { "guncon", NULL },
+ { "mouse", NULL },
{ "none", "hiçbiri" },
{ NULL, NULL },
},
{ "analog", NULL },
{ "dualshock", NULL },
{ "negcon", NULL },
+ { "guncon", NULL },
+ { "mouse", NULL },
{ "none", "hiçbiri" },
{ NULL, NULL },
},
{ "analog", NULL },
{ "dualshock", NULL },
{ "negcon", NULL },
+ { "guncon", NULL },
+ { "mouse", NULL },
{ "none", "hiçbiri" },
{ NULL, NULL },
},
{ "analog", NULL },
{ "dualshock", NULL },
{ "negcon", NULL },
+ { "guncon", NULL },
+ { "mouse", NULL },
{ "none", "hiçbiri" },
{ NULL, NULL },
},
{ "analog", NULL },
{ "dualshock", NULL },
{ "negcon", NULL },
+ { "guncon", NULL },
+ { "mouse", NULL },
{ "none", "hiçbiri" },
{ NULL, NULL },
},
{ "analog", NULL },
{ "dualshock", NULL },
{ "negcon", NULL },
+ { "guncon", NULL },
+ { "mouse", NULL },
{ "none", "hiçbiri" },
{ NULL, NULL },
},
{ "analog", NULL },
{ "dualshock", NULL },
{ "negcon", NULL },
+ { "guncon", NULL },
+ { "mouse", NULL },
{ "none", "hiçbiri" },
{ NULL, NULL },
},
/* PAD */
static long PADreadPort1(PadDataS *pad) {
int pad_index = pad->requestPadIndex;
- pad->controllerType = in_type[pad_index];
- pad->buttonStatus = ~in_keystate[pad_index];
- if (multitap1 == 1)
- pad->portMultitap = 1;
- else
- pad->portMultitap = 0;
-
- if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGJOY || in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON || in_type[pad_index] == PSE_PAD_TYPE_GUNCON)
- {
- pad->leftJoyX = in_analog_left[pad_index][0];
- pad->leftJoyY = in_analog_left[pad_index][1];
- pad->rightJoyX = in_analog_right[pad_index][0];
- pad->rightJoyY = in_analog_right[pad_index][1];
-
- pad->absoluteX = in_analog_left[pad_index][0];
- pad->absoluteY = in_analog_left[pad_index][1];
- }
- return 0;
+
+ pad->controllerType = in_type[pad_index];
+ pad->buttonStatus = ~in_keystate[pad_index];
+
+ if (multitap1 == 1)
+ pad->portMultitap = 1;
+ else
+ pad->portMultitap = 0;
+
+ if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGJOY || in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON || in_type[pad_index] == PSE_PAD_TYPE_GUNCON)
+ {
+ pad->leftJoyX = in_analog_left[pad_index][0];
+ pad->leftJoyY = in_analog_left[pad_index][1];
+ pad->rightJoyX = in_analog_right[pad_index][0];
+ pad->rightJoyY = in_analog_right[pad_index][1];
+
+ pad->absoluteX = in_analog_left[pad_index][0];
+ pad->absoluteY = in_analog_left[pad_index][1];
+ }
+
+ if (in_type[pad_index] == PSE_PAD_TYPE_MOUSE)
+ {
+ pad->moveX = in_mouse[pad_index][0];
+ pad->moveY = in_mouse[pad_index][1];
+ }
+
+ return 0;
}
static long PADreadPort2(PadDataS *pad) {
int pad_index = pad->requestPadIndex;
-
- pad->controllerType = in_type[pad_index];
- pad->buttonStatus = ~in_keystate[pad_index];
- if (multitap2 == 1)
- pad->portMultitap = 2;
- else
- pad->portMultitap = 0;
-
- if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGJOY || in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON || in_type[pad_index] == PSE_PAD_TYPE_GUNCON)
- {
- pad->leftJoyX = in_analog_left[pad_index][0];
- pad->leftJoyY = in_analog_left[pad_index][1];
- pad->rightJoyX = in_analog_right[pad_index][0];
- pad->rightJoyY = in_analog_right[pad_index][1];
-
- pad->absoluteX = in_analog_left[pad_index][0];
- pad->absoluteY = in_analog_left[pad_index][1];
- }
- return 0;
+
+ pad->controllerType = in_type[pad_index];
+ pad->buttonStatus = ~in_keystate[pad_index];
+
+ if (multitap2 == 1)
+ pad->portMultitap = 2;
+ else
+ pad->portMultitap = 0;
+
+ if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGJOY || in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON || in_type[pad_index] == PSE_PAD_TYPE_GUNCON)
+ {
+ pad->leftJoyX = in_analog_left[pad_index][0];
+ pad->leftJoyY = in_analog_left[pad_index][1];
+ pad->rightJoyX = in_analog_right[pad_index][0];
+ pad->rightJoyY = in_analog_right[pad_index][1];
+
+ pad->absoluteX = in_analog_left[pad_index][0];
+ pad->absoluteY = in_analog_left[pad_index][1];
+ }
+
+ if (in_type[pad_index] == PSE_PAD_TYPE_MOUSE)
+ {
+ pad->moveX = in_mouse[pad_index][0];
+ pad->moveY = in_mouse[pad_index][1];
+ }
+
+ return 0;
}
/* GPU */
extern int in_analog_left[8][2];
extern int in_analog_right[8][2];
extern unsigned short in_keystate[8];
+extern int in_mouse[8][2];
extern int in_adev[2], in_adev_axis[2][2];
extern int in_adev_is_nublike[2];