Events in C++ and work with IDE cdrom

K

Klapet

Hi, I'm quite new in C++ programing and I want to ask, if I can handle
events in simple console-like program. For example I need one loop to
repeat until some key is pressed. Is it possible to make?

And then I would like to ask, if it is possible to read data from cdrom
over IDE. My intention is, to make a program for PSP (PlayStation
Portable), which could read data from cdrom connected to PSP (don't
know exactly how yet, but frirst of all I need to know, if the program
can be even written). So it would be some kind of file browser. There
is a program called usbhostfs and with this you can acces your HDD in
PC from PSP and do whatever you want with the data from PSP. But the
usbhostfs must be running on the PC, so the PSP's usbhost could somehow
connect to PC usbhostfs (something like connetcting client to server).
So my question is, if it is possible to read data from cdrom without
anything like "usbhostfs server"?
 
M

mlimber

Klapet said:
Hi, I'm quite new in C++ programing and I want to ask, if I can handle
events in simple console-like program. For example I need one loop to
repeat until some key is pressed. Is it possible to make?

bool done = false;
char ch;
print_menu();
while( !done && (cin >> ch) )
{
switch( ch )
{
case '1': /* Do menu option 1 */ break;
case '2': /* Do menu option 2 */ break;
case '3': /* Do menu option 3 */ break;
case 'Q': done = true; break;
}
print_menu();
}

If you mean without pressing enter, there's no way to do it without
using platform-dependent extensions:

http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.17
And then I would like to ask, if it is possible to read data from cdrom
over IDE. My intention is, to make a program for PSP (PlayStation
Portable), which could read data from cdrom connected to PSP (don't
know exactly how yet, but frirst of all I need to know, if the program
can be even written). So it would be some kind of file browser. There
is a program called usbhostfs and with this you can acces your HDD in
PC from PSP and do whatever you want with the data from PSP. But the
usbhostfs must be running on the PC, so the PSP's usbhost could somehow
connect to PC usbhostfs (something like connetcting client to server).
So my question is, if it is possible to read data from cdrom without
anything like "usbhostfs server"?

This is an OS-specific question. If you can mount something so you can
open it like a normal file, then sure. Otherwise, you can probably
still do it (there's not much that *can't* be done somehow in C++), but
you're beyond the bounds of standard C++ and thus this newsgroup. See
this FAQ for what is on-topic here and for some other newsgroups you
might consider:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

Cheers! --M
 
K

Klapet

Thanks for the loop solution, but it's not working exactly the way I
would like to. Altough it gave me some ideas how to do that. But I'm
still unsuccessful.

I want to control winamp from command line, but the problem is, when I
start the playback, I need to print the current time on screen, but
when you press some key, it should stop (both the playback and the
counter). And there's the problem. When it is printing on screen, I
can't do anything (because of the running loop) and when I use your
solution, it's not counting.

So can you help me with this? Thanks in advance.

mlimber napsal:
 
M

mlimber

Klapet said:
mlimber napsal:

Thanks for the loop solution, but it's not working exactly the way I
would like to. Altough it gave me some ideas how to do that. But I'm
still unsuccessful.

I want to control winamp from command line, but the problem is, when I
start the playback, I need to print the current time on screen, but
when you press some key, it should stop (both the playback and the
counter). And there's the problem. When it is printing on screen, I
can't do anything (because of the running loop) and when I use your
solution, it's not counting.

So can you help me with this? Thanks in advance.

At the risk of redundancy:

"If you mean [receiving input] without pressing enter, there's no way
to do it without
using platform-dependent extensions:

http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.17 "

Consequently, you'll need to ask in a group for your OS.

Cheers! --M

PS, Please don't top-post here. It's considered rude (cf.
http://parashift.com/c++-faq-lite/how-to-post.html#faq-5.4).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top