CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

USB & DirectInput

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ctw



Joined: 17 Aug 2005
Posts: 0

View user's profile Send private message Send e-mail

USB & DirectInput
PostPosted: Wed Aug 17, 2005 8:28 am     Reply with quote

Hello,
I recently been attempting to create a USB device to work alongside a specific video-game. A kind of super-game-controller if you like, only the device needs to have information sent TO it at regular intervals.
It is now mostly up and running, and our game can happlily send info to the device to make it dance and do its thing.

However...
Although everything works fine (usually), the USB device does not like being plugged in and enumerated whilst other USB devices are plugged in at the same time.
(! ?)
I am fairly certain I am doing nothing wrong as I have reduced my problem right back to pieces of code that I did not create (both on the PICC and for the Windows driver).


I'm using the PIC16C765 / picStart Plus Programmer / MPLAB / CCS 'PCM' compiler / Windows XP / DirectInput (part of DirectX) to talk to the chip / The PICC is programmed with the 'ex_usb_hid.c example' that comes with the CCS 'PCM' compiler.

To reproduce the problem all you need to do is program the pic16c765 with the 'ex_usb_hid.c' example, plug it into a computer running windows XP (it works fine on a 98 machine that I tried, but have tried 2 XP machines and it works on neither), - connect it to the PC alongside another USB peripheral (either a mouse or a game controller, not tried others) - and run a USB viewer program from the link below.

Is there a PICC guru out there who has a likely explanation for this??


To help anyone out there who fancies trying to reproduce this...
Your MPLAB / CCS compiler project will require the following (original files)...
ex_usb_hid.c
16c765.h
pic_usb.h
usb.h
usb_desc_hid.h
16c765.lkr
p16c765.inc

When its done, and you've plugged it into a PC (running windows XP), you can then run 'Usbview.exe' which will hopefully tell you that its found a USB HID device. 'Primax Electronics'. etc.
Fine.
But then try running a program that uses 'DirectInput' (part of DirectX) to detect the USB device (such as this one 'DeviceView.exe' that comes with DirectX) and you get a nasty error message.
Sometimes it is the usual windows error: do you want to send an error report? - but often it is a 'attempting to reference *** memory location'.


To make like easier I have put these freely available programs on my website..
http://www.wrightgame.com/clivesstuff/USBVIEW.EXE
http://www.wrightgame.com/clivesstuff/DeviceView.exe

Under normal circumstances there is no situation and no USB device that will ever cause 'DeviceView.exe' to crash.

I have tried using the windows DDK to detect the device - and all is fine. Its just the DirectInput thing (which is what DeviceView.exe' uses) - but in my case this is a must.

Can anyone help?

Clive.
Guest








PostPosted: Wed Aug 17, 2005 3:15 pm     Reply with quote

Don't know if this will help your problem or not, but it is a starting point. I created a USB Nintendo controller. It may or may not be helpful, but it is tested, working code.

www.Zero-Soft.com/HW/USB_NES/

Drew
ctw



Joined: 17 Aug 2005
Posts: 0

View user's profile Send private message Send e-mail

more usb
PostPosted: Thu Aug 18, 2005 8:25 am     Reply with quote

Thanks. Had a look at your code, especially your descriptors. Tried changing all the obvious: report descriptor, making my device appear as a game controller rather than a vendor-specific device (which is what I wanted). Unfortunately couldn't solve the problem.

I think it must either be (1) A mistake in one of the descriptors, which in most circumstances makes no difference, but in the occasional case causes problems.
(2) A compiler problem. Something to do with how they've implemented all of the 'Chapter 9' stuff, which to be honest, I rather avoid getting into in too much depth.

For now I've managed to get our (original) MPLAB assembler version working, so it sends & receives via USB, so that will have to do.

Clive.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group