Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ouya Controller doesn't fully work #13

Closed
slime73 opened this issue Jan 6, 2014 · 21 comments
Closed

Ouya Controller doesn't fully work #13

slime73 opened this issue Jan 6, 2014 · 21 comments
Labels
bug Something isn't working

Comments

@slime73
Copy link
Member

slime73 commented Jan 6, 2014

Original report by Landon “Karai” Manning (Bitbucket: karai17, GitHub: karai17).


The directional pad seems to work, but other buttons do not. Probably an SDL issue.

@slime73
Copy link
Member Author

slime73 commented Jan 6, 2014

Original comment by Pavol Rusnak (Bitbucket: prusnak, GitHub: prusnak).


How do you test?

@slime73
Copy link
Member Author

slime73 commented Jan 6, 2014

Original comment by Landon “Karai” Manning (Bitbucket: karai17, GitHub: karai17).


#!lua

function love.joystickpressed(joystick, button)
  love.graphics.print(joystick .. " - " .. button, 100, 100)
  print(joystick, button)
end

This should print out every recognized button on any controller. If a button does not print anything, love/SDL is not registering said button.

@slime73
Copy link
Member Author

slime73 commented Jan 7, 2014

Original comment by Colby Klein (Bitbucket: shakesoda, GitHub: shakesoda).


I wasn't getting anything with my Ouya controllers in my testing, googling showed that SDL2 has had some work on controllers (among other things) in Android post-2.0.1 (in HG tip) so this just might be resolvable by bumping the SDL version.

@slime73
Copy link
Member Author

slime73 commented Jan 8, 2014

Original comment by Martin Felis (Bitbucket: MartinFelis, GitHub: MartinFelis).


I have just updated SDL2 to the latest development version (changeset d4a88c49247e). A new alpha build can be found at http://fysx.org/~martin/shared/love_android_sdl2_alpha5.apk.

The gamepad API for Android was introduced with API level 12, therefore it will only 3.1 and above.

@slime73
Copy link
Member Author

slime73 commented Jan 9, 2014

Original comment by Colby Klein (Bitbucket: shakesoda, GitHub: shakesoda).


Controllers are working great now! The only issue I've found so far is that the Ouya system button doesn't respond (and it should - it's usually used for pause).

@slime73
Copy link
Member Author

slime73 commented Jan 9, 2014

Original comment by Landon “Karai” Manning (Bitbucket: karai17, GitHub: karai17).


perhaps it is registering as a hat instead of a button, or some other wonky issue?

@slime73
Copy link
Member Author

slime73 commented Jan 10, 2014

Original comment by Martin Felis (Bitbucket: MartinFelis, GitHub: MartinFelis).


I fear it requires adjustment of the file https://hg.libsdl.org/SDL/file/2e4f1bd21196/src/joystick/SDL_gamecontrollerdb.h. However I do not have such a controller at hand so I cannot test it. Maybe with help from the SDL2 mailing list a fix could be made.

@slime73
Copy link
Member Author

slime73 commented Jan 10, 2014

Original comment by Alex Szpakowski (Bitbucket: slime73, GitHub: slime73).


You can add / change game controller mappings in SDL with SDL_GameControllerAddMapping. This is exposed in LÖVE (although a bit differently) with love.joystick.setGamepadMapping.

@slime73
Copy link
Member Author

slime73 commented Jan 12, 2014

Original comment by Carlo Cabanilla (Bitbucket: clofresh, GitHub: clofresh).


The ouya controller wasn't working for me as a gamepad until I manually mapped the buttons:

gamepads = {
    -- ouya controller
    ["4f5559412047616d6520436f6e74726f"] = {
        {"a", "button", 6},
        {"b", "button", 7},
        {"x", "button", 9},
        {"y", "button", 10},
        {"leftstick", "button", 16},
        {"rightstick", "button", 17},
        {"leftshoulder", "button", 12},
        {"rightshoulder", "button", 13},
        {"dpup", "button", 1},
        {"dpdown", "button", 2},
        {"dpleft", "button", 3},
        {"dpright", "button", 4},
        {"leftx", "axis", 1},
        {"lefty", "axis", 2},
        {"rightx", "axis", 4},
        {"righty", "axis", 5},
        {"triggerleft", "axis", 3},
        {"triggerright", "axis", 6},
    }
}

 for guid, mappings in pairs(gamepads) do
    for i, mapping in pairs(mappings) do
        love.joystick.setGamepadMapping(guid, unpack(mapping))
    end
end

@slime73
Copy link
Member Author

slime73 commented Jan 20, 2014

Original comment by Martin Felis (Bitbucket: MartinFelis, GitHub: MartinFelis).


How about the system button? Is it reporting something? Or does it do anything?

@slime73
Copy link
Member Author

slime73 commented Jan 20, 2014

Original comment by Carlo Cabanilla (Bitbucket: clofresh, GitHub: clofresh).


The system button doesn't register as anything. This is how I discovered what everything does: https://gist.github.com/clofresh/8531100

@slime73
Copy link
Member Author

slime73 commented Jan 20, 2014

Original comment by Jairo Luiz (Bitbucket: tangzero, GitHub: tangzero).


I think the pause button is mapped as a keyboard button named pause...

@slime73
Copy link
Member Author

slime73 commented Jan 20, 2014

Original comment by Pavol Rusnak (Bitbucket: prusnak, GitHub: prusnak).


I used code from previous comment to create a config for Moga Pro controller.

gamepads = {
    -- moga pro controller
    ["42726f6164636f6d20426c7565746f6f"] = {
        {"a", "button", 6},
        {"b", "button", 7},
        {"x", "button", 9},
        {"y", "button", 10},
        {"leftshoulder", "button", 12},
        {"rightshoulder", "button", 13},
        {"start", "button", 18},
        {"leftx", "axis", 1},
        {"lefty", "axis", 2},
        {"rightx", "axis", 3},
        {"righty", "axis", 4},
        {"triggerright", "axis", 5},
        {"triggerleft", "axis", 6},
        {"dpx", "axis", 7},
        {"dpy", "axis", 8},

    }
}

Digital Pad behaves like two axis 7 & 8, with values -1,0,1. Not sure what the naming conventions for such setup are.

Feel free to adapt and push to SDL_gamecontrollerdb.h in SDL2.

@slime73
Copy link
Member Author

slime73 commented Jan 20, 2014

Original comment by Alex Szpakowski (Bitbucket: slime73, GitHub: slime73).


For l1/r1 and l2/r2 did you mean to do leftshoulder/rightshoulder and triggerleft/triggerright ?

Feel free to adapt and push to SDL_gamecontrollerdb.h in SDL2.

Also keep in mind if doing this that you'll have to account for button/axis/hat indices starting from 1 in LÖVE's API, and from 0 in SDL's (i.e. you'll need to put button 5 instead of button 6 for the 'a' button in the string used by SDL.)

