More progress towards 2nd gameport support
This commit is contained in:
@@ -91,7 +91,7 @@ joystick_close(void)
|
||||
}
|
||||
|
||||
static int
|
||||
joystick_get_axis(int gameport, int joystick_nr, int mapping)
|
||||
joystick_get_axis(int joystick_nr, int mapping)
|
||||
{
|
||||
if (mapping & POV_X) {
|
||||
switch (plat_joystick_state[joystick_nr].p[mapping & 3]) {
|
||||
@@ -128,9 +128,9 @@ joystick_get_axis(int gameport, int joystick_nr, int mapping)
|
||||
}
|
||||
|
||||
void
|
||||
joystick_process(void)
|
||||
joystick_process(uint8_t gp)
|
||||
{
|
||||
if (!joystick_type)
|
||||
if (!joystick_type[gp])
|
||||
return;
|
||||
|
||||
SDL_JoystickUpdate();
|
||||
@@ -146,44 +146,44 @@ joystick_process(void)
|
||||
|
||||
#if 0
|
||||
pclog("joystick %i - x=%i y=%i b[0]=%i b[1]=%i %i\n", js,
|
||||
joystick_state[0][js].x,
|
||||
joystick_state[0][js].y,
|
||||
joystick_state[0][js].b[0],
|
||||
joystick_state[0][js].b[1],
|
||||
joysticks_present);
|
||||
joystick_state[gp][js].x,
|
||||
joystick_state[gp][js].y,
|
||||
joystick_state[gp][js].b[0],
|
||||
joystick_state[gp][js].b[1],
|
||||
joysticks_present[gp]);
|
||||
#endif
|
||||
}
|
||||
|
||||
for (int js = 0; js < joystick_get_max_joysticks(joystick_type); js++) {
|
||||
if (joystick_state[0][js].plat_joystick_nr) {
|
||||
int joystick_nr = joystick_state[0][js].plat_joystick_nr - 1;
|
||||
for (int js = 0; js < joystick_get_max_joysticks(joystick_type[gp]); js++) {
|
||||
if (joystick_state[gp][js].plat_joystick_nr) {
|
||||
int joystick_nr = joystick_state[gp][js].plat_joystick_nr - 1;
|
||||
|
||||
for (int axis_nr = 0; axis_nr < joystick_get_axis_count(joystick_type); axis_nr++)
|
||||
joystick_state[0][js].axis[axis_nr] = joystick_get_axis(0, joystick_nr, joystick_state[0][js].axis_mapping[axis_nr]);
|
||||
for (int axis_nr = 0; axis_nr < joystick_get_axis_count(joystick_type[gp]); axis_nr++)
|
||||
joystick_state[gp][js].axis[axis_nr] = joystick_get_axis(joystick_nr, joystick_state[gp][js].axis_mapping[axis_nr]);
|
||||
|
||||
for (int button_nr = 0; button_nr < joystick_get_button_count(joystick_type); button_nr++)
|
||||
joystick_state[0][js].button[button_nr] = plat_joystick_state[joystick_nr].b[joystick_state[0][js].button_mapping[button_nr]];
|
||||
for (int button_nr = 0; button_nr < joystick_get_button_count(joystick_type[gp]); button_nr++)
|
||||
joystick_state[gp][js].button[button_nr] = plat_joystick_state[joystick_nr].b[joystick_state[gp][js].button_mapping[button_nr]];
|
||||
|
||||
for (int pov_nr = 0; pov_nr < joystick_get_pov_count(joystick_type); pov_nr++) {
|
||||
int x = joystick_get_axis(0, joystick_nr, joystick_state[0][js].pov_mapping[pov_nr][0]);
|
||||
int y = joystick_get_axis(0, joystick_nr, joystick_state[0][js].pov_mapping[pov_nr][1]);
|
||||
for (int pov_nr = 0; pov_nr < joystick_get_pov_count(joystick_type[gp]); pov_nr++) {
|
||||
int x = joystick_get_axis(joystick_nr, joystick_state[gp][js].pov_mapping[pov_nr][0]);
|
||||
int y = joystick_get_axis(joystick_nr, joystick_state[gp][js].pov_mapping[pov_nr][1]);
|
||||
double angle = (atan2((double) y, (double) x) * 360.0) / (2 * M_PI);
|
||||
double magnitude = sqrt((double) x * (double) x + (double) y * (double) y);
|
||||
|
||||
if (magnitude < 16384)
|
||||
joystick_state[0][js].pov[pov_nr] = -1;
|
||||
joystick_state[gp][js].pov[pov_nr] = -1;
|
||||
else
|
||||
joystick_state[0][js].pov[pov_nr] = ((int) angle + 90 + 360) % 360;
|
||||
joystick_state[gp][js].pov[pov_nr] = ((int) angle + 90 + 360) % 360;
|
||||
}
|
||||
} else {
|
||||
for (int axis_nr = 0; axis_nr < joystick_get_axis_count(joystick_type); axis_nr++)
|
||||
joystick_state[0][js].axis[axis_nr] = 0;
|
||||
for (int axis_nr = 0; axis_nr < joystick_get_axis_count(joystick_type[gp]); axis_nr++)
|
||||
joystick_state[gp][js].axis[axis_nr] = 0;
|
||||
|
||||
for (int button_nr = 0; button_nr < joystick_get_button_count(joystick_type); button_nr++)
|
||||
joystick_state[0][js].button[button_nr] = 0;
|
||||
for (int button_nr = 0; button_nr < joystick_get_button_count(joystick_type[gp]); button_nr++)
|
||||
joystick_state[gp][js].button[button_nr] = 0;
|
||||
|
||||
for (int pov_nr = 0; pov_nr < joystick_get_pov_count(joystick_type); pov_nr++)
|
||||
joystick_state[0][js].pov[pov_nr] = -1;
|
||||
for (int pov_nr = 0; pov_nr < joystick_get_pov_count(joystick_type[gp]); pov_nr++)
|
||||
joystick_state[gp][js].pov[pov_nr] = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user