Caanoo / WIZ Caanoo Sdl Keymap Using Joystick


Rikku2000

Member
Joined
Jul 2, 2010
Messages
348
Here my SDL config for Caanoo with SDL_Joystick:
Code:
				SDL_Joystick* joy;

				if (SDL_Init(SDL_INIT_JOYSTICK) < 0)
					printf("Couldn't initialize SDL: %s\n", SDL_GetError ());

				joy = SDL_JoystickOpen(0);

				while (SDL_PollEvent(&event)) {
					if(SDL_JoystickGetAxis(joy, 0) < -3200) { // X Axis (Left)
					} else if(SDL_JoystickGetAxis(joy, 0) > +3200) { // X Axis (Right)
					}

					if(SDL_JoystickGetAxis(joy, 1) < -3200) { // Y Axis (Up)
					} else if(SDL_JoystickGetAxis(joy, 1) > +3200) { // Y Axis (Down)	
					}

					if( SDL_JoystickGetButton(joy, 0) ) { // B
					}

					if( SDL_JoystickGetButton(joy, 1) ) { // A
					}

					if( SDL_JoystickGetButton(joy, 2) ) { // X
					}

					if( SDL_JoystickGetButton(joy, 3) ) { // Y
					}

					if( SDL_JoystickGetButton(joy, 4) ) { // L
					}

					if( SDL_JoystickGetButton(joy, 5) ) { // R
					}

					if( SDL_JoystickGetButton(joy, 6) ) { // Home
					}

					if( SDL_JoystickGetButton(joy, 7) ) { // Hold
					}

					if( SDL_JoystickGetButton(joy, 8) ) { // Help 1
					}

					if( SDL_JoystickGetButton(joy, 9) ) { // Help 2
					}

					if( SDL_JoystickGetButton(joy, 10) ) { // Stick Press
					}
				}
 
Rikku2000 said:
Code:
					if( SDL_JoystickGetButton(joy, 0) ) { // B
					}

					if( SDL_JoystickGetButton(joy, 1) ) { // A
					}

					if( SDL_JoystickGetButton(joy, 2) ) { // X
					}

					if( SDL_JoystickGetButton(joy, 3) ) { // Y
					}
Your values are wrong(for Caanoo).
Here right ones:
Code:
enum
{
     BTN_A = 0,     //       A /             1
     BTN_X = 1,     //       X /             2
     BTN_B = 2,     //       B /             3
     BTN_Y = 3,     //       Y /             4
     BTN_L = 4,     //       L /         5, L1
     BTN_R = 5,     //       R /         6, L2
     BTN_HOME = 6,  //    Home /         7, R1
     BTN_HOLD = 7,  //    Hold /         8, R2
     BTN_HELP1 = 8, //  Help I /        Select
     BTN_HELP2 = 9, // Help II /         Start
     BTN_TACT = 10, //    Tact / L Thumb Stick
};
 
Last edited by a moderator:
than let's be complete, my Joystick handling class header (I use it with SDL), WIZ included:

Code:
		static const int CAANOO_JOYSTICK_MIN = -32768;
		static const int CAANOO_JOYSTICK_MAX = 32767;

		enum CaanooAxes {
			CAANOO_AXIS_X = 0,
			CAANOO_AXIS_Y = 1
		};

		enum CaanooButtons {
			CAANOO_BUTTON_A = 0,
			CAANOO_BUTTON_X = 1,
			CAANOO_BUTTON_B = 2,
			CAANOO_BUTTON_Y = 3,
			CAANOO_BUTTON_L = 4,
			CAANOO_BUTTON_R = 5,
			CAANOO_BUTTON_HOME = 6,
			CAANOO_BUTTON_1 = 8,
			CAANOO_BUTTON_2 = 9,
			CAANOO_BUTTON_JOY = 10
		};

		enum WizButtons {
			WIZ_BUTTON_UP = 0,
			WIZ_BUTTON_LEFT = 2,
			WIZ_BUTTON_DOWN = 4,
			WIZ_BUTTON_RIGHT = 6,
			WIZ_BUTTON_MENU = 8,
			WIZ_BUTTON_SELECT = 9,
			WIZ_BUTTON_VOL_UP = 16,
			WIZ_BUTTON_VOL_DOWN = 17,
			WIZ_BUTTON_A = 12,
			WIZ_BUTTON_X = 14,
			WIZ_BUTTON_B = 13,
			WIZ_BUTTON_Y = 15,
			WIZ_BUTTON_L = 10,
			WIZ_BUTTON_R = 11
		};
 
hehe, i forgot about the HOLD btn :)
it's the opposite position on the poweron button
it would explain the missing number (check my enum, there's nothing at btn 7)
 
The HOLD button can be used for things such as pausing in MAME.
It'd be useful if more emu-devs used this to pause/lock the emulation, since input isn't possible.
 
CAANOO_BUTTON_JOY(10) doesn't work for me (stick press I suppose). All other buttons work fine. Is there any difference in handling this button? Does anyone suсceed using it?
 
Back
Top