Actually support the classic controller

This commit is contained in:
simon.kagstrom 2009-01-11 12:52:09 +00:00
parent 128c1ad142
commit 5bc645cfb5
3 changed files with 44 additions and 13 deletions

View File

@ -1,4 +1,8 @@
version 3:
* Fixed changelog format
* Bought a Classic controller and fixed so that it actually works...
* Allow controlling the joystick via the keyboard for the host (basically
to ease debugging)
@ -6,23 +10,35 @@ version 3:
version 2:
* Also support the .prg and p00, s00 formats. Only .prg has been tested.
* Added support for classic controllers. NOTE: This is untested since I don't
have a classic controller!
* Fixed some corner-cases in the prefs setting to avoid loosing key bindings etc
* Improve keyboard bindings to handle press and release correctly and also
both controllers at the same time (key is released when the last controller releases
it)
* Handle keycode 0 and therefore make del work
* Remove the 1-1 graphics option and make stretched the default. Should avoid
"helpful and constructive" messages such as
http://wiinewz.com/forums/nintendo-news/91829-frodo-v1-0-a.html#post580580
* Improved speed just a bit (by enabling compiler optimization!)
* Only save prefs on exit
* Pause sound in the menu
* Handle very long filenames better (thanks Corey89 for pointing this out)
* Corrected file sorting
* Better Makefile
* More keycodes added (C=)
* More keycodes added (C= etc)
-- Simon Kagstrom <simon.kagstrom@gmail.com>, Sat Jan 10 17:26:32 CET 2009

View File

@ -650,13 +650,13 @@ uint8 C64::poll_joystick(int port)
if (wpad_other->exp.type == WPAD_EXP_CLASSIC)
held_classic_other = wpad_other->exp.classic.btns_held;
if ( (held & WPAD_BUTTON_UP) || (held_classic & CLASSIC_CTRL_BUTTON_UP) )
if ( (held & WPAD_BUTTON_UP) || (held_classic & CLASSIC_CTRL_BUTTON_LEFT) )
j &= 0xfb; // Left
if ( (held & WPAD_BUTTON_DOWN) || (held_classic & CLASSIC_CTRL_BUTTON_DOWN) )
if ( (held & WPAD_BUTTON_DOWN) || (held_classic & CLASSIC_CTRL_BUTTON_RIGHT) )
j &= 0xf7; // Right
if ( (held & WPAD_BUTTON_RIGHT) || (held_classic & CLASSIC_CTRL_BUTTON_RIGHT) )
if ( (held & WPAD_BUTTON_RIGHT) || (held_classic & CLASSIC_CTRL_BUTTON_UP) )
j &= 0xfe; // Up
if ( (held & WPAD_BUTTON_LEFT) || (held_classic & CLASSIC_CTRL_BUTTON_LEFT) )
if ( (held & WPAD_BUTTON_LEFT) || (held_classic & CLASSIC_CTRL_BUTTON_DOWN) )
j &= 0xfd; // Down
if ( (held & WPAD_BUTTON_2) || (held_classic & CLASSIC_CTRL_BUTTON_A) )
j &= 0xef; // Button
@ -676,6 +676,9 @@ uint8 C64::poll_joystick(int port)
extra_keys[CLASSIC_L] = (held_classic | held_classic_other) & CLASSIC_CTRL_BUTTON_FULL_L;
extra_keys[CLASSIC_R] = (held_classic | held_classic_other) & CLASSIC_CTRL_BUTTON_FULL_R;
extra_keys[WIIMOTE_PLUS] = (held_classic | held_classic_other) & CLASSIC_CTRL_BUTTON_PLUS;
extra_keys[WIIMOTE_MINUS] = (held_classic | held_classic_other) & CLASSIC_CTRL_BUTTON_MINUS;
for (int i = 0; i < N_WIIMOTE_BINDINGS; i++)
{
int kc = ThePrefs.JoystickKeyBinding[i];

View File

@ -261,8 +261,10 @@ void menu_fini(menu_t *p_menu)
static uint32_t wait_key_press(void)
{
SDL_Event ev;
bool classic_keys_changed = false;
Uint32 classic_last = 0;
uint32_t keys = 0;
while (1)
{
#if defined(GEKKO)
@ -276,17 +278,27 @@ static uint32_t wait_key_press(void)
remote_keys = wpad->btns_d | wpad_other->btns_d;
classic_keys = 0;
// Check classic controller as well
if (wpad->exp.type == WPAD_EXP_CLASSIC)
classic_keys = wpad->exp.classic.btns_held | wpad_other->exp.classic.btns_held;
/* Check classic controllers as well */
if (wpad->exp.type == WPAD_EXP_CLASSIC ||
wpad_other->exp.type == WPAD_EXP_CLASSIC)
{
classic_keys = wpad->exp.classic.btns | wpad_other->exp.classic.btns;
if ( (remote_keys & WPAD_BUTTON_DOWN) || (classic_keys & CLASSIC_CTRL_BUTTON_DOWN) )
classic_keys_changed = classic_keys != classic_last;
classic_last = classic_keys;
/* No repeat, thank you */
if (!classic_keys_changed)
classic_keys = 0;
}
if ( (remote_keys & WPAD_BUTTON_DOWN) || (classic_keys & CLASSIC_CTRL_BUTTON_RIGHT) )
keys |= KEY_RIGHT;
if ( (remote_keys & WPAD_BUTTON_UP) || (classic_keys & CLASSIC_CTRL_BUTTON_UP) )
if ( (remote_keys & WPAD_BUTTON_UP) || (classic_keys & CLASSIC_CTRL_BUTTON_LEFT) )
keys |= KEY_LEFT;
if ( (remote_keys & WPAD_BUTTON_LEFT) || (classic_keys & CLASSIC_CTRL_BUTTON_LEFT) )
if ( (remote_keys & WPAD_BUTTON_LEFT) || (classic_keys & CLASSIC_CTRL_BUTTON_DOWN) )
keys |= KEY_DOWN;
if ( (remote_keys & WPAD_BUTTON_RIGHT) || (classic_keys & CLASSIC_CTRL_BUTTON_RIGHT) )
if ( (remote_keys & WPAD_BUTTON_RIGHT) || (classic_keys & CLASSIC_CTRL_BUTTON_UP) )
keys |= KEY_UP;
if ( (remote_keys & WPAD_BUTTON_PLUS) || (classic_keys & CLASSIC_CTRL_BUTTON_PLUS) )
keys |= KEY_PAGEUP;