Console controller-PC

Console controller-PC

Post by t0m4t3 on Wed Jun 16, 2010 2:12 pm
([msg=40162]see Console controller-PC[/msg])

Hello all, this is my first post here, tough I've been here for some time...

Anyways...I'm trying to control a PC using some console controller, preferibly N64 (altough I have tought about using a wii controller also), anyways, I have tought in all the circuits to do that, but the hardest part comes to programming, I have chosen C because it allows us to work at a low level (that's what they say, at least!)

The input would come trough an USB connection, so, I'm asking for those who have some time, if they know any library/commands/things wich allow to program the USB input on the OS (I have chosen windows, OR linux).

Do you know any webpage with some kind of related info?

Thank you very much, I'll be here posting how I'll try to do this! :mrgreen:

PS: I know some programming, and I think I can handle the microcontroller part. By the way, sorry for my grammar, since english is not my language.
Last edited by t0m4t3 on Wed Jun 16, 2010 2:46 pm, edited 1 time in total.
t0m4t3
New User
New User
 
Posts: 8
Joined: Mon Mar 09, 2009 7:38 am
Blog: View Blog (0)


Re: Console controller-PC

Post by Bren2010 on Wed Jun 16, 2010 2:46 pm
([msg=40164]see Re: Console controller-PC[/msg])

Control it how? Like a mouse, or like an RC car?
User avatar
Bren2010
Poster
Poster
 
Posts: 340
Joined: Fri Sep 19, 2008 3:23 pm
Blog: View Blog (0)


Re: Console controller-PC

Post by t0m4t3 on Wed Jun 16, 2010 2:53 pm
([msg=40165]see Re: Console controller-PC[/msg])

I have some options...

1:Display some kind of virtual keyboard and use some buttons to use typical buttons (for instance, Z button to call the start panel at windows)
2: Just use some key-buttons attached to the controller, like: WASD: analog joystick

OR 3: Create some kind of menu where I can configure all this

The 3rd option would come eventually, since the first part I want to design is the hardware part. After that, basic programming (input), and in the end the config part.
t0m4t3
New User
New User
 
Posts: 8
Joined: Mon Mar 09, 2009 7:38 am
Blog: View Blog (0)


Re: Console controller-PC

Post by Goatboy on Wed Jun 16, 2010 3:09 pm
([msg=40166]see Re: Console controller-PC[/msg])

That's a pretty cool idea. Here's how I'd lay it out for the N64:

Joystick = Cursor control
Start = Windows key by default, mappable
A = Left click
B = Right click
C buttons = Mappable to various actions (like in Zelda)
Z = Virtual keyboard toggle by default, mappable (possibly middle mouse button)
L = Escape by default, mappable
R = Shift by default, mappable
Arrows = Up, Down, Left, Right keys

I think that would work pretty well. Assuming you are doing this without a real keyboard, the virtual keyboard could be mapped either to Z or to one of the C keys. I'd make all of the buttons customizable, but having these defaults.
Assume that everything I say is or could be a lie.
User avatar
Goatboy
Expert
Expert
 
Posts: 2865
Joined: Mon Jul 07, 2008 9:35 pm
Blog: View Blog (0)


Re: Console controller-PC

Post by Bren2010 on Wed Jun 16, 2010 3:10 pm
([msg=40167]see Re: Console controller-PC[/msg])

I don't think there would be much hardware needed. All you would really need is the controller, and then you would have to write/download drivers (for Windows at least).
User avatar
Bren2010
Poster
Poster
 
Posts: 340
Joined: Fri Sep 19, 2008 3:23 pm
Blog: View Blog (0)


Re: Console controller-PC

Post by t0m4t3 on Wed Jun 16, 2010 3:34 pm
([msg=40168]see Re: Console controller-PC[/msg])

Goatboy wrote:That's a pretty cool idea. Here's how I'd lay it out for the N64:

Joystick = Cursor control
Start = Windows key by default, mappable
A = Left click
B = Right click
C buttons = Mappable to various actions (like in Zelda)
Z = Virtual keyboard toggle by default, mappable (possibly middle mouse button)
L = Escape by default, mappable
R = Shift by default, mappable
Arrows = Up, Down, Left, Right keys

I think that would work pretty well. Assuming you are doing this without a real keyboard, the virtual keyboard could be mapped either to Z or to one of the C keys. I'd make all of the buttons customizable, but having these defaults.


Awesome mapping, I haven't tought about it, since I'm doing my final exams and I lack time to focus on this, thanks for the help.

Bren2010 wrote:I don't think there would be much hardware needed. All you would really need is the controller, and then you would have to write/download drivers (for Windows at least).


