Author |
Message |
kijjaz
Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
Posted: Fri Nov 24, 2006 5:05 am Post subject:
Using HID in Linux & other HID issues |
|
|
1. HID and Linux
i've been using HID (for keyboard, mouse, joystick) in chuck on WinXP, Mac OS X
but on linux i can only use HID when i'm a superuser. (i'm on debian / ubuntu)
is there anyway i can use chuck as a normal user while chuck can communicate with HID devices?
2. more HID use
are there some new / exciting / experimental HID uses i should here about?
how about PlayStation-style USB controller? <-- is it somewhat like a normal 1-stick joy?
those controller has 2 analog joys..
(and possibly, shaking effect)
and where do i read about designing USB sensors/controller for use with chuck?
and is it accessed with HID?
- - -
no more questions for today ^_^
can't wait to chuck more.
i can chuck all day long, but it's more fun chucking with friends.
especially cyber friends.
('chuck', pronounced in Thai, is a slang for 'masturbate', really.) |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Fri Nov 24, 2006 8:41 am Post subject:
Re: Using HID in Linux & other HID issues |
|
|
kijjaz wrote: | [color=#114477]
2. more HID use
are there some new / exciting / experimental HID uses i should here about?
how about PlayStation-style USB controller? <-- is it somewhat like a normal 1-stick joy?
those controller has 2 analog joys..
(and possibly, shaking effect)
and where do i read about designing USB sensors/controller for use with chuck?
and is it accessed with HID?
|
Plenty! And afordably as well! And it's fun!
There are several companies that make imitations of the Playstayion "dualshock" controler for the PC. Any good computer store should have a few. I even have two joypads here that work both with USB and a Plystation plug.
Generally I think it's safe to asume that any modern joypad with a USB plug will conform to the HID protocol.
Another exciting thing is that you can get cheap (10 euro or so around here) converter plugs that will turn a Playstation (or other console) controler into a USB device that conforms to the HID standard. Right now I'm using a arcade stick and a Beatmania controler here. There are lots of weird and interesting Playstation controlers that could be adapted, maybe those fishing ones can be shaken or tilted?
I have high expectations for the PS3 controler, if anybody gets that to work (not out yet around here...) I'd love to hear about it. _________________ Kassen |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Fri Nov 24, 2006 8:43 am Post subject:
|
|
|
Oh, and we have to admit the ChucK operator is a bit phalic so that makes sense. It's still less phalic then 1/4" jack plugs... _________________ Kassen |
|
Back to top
|
|
|
jksuperstar
Joined: Aug 20, 2004 Posts: 2503 Location: Denver
Audio files: 1
G2 patch files: 18
|
Posted: Fri Nov 24, 2006 10:30 am Post subject:
|
|
|
I haven't targeted chuck for linux (yet, but that's coming soon!), but the usual manner for getting user space usb-anything, is by using the cross-platform "libusb" library. To complement libusb, is libhid, which allows--you guessed it--user space usb hid devices. It's typically used by developers to create specialized or portable usb drivers, but could be used by anything, really.
libusb works by not using the kernel driver, and instead installing a usb module into the kernel, that then speaks with a user space component (or that's my best interpretation of it). I have no idea if/how this effects performance of the device or your machine.
See more here: http://libusb.sourceforge.net/ and here: http://libhid.alioth.debian.org/ |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Fri Nov 24, 2006 10:51 am Post subject:
|
|
|
I just send a mail to Nescivi who did quite a lot of work with HID thingies on LInux (but with SC), she should be able to give some advice.
Linux USB stuff can be weird, a while ago I got a cardreader to work and it turns out it works by pretending to be SCSI... Strange but as long as it works.... _________________ Kassen |
|
Back to top
|
|
|
spencer
Joined: Aug 16, 2006 Posts: 53 Location: northern california
|
Posted: Fri Nov 24, 2006 2:29 pm Post subject:
|
|
|
Howdy, kijjaz,
kijjaz wrote: | 1. HID and Linux
i've been using HID (for keyboard, mouse, joystick) in chuck on WinXP, Mac OS X
but on linux i can only use HID when i'm a superuser. (i'm on debian / ubuntu)
is there anyway i can use chuck as a normal user while chuck can communicate with HID devices? |
For some reason or another, the device files that ChucK uses for HID are by default r/w by root only on the systems ive come across. So, a simple Code: | chmod a+r /dev/input/* | (as root) should allow you to run ChucK HID programs as a normal user. Please let us know if this doesn't work for you.
kijjaz wrote: | 2. more HID use
are there some new / exciting / experimental HID uses i should here about?
how about PlayStation-style USB controller? <-- is it somewhat like a normal 1-stick joy?
those controller has 2 analog joys.. |
Yes! ChucK should support anything marketed as a game controller: gamepads, power gloves, dance pads, etc. And as Kassen mentioned, a cheap PS2/XBox -> USB converter opens up a lot of possibilities too.
kijjaz wrote: | (and possibly, shaking effect) |
We are working on a "HidOut" object which could be used to light up LED's and induce force feedback on supporting HID's. So that should be out sometime soon.
I recently came across a gamepad with a low quality built-in tilt sensor (only senses the direction of tilt in 8 directions), so that can be pretty interesting too if you can find one.
spencer |
|
Back to top
|
|
|
kijjaz
Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
Posted: Fri Nov 24, 2006 8:06 pm Post subject:
|
|
|
wow wow! exciting.
thanks everyone. |
|
Back to top
|
|
|
nescivi
Joined: Mar 23, 2005 Posts: 94 Location: Montreal
|
Posted: Sat Nov 25, 2006 4:04 am Post subject:
|
|
|
probably (if you have a recent kernel) you are using udev to
automatically mount and unmount the hid devices. This has a
configuration file which is in /etc/udev or something. In there there
is a file called udev.rules.
There should be a line that starts with:
event[0-9] and then some settings.
If you add GROUP="audio" to this, then the hid-devices will be mounted
and be accessible by anyone in the group "audio", which will probably
be you if your system is set up correctly.
Do the same for js[0-9]. |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Sat Nov 25, 2006 9:15 am Post subject:
|
|
|
kijjaz wrote: | wow wow! exciting. |
Hint; PlayStation2 conectors are backwards compatible with Playstation1 controlers. The important difference is that PS2 joypads have presure sensitive buttons which is kinda moot since the HID protocol doesn't seem to anticipate those or at least the converters don't convert those.
This is good since PS1 stuff is now old and getting dumped but the PS1 was around for a LONG time and there are many exciting and weird controlers for it. Also; this stuff is meant to be child-proof meaning it should survive touring longer then some of the recent crop of "electronic instruments" that aren't build to take getting thrown on the floor in frustration.
Loads of fun for bargain prices! _________________ Kassen |
|
Back to top
|
|
|
majutsu
Joined: Jun 18, 2006 Posts: 151 Location: New York
Audio files: 1
|
Posted: Sat Nov 25, 2006 10:57 pm Post subject:
|
|
|
i know you have been a big fan of these kassen, and that's cool. but could you (or anyone) tell me what sort of musical events / uses these HID controllers have for you, in specific? I've played with it a little, but i guess i don't have a sense of vision. what sort of things are you doing with it? _________________ All phenomena are atoms in association and dissociation. |
|
Back to top
|
|
|
jksuperstar
Joined: Aug 20, 2004 Posts: 2503 Location: Denver
Audio files: 1
G2 patch files: 18
|
Posted: Sat Nov 25, 2006 11:14 pm Post subject:
|
|
|
I posted a Pd patch (see that forum section) that uses the joystick to act like the transport of a Mackie Control Protocol device. This means, any program like Live, Cubase, etc, will "hear" my joystick buttons as Play, Stop, Rew, Undo, etc. So I now have a set of buttons that are always accessible, and 2 joysticks for controlling effects, pitch bends, or modulations. Not bad for $10US, when Frontier and many others are charging $150US for the same features.
It could've just as easily been notes (actually, they are in the MCP), gates, excitation, loop triggers.... |
|
Back to top
|
|
|
majutsu
Joined: Jun 18, 2006 Posts: 151 Location: New York
Audio files: 1
|
Posted: Sun Nov 26, 2006 9:32 am Post subject:
|
|
|
hmmmmmmm
i see . . .
shit, maybe i'll grab my son's game controllers for 5 min . . . _________________ All phenomena are atoms in association and dissociation. |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Sun Nov 26, 2006 9:41 am Post subject:
|
|
|
majutsu wrote: | i know you have been a big fan of these kassen, and that's cool. but could you (or anyone) tell me what sort of musical events / uses these HID controllers have for you, in specific? I've played with it a little, but i guess i don't have a sense of vision. what sort of things are you doing with it? |
Sorry, little time right now but look at this for now;
https://lists.cs.princeton.edu/pipermail/chuck-users/2006-May/000557.html
That's the first thing I did with joypads and what got me enthousiastic. Not the cleanest code ever but you'll survive. _________________ Kassen |
|
Back to top
|
|
|
kijjaz
Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
Posted: Mon Nov 27, 2006 5:40 am Post subject:
|
|
|
thanks to spencer's
chmod a+r /dev/input/*
works well now. done testing with keyboard, mouse, and joystick.
i should practice making a chuck game soon.
is there any demo chuck games now? |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
|
Back to top
|
|
|
nescivi
Joined: Mar 23, 2005 Posts: 94 Location: Montreal
|
Posted: Wed Nov 29, 2006 11:35 am Post subject:
|
|
|
Ok, now I have a bit more time to elaborate...
if you do not want to have to do the chmod solution, everytime you unplug and plug or reboot your system, you have to make some changes (as root) to the file
/etc/udev/udev.rules
to modify the input devices section as follows:
Code: |
# input devices
KERNEL=="mice", NAME="input/%k"
KERNEL=="mouse[0-9]*", NAME="input/%k", GROUP="audio"
KERNEL=="event[0-9]*", NAME="input/%k", GROUP="audio"
KERNEL=="js[0-9]*", NAME="input/%k", GROUP="audio"
KERNEL=="ts[0-9]*", NAME="input/%k"
KERNEL=="uinput", NAME="input/%k"
|
i.e. you have to add the GROUP settings to it, so that the devices automatically will become part of the group "audio", and if you as a user are also in that group, then you can access the devices.
You could of course also create a separate group for this (such as "hid" or something).
More info about udev settings are in the man pages:
%man udev
[/code] |
|
Back to top
|
|
|
moudi
Joined: Oct 07, 2006 Posts: 63 Location: Bern Switzerland
|
Posted: Sun Dec 03, 2006 10:07 am Post subject:
|
|
|
wow, this one is great fun
it remembers me to my earliest turntable experiences.
regards
/moudi |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Mon Dec 04, 2006 3:49 am Post subject:
|
|
|
Yeah, I'd like to be proud of that one but "pleasantly surprised" is more like it... It's all the fun of turntable-ism with none of the hard stuff, I litterally made it in the first hour after unpacking the joypad I got for ChucKing.
Making similar fun toys is very easy too; basically you can chuck the output of the HID to the input of a suitable sound generator and you are in business. Making *good* instruments is still a matter of having a good idea, some experience and some luck but the actual coding is very easy. The one thing to remember is that if you modulate time/timing you have to make sure the loop can never be length zero ro you will overload the cpu and the cpu won't have the chance to listen to your attempts to get the loop back to non-zero length. _________________ Kassen |
|
Back to top
|
|
|
moudi
Joined: Oct 07, 2006 Posts: 63 Location: Bern Switzerland
|
Posted: Mon Dec 04, 2006 3:52 pm Post subject:
|
|
|
Kassen wrote: | you have to make sure the loop can never be length zero ro you will overload the cpu and the cpu won't have the chance to listen to your attempts to get the loop back to non-zero length. |
yep, i came across this behaviour some days ago.
i accidently chucked a zero-duration to now ...and had to restart miniaudicle.
by the way, it was caused by a very similar behaviour you mentioned about the types of arrays.
i tried this one:
(1/3)::second => now;
i was surprised that the division 1/3 results in an integer of 0, while a division of 1.0/3 results in a float of 0.33333...
regards
/moudi |
|
Back to top
|
|
|
sjef
Joined: Jan 22, 2007 Posts: 6 Location: Netherlands
|
Posted: Thu Jan 25, 2007 12:05 pm Post subject:
|
|
|
Hi,
Just for information, if anyone encounters the 'PC SPeaker' thing:
keyboard ' PC Speaker ' ready
when trying the kb.ck example and no input messages are coming up when you press keys, just change
if( !hi.openKeyboard( 0 ) ) me.exit();
to
if( !hi.openKeyboard( 1 ) ) me.exit();
.. works for me (on Ubuntu 6.06).
Greetings,
Sjef. |
|
Back to top
|
|
|
|