@slime73
Copy link
Member Author

slime73 commented Jan 20, 2014

Original comment by Pavol Rusnak (Bitbucket: prusnak, GitHub: prusnak).


Alex: Right, you are correct. I fixed the snippet. What about digital pad naming? Is dpx/dpy OK? I could not find an example where digital pad is represented as two axis. All I found were four buttons.

@slime73
Copy link
Member Author

slime73 commented Jan 20, 2014

Original comment by Jairo Luiz (Bitbucket: tangzero, GitHub: tangzero).


I just test. The OUYA menu button is mapped to a key named menu. You can access this key with love.keypressed and love.keyreleased callbacks.

@slime73
Copy link
Member Author

slime73 commented Jan 21, 2014

Original comment by Landon “Karai” Manning (Bitbucket: karai17, GitHub: karai17).


Let's all take a moment to reflect on the thought that someone at OUYA deliberately made the menu button on the controller register as a global key press, instead of a joystick-specific button press. This was a design decision.

-- imnotsorry.lua
function love.keypressed(key, isrepeat)
	if key == "menu" then
		love.joystickpressed(1, key)
	end
end

function love.joystickpressed(joystick, button)
	if button == "menu" then
		-- OUYAAAAAAAAAAAAAAAAAAAAAAAAAAA
	end
end

@slime73
Copy link
Member Author

slime73 commented Jan 21, 2014

Original comment by Carlo Cabanilla (Bitbucket: clofresh, GitHub: clofresh).


Oh weird, glad you figured that out. So that means we won't be able to tell which joystick actually pressed the menu button huh.

@karai17: that'll only work work in love 0.8 since 0.9 passes in joystick objects instead of joystick numbers. You'll probably wanna do

function love.keypressed(key, isrepeat)
    if key == "menu" then
        love.joystickpressed(love.joystick.getJoysticks()[1], key)
    end
end

@slime73
Copy link
Member Author

slime73 commented Jan 21, 2014

Original comment by Landon “Karai” Manning (Bitbucket: karai17, GitHub: karai17).


Heh. The point that this is mind-boggling still stands. :)

@slime73
Copy link
Member Author

slime73 commented Jan 21, 2014

Original comment by Pavol Rusnak (Bitbucket: prusnak, GitHub: prusnak).


JFYI I created bindings for Moga Pro in Steam Big Picture mode as mentioned in SDL_gamecontrollerdb.h:

https://bugzilla.libsdl.org/show_bug.cgi?id=2357

I think you want to do the same for Ouya controller.

@slime73
Copy link
Member Author

slime73 commented Jan 21, 2014

Original comment by Martin Felis (Bitbucket: MartinFelis, GitHub: MartinFelis).


So I guess the Ouya controller then works (somewhat mind-boggling), right? At least it does not seem to be an issue of the port, rather of SDL or the controller itself.

Feel free to re-open if I did not read correctly or you do not agree.

@slime73 slime73 closed this as completed Jan 21, 2014
@slime73 slime73 added minor bug Something isn't working labels Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant