#define CE_INTVAL(val) \
{ #val, sizeof(val), &val }
+#define CE_INTVAL_N(name, val) \
+ { name, sizeof(val), &val }
+
#define CE_INTVAL_P(val) \
{ #val, sizeof(pl_rearmed_cbs.val), &pl_rearmed_cbs.val }
CE_INTVAL(in_type_sel1),
CE_INTVAL(in_type_sel2),
CE_INTVAL(analog_deadzone),
+ CE_INTVAL_N("adev0_is_nublike", in_adev_is_nublike[0]),
+ CE_INTVAL_N("adev1_is_nublike", in_adev_is_nublike[1]),
CE_INTVAL_V(frameskip, 3),
CE_INTVAL_P(gpu_peops.iUseDither),
CE_INTVAL_P(gpu_peops.dwActFixes),
return 0;
}
+static const char h_nubmode[] = "Maps nub-like analog controls to PSX ones better\n"
+ "Might cause problems with real analog sticks";
static const char *adevnames[IN_MAX_DEVS + 2];
static int stick_sel[2];
static menu_entry e_menu_keyconfig_analog[] =
{
- mee_enum ("Left stick (L3)", 0, stick_sel[0], adevnames),
- mee_range(" X axis", 0, in_adev_axis[0][0], 0, 7),
- mee_range(" Y axis", 0, in_adev_axis[0][1], 0, 7),
- mee_enum ("Right stick (R3)", 0, stick_sel[1], adevnames),
- mee_range(" X axis", 0, in_adev_axis[1][0], 0, 7),
- mee_range(" Y axis", 0, in_adev_axis[1][1], 0, 7),
+ mee_enum ("Left stick (L3)", 0, stick_sel[0], adevnames),
+ mee_range (" X axis", 0, in_adev_axis[0][0], 0, 7),
+ mee_range (" Y axis", 0, in_adev_axis[0][1], 0, 7),
+ mee_onoff_h(" nub mode", 0, in_adev_is_nublike[0], 1, h_nubmode),
+ mee_enum ("Right stick (R3)", 0, stick_sel[1], adevnames),
+ mee_range (" X axis", 0, in_adev_axis[1][0], 0, 7),
+ mee_range (" Y axis", 0, in_adev_axis[1][1], 0, 7),
+ mee_onoff_h(" nub mode", 0, in_adev_is_nublike[1], 1, h_nubmode),
mee_end,
};
int in_type1, in_type2;
int in_a1[2] = { 127, 127 }, in_a2[2] = { 127, 127 };
int in_adev[2] = { -1, -1 }, in_adev_axis[2][2] = {{ 0, 1 }, { 0, 1 }};
+int in_adev_is_nublike[2];
int in_keystate, in_state_gun;
int in_enable_vibration;
void *tsdev;
}
#ifndef MAEMO
+/* adjust circle-like analog inputs to better match
+ * more square-like analogs in PSX */
+static void update_analog_nub_adjust(int *x_, int *y_)
+{
+ static const int scale[] = { 0, 0, 0, 12, 30, 60, 75, 60, 60 };
+ int x = *x_;
+ int y = *y_;
+
+ x += x * scale[abs(y) / 16] >> 8;
+ y += y * scale[abs(x) / 16] >> 8;
+
+ *x_ = x;
+ *y_ = y;
+}
+
static void update_analogs(void)
{
int *nubp[2] = { in_a1, in_a2 };
+ int vals[2];
int i, a, v, ret;
for (i = 0; i < 2; i++)
continue;
for (a = 0; a < 2; a++) {
- nubp[i][a] = 127;
+ vals[a] = 0;
ret = in_update_analog(in_adev[i], in_adev_axis[i][a], &v);
- if (ret == 0) {
- v = v / (IN_ABS_RANGE / 128) + 127;
- nubp[i][a] = v < 0 ? 0 : v;
- }
+ if (ret == 0)
+ vals[a] = 128 * v / IN_ABS_RANGE;
}
+
+ if (in_adev_is_nublike[i])
+ update_analog_nub_adjust(&vals[0], &vals[1]);
+
+ for (a = 0; a < 2; a++) {
+ v = vals[a] + 127;
+ if (v < 0) v = 0;
+ else if (v > 255) v = 255;
+ nubp[i][a] = v;
+ }
+
}
//printf("%4d %4d %4d %4d\n", in_a1[0], in_a1[1], in_a2[0], in_a2[1]);
}