Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Peter_123 · Aug 10, 2017 at 03:51 PM · pluginpluginslinuxnative pluginusb

How to access USB on Linux

I'm trying to access a USB device from Unity. There are some additional hurdles as the finished game is supposed to run on a Linux machine continuously reading input from the device (which is plugged into a USB slot on the motherboard).

I've got code for reading and interpreting information passed from the device, it's VendorID and ProductID so I don't need to reverse engineer anything, just access it. Another game made for the device (c++) uses built in Libusb library that is already in linux. It references #include and gets access like this:

 usb_init();
 usb_find_busses();
 usb_find_devices();
 for (bus = usb_busses; bus; bus = bus->next)
     {
         for (dev = bus->devices; dev; dev = dev->next)
         {
             if ((dev->descriptor.idVendor == vid) && (dev->descriptor.idProduct == pid))
             {
                 return dev;
             }
         }
     }

Than it keeps reading from this device:

 usb_interrupt_read(handle, 1, (char*)Inbuf, PKT_SIZE*NUM_MATS, 50);

Inbuf then is interpreted as the game inputs.

I've got libraries: libusb (written in C++, so it's a native plugin in Unity) and c# wrapper for it libusbdotnet . With that and IDs for that device I should be able to access it (as a test I could crash Unity accessing a USB keyboard... on a PC Windows machine). But, when I compile a Linux build from Unity, the libusb.dll native plugin is dropped. There is not even an option to keep it for Linux in plugin inspector. Even If I manually add it to the build to Plugin directory it doesn't load and game throws missing dll file. Libusb is already on the OS on the Linux machine. Can I somehow access that library from Unity? Or is there a way to "sneak in" the .dll with the Linux build? Or Am I going about it ass-backwards and it should be done in a completely different way?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Peter_123 · Aug 17, 2017 at 05:15 PM

Well, I've found the answer. I had to update libusb on the linux machine and than I've copied .so file from /lib folder on that computer. After adding it to plugins in /Assets it builds correctly.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

71 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Linux build is putting libNative.so in wrong place 1 Answer

EntryPointNotFoundException - .so plugin (Linux) 0 Answers

Project Tango or Vuforia Android plugin support on Unity for Linux 2 Answers

android time cheat plugin problem with broadcastreceiver 1 Answer

Do Native Mobile Plugins Require Pro? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges