How can I connect a gamepad to MatLab?

조회 수: 27 (최근 30일)
Raffaele Modugno
Raffaele Modugno 2017년 6월 2일
답변: Arnav Mendiratta 2017년 6월 12일
I should connect to Matlab a keyboard that is ridden by the pc as a Gamepad (I checked that it’s already installed and recognised by the pc using a tester). According to the instructions I have, I first typed daqregister('joy') in the command window for register the dll. Using Matlab 2016b was not working, so as I read in a forum I downloaded an older 32 bit version (first the 2013b then the 2011b) and it worked showing me: ans =
'joy.dll' successfully registered.
Then I typed the analoginput('joy',ID) function but it appeared:
Error using analoginput (line 142) Invalid enum value.
I tried to put as (ID) different numbers , seen that it should be 1, but with the same results. Do someone know how could I solve the problem? Or if not if there is just another way to make MatLab read the joypad? Thanks a lot.

답변 (1개)

Arnav Mendiratta
Arnav Mendiratta 2017년 6월 12일
"daqregister" is an old way of registering and using Analog devices within MATLAB. This functionality has been removed since MATLAB R2016a. Since the newer release, you do not need to register an adaptor (which is what "daqregister" was used for) if you are using session-based interface. If you are using newer release, I recommend setting up your device by following the steps as described in the documentation here:
https://www.mathworks.com/help/daq/hardware-discovery-and-session-setup.html
You may use this example as a starting point to set up your device.
I also recommend going through this short video if you are looking to integrate a gamepad controller with a Simulink model.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by