Well, the hardware is basically some voltage regulation from usb to N64 controller (it works using 3.6V and GND, and usb has +5 and GND), and something to adapt how the N64 sends the info to the USB (microcontroller), and besides that, the hardest part of all, the programming. (I study electronic enginneery, so the hardward part is kind of easy to me (at least, that's what it seems, and you never know how analog electronics will work ;) )

I have been doing some goggleing, and the USB library I will use is libusb, what do you people think?

And I haven't tought about other libs I may need, all the programming I've been doing is using stdio.h and string.h, and that are the only ones, do you people know some libs I may need (keeping in mind that it has a lot of chances to appear some kind of graphic menu)

Thanks for the quick response! :P
t0m4t3
New User
New User
 
Posts: 8
Joined: Mon Mar 09, 2009 7:38 am
Blog: View Blog (0)


Re: Console controller-PC

Post by OnlyHuman on Wed Jun 16, 2010 4:22 pm
([msg=40171]see Re: Console controller-PC[/msg])

t0m4t3 wrote:And I haven't tought about other libs I may need, all the programming I've been doing is using stdio.h and string.h, and that are the only ones, do you people know some libs I may need (keeping in mind that it has a lot of chances to appear some kind of graphic menu)

Thanks for the quick response! :P

If you're using Windows you should look into the Direct Input API. There are already predefined interfaces for dealing with game controller input. It's not too difficult to define your own action maps that way. In fact, there's already an interface defined for doing just that. On Linux, I believe you have to open the device as a file, and read the input as raw data. It can still be done, it just involves a lot more work on your end. Either way, good luck, and let us know how things come along.

EDIT

Note also, that the input you get from the controller will be completely different than the input you read from the keyboard. You'll have to work out a system to handle character input. Maybe something like using the analog joystick to cycle through the set of available characters, and then selecting that character when the joystick is pressed instead of tilted. Additionally, you'll still need to have some sort of keyboard installed on the system in order for it to pass its BIOS check, unless you're thinking about extremely low level control. :idea:
OnlyHuman
Poster
Poster
 
Posts: 191
Joined: Sat Aug 22, 2009 1:37 am
Blog: View Blog (0)


Re: Console controller-PC

Post by t0m4t3 on Wed Jun 16, 2010 4:49 pm
([msg=40177]see Re: Console controller-PC[/msg])

OnlyHuman wrote:
t0m4t3 wrote:And I haven't tought about other libs I may need, all the programming I've been doing is using stdio.h and string.h, and that are the only ones, do you people know some libs I may need (keeping in mind that it has a lot of chances to appear some kind of graphic menu)

Thanks for the quick response! :P

If you're using Windows you should look into the Direct Input API. There are already predefined interfaces for dealing with game controller input. It's not too difficult to define your own action maps that way. In fact, there's already an interface defined for doing just that. On Linux, I believe you have to open the device as a file, and read the input as raw data. It can still be done, it just involves a lot more work on your end. Either way, good luck, and let us know how things come along.

EDIT

Note also, that the input you get from the controller will be completely different than the input you read from the keyboard. You'll have to work out a system to handle character input. Maybe something like using the analog joystick to cycle through the set of available characters, and then selecting that character when the joystick is pressed instead of tilted. Additionally, you'll still need to have some sort of keyboard installed on the system in order for it to pass its BIOS check, unless you're thinking about extremely low level control. :idea:


Thank you for the info! Well, I have tought about this "project" as something to use at the same time as the keyboard, anyways, coudn't I just do some "Keyboard spoofing" using the microcontroller, and using the keyboard connection instead of usb?
Well, that wouldn't let me connect my keyboard, since mine uses the typical keyboard port (not usb, and I can't remember the name xD EDIT: PS/2! )...well, this is just an idea.
t0m4t3
New User
New User
 
Posts: 8
Joined: Mon Mar 09, 2009 7:38 am
Blog: View Blog (0)


Re: Console controller-PC

Post by OnlyHuman on Wed Jun 16, 2010 5:20 pm
([msg=40186]see Re: Console controller-PC[/msg])

Hmm... Keyboard spoofing. I'm not going to say it's impossible to do it using the USB microcontroller, because I really don't know. But, I can think of two ways that it can be done; The first involves flashing the game controller's firmware (if it has any) to report to the BIOS as if it were a keyboard. The second involves altering, and flashing the BIOS, with a duplicate that doesn't require the PS/2 keyboard. In the end, I think an altered BIOS is really the only way around that low level block. Again for two reasons; Some game controllers simply deal with electrical voltages, and don't report from an internal firmware buffer. And, even if they did, once the BIOS detects it as a keyboard, it, and the OS, expect that interrupts sent to it, will return the type of data expected from it. But, like I said, I won't say it can't be done in another way. Those are just the methods I see, and the limitations associated with them.
OnlyHuman
Poster
Poster
 
Posts: 191
Joined: Sat Aug 22, 2009 1:37 am
Blog: View Blog (0)


Re: Console controller-PC

Post by t0m4t3 on Thu Jun 17, 2010 2:47 am
([msg=40263]see Re: Console controller-PC[/msg])

OnlyHuman wrote:Hmm... Keyboard spoofing. I'm not going to say it's impossible to do it using the USB microcontroller, because I really don't know. But, I can think of two ways that it can be done; The first involves flashing the game controller's firmware (if it has any) to report to the BIOS as if it were a keyboard. The second involves altering, and flashing the BIOS, with a duplicate that doesn't require the PS/2 keyboard. In the end, I think an altered BIOS is really the only way around that low level block. Again for two reasons; Some game controllers simply deal with electrical voltages, and don't report from an internal firmware buffer. And, even if they did, once the BIOS detects it as a keyboard, it, and the OS, expect that interrupts sent to it, will return the type of data expected from it. But, like I said, I won't say it can't be done in another way. Those are just the methods I see, and the limitations associated with them.


Those seem to be some nice ideas, but I'm not doing this (at least, for now), since what I want to so is more simple, tough it may come in a future, maybe, for now, I want to design the hardware part, and start focusing in programming this into the OS, not bios.

How I said, maybe in the future I'll add new features like that (it'd be awesome!)

BTW, at least in my PC I can configure the BIOS so that it can just keep on without keyboard.
t0m4t3
New User
New User
 
Posts: 8
Joined: Mon Mar 09, 2009 7:38 am
Blog: View Blog (0)


Next

Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests