keyboard programming

hi,

i am looking for a way in where i can trap various keystrokes. no! i can't go for BIOS routines as that will be plateform dependent. what i am looking for is absolutely plateform independent.

any idea!

any help is appreciated.


Comments

  • : hi,
    :
    : i am looking for a way in where i can trap various keystrokes. no! i can't go for BIOS routines as that will be plateform dependent. what i am looking for is absolutely plateform independent.
    :
    : any idea!
    :
    : any help is appreciated.

    Sorry, each platform has it's own way of doing things.

    One way to do it is to write the code for each platform and use #if...#endif to compile the code necessary for each platform.

    For example:

    #ifdef UNIX
    // Unix code to read a key
    #else
    #ifdef BORLAND
    // Borland compiler code
    #else
    #ifdef MSOFT
    // Microsoft compiler code
    #else
    #ifdef MAC
    // Macintosh code to read a key
    #endif
    #endif
    #endif
    #endif

    Then use a compiler switch to define one of the above values BORLAND, UNIX, etc.

    The other way is to write a set of libraries that contain platform-specific routines, naming each routine with the same name. Then link the program with the appropriate library.


    ----------------
    Walt


  • By plateform independent i mean hardware independene. CPU can be x86 or AMD. using bios will ask for INT9 interrupt and that may not be there in AMD. so i said plateform independence.

    I looked in visual studio. it provides some APIs which i can use in VC. and that should be plateform independent(i think so) for any windows flavor.

    what do u say for LINUX/UNIX. are there some APIs too.

    regards


    : : hi,
    : :
    : : i am looking for a way in where i can trap various keystrokes. no! i can't go for BIOS routines as that will be plateform dependent. what i am looking for is absolutely plateform independent.
    : :
    : : any idea!
    : :
    : : any help is appreciated.
    :
    : Sorry, each platform has it's own way of doing things.
    :
    : One way to do it is to write the code for each platform and use #if...#endif to compile the code necessary for each platform.
    :
    : For example:
    :
    : #ifdef UNIX
    : // Unix code to read a key
    : #else
    : #ifdef BORLAND
    : // Borland compiler code
    : #else
    : #ifdef MSOFT
    : // Microsoft compiler code
    : #else
    : #ifdef MAC
    : // Macintosh code to read a key
    : #endif
    : #endif
    : #endif
    : #endif
    :
    : Then use a compiler switch to define one of the above values BORLAND, UNIX, etc.
    :
    : The other way is to write a set of libraries that contain platform-specific routines, naming each routine with the same name. Then link the program with the appropriate library.
    :
    :
    : ----------------
    : Walt
    :
    :
    :

  • What you are asking sounds like it isn't processor dependent. It is actually compiler dependent. You don't need to go beyond your compiler. If you are using VC++, look at the _getch() and _kbhit() routines.

    : By plateform independent i mean hardware independene. CPU can be x86 or AMD. using bios will ask for INT9 interrupt and that may not be there in AMD. so i said plateform independence.
    :
    : I looked in visual studio. it provides some APIs which i can use in VC. and that should be plateform independent(i think so) for any windows flavor.
    :
    : what do u say for LINUX/UNIX. are there some APIs too.
    :
    : regards
    :
    :
    : : : hi,
    : : :
    : : : i am looking for a way in where i can trap various keystrokes. no! i can't go for BIOS routines as that will be plateform dependent. what i am looking for is absolutely plateform independent.
    : : :
    : : : any idea!
    : : :
    : : : any help is appreciated.
    : :
    : : Sorry, each platform has it's own way of doing things.
    : :
    : : One way to do it is to write the code for each platform and use #if...#endif to compile the code necessary for each platform.
    : :
    : : For example:
    : :
    : : #ifdef UNIX
    : : // Unix code to read a key
    : : #else
    : : #ifdef BORLAND
    : : // Borland compiler code
    : : #else
    : : #ifdef MSOFT
    : : // Microsoft compiler code
    : : #else
    : : #ifdef MAC
    : : // Macintosh code to read a key
    : : #endif
    : : #endif
    : : #endif
    : : #endif
    : :
    : : Then use a compiler switch to define one of the above values BORLAND, UNIX, etc.
    : :
    : : The other way is to write a set of libraries that contain platform-specific routines, naming each routine with the same name. Then link the program with the appropriate library.
    : :
    : :
    : : ----------------
    : : Walt
    : :
    : :
    : :
    :
    :

    ----------------
    Walt


  • well! i think _kbhit will make processor always looking for a key hit and will cause loss of processor cycles. is there some way i can gererate a software interrupt whenever a particular key is hit.


    : What you are asking sounds like it isn't processor dependent. It is actually compiler dependent. You don't need to go beyond your compiler. If you are using VC++, look at the _getch() and _kbhit() routines.
    :
    : : By plateform independent i mean hardware independene. CPU can be x86 or AMD. using bios will ask for INT9 interrupt and that may not be there in AMD. so i said plateform independence.
    : :
    : : I looked in visual studio. it provides some APIs which i can use in VC. and that should be plateform independent(i think so) for any windows flavor.
    : :
    : : what do u say for LINUX/UNIX. are there some APIs too.
    : :
    : : regards
    : :
    : :
    : : : : hi,
    : : : :
    : : : : i am looking for a way in where i can trap various keystrokes. no! i can't go for BIOS routines as that will be plateform dependent. what i am looking for is absolutely plateform independent.
    : : : :
    : : : : any idea!
    : : : :
    : : : : any help is appreciated.
    : : :
    : : : Sorry, each platform has it's own way of doing things.
    : : :
    : : : One way to do it is to write the code for each platform and use #if...#endif to compile the code necessary for each platform.
    : : :
    : : : For example:
    : : :
    : : : #ifdef UNIX
    : : : // Unix code to read a key
    : : : #else
    : : : #ifdef BORLAND
    : : : // Borland compiler code
    : : : #else
    : : : #ifdef MSOFT
    : : : // Microsoft compiler code
    : : : #else
    : : : #ifdef MAC
    : : : // Macintosh code to read a key
    : : : #endif
    : : : #endif
    : : : #endif
    : : : #endif
    : : :
    : : : Then use a compiler switch to define one of the above values BORLAND, UNIX, etc.
    : : :
    : : : The other way is to write a set of libraries that contain platform-specific routines, naming each routine with the same name. Then link the program with the appropriate library.
    : : :
    : : :
    : : : ----------------
    : : : Walt
    : : :
    : : :
    : : :
    : :
    : :
    :
    : ----------------
    : Walt
    :
    :
    :

  • Better use DOS and ASM then. Too many restrictions make the use of any suggestions useless.

    : well! i think _kbhit will make processor always looking for a key hit and will cause loss of processor cycles. is there some way i can gererate a software interrupt whenever a particular key is hit.
    :
    :
    : : What you are asking sounds like it isn't processor dependent. It is actually compiler dependent. You don't need to go beyond your compiler. If you are using VC++, look at the _getch() and _kbhit() routines.
    : :
    : : : By plateform independent i mean hardware independene. CPU can be x86 or AMD. using bios will ask for INT9 interrupt and that may not be there in AMD. so i said plateform independence.
    : : :
    : : : I looked in visual studio. it provides some APIs which i can use in VC. and that should be plateform independent(i think so) for any windows flavor.
    : : :
    : : : what do u say for LINUX/UNIX. are there some APIs too.
    : : :
    : : : regards
    : : :
    : : :
    : : : : : hi,
    : : : : :
    : : : : : i am looking for a way in where i can trap various keystrokes. no! i can't go for BIOS routines as that will be plateform dependent. what i am looking for is absolutely plateform independent.
    : : : : :
    : : : : : any idea!
    : : : : :
    : : : : : any help is appreciated.
    : : : :
    : : : : Sorry, each platform has it's own way of doing things.
    : : : :
    : : : : One way to do it is to write the code for each platform and use #if...#endif to compile the code necessary for each platform.
    : : : :


    ----------------
    Walt


  • well! there are not too many restictions. purpose is very simple
    i want to trap F1. but don't want to use kbhit or assembly. is here
    any API in Visual Studio by which i can trap a key.

    the whole idea is. as soon as user hits the key, a software interrupt is generated and invokes the application. any idea how to do this.

    these kbhit and all works for only the active window being displayed on console. but my process runs in background.
    even in game programming i think things works in the same way as i said. if i am right instead of waiting for a key pressed they work on interrupt bases only.

    what do u say ?


    : Better use DOS and ASM then. Too many restrictions make the use of any suggestions useless.
    :
    : : well! i think _kbhit will make processor always looking for a key hit and will cause loss of processor cycles. is there some way i can gererate a software interrupt whenever a particular key is hit.
    : :
    : :
    : : : What you are asking sounds like it isn't processor dependent. It is actually compiler dependent. You don't need to go beyond your compiler. If you are using VC++, look at the _getch() and _kbhit() routines.
    : : :
    : : : : By plateform independent i mean hardware independene. CPU can be x86 or AMD. using bios will ask for INT9 interrupt and that may not be there in AMD. so i said plateform independence.
    : : : :
    : : : : I looked in visual studio. it provides some APIs which i can use in VC. and that should be plateform independent(i think so) for any windows flavor.
    : : : :
    : : : : what do u say for LINUX/UNIX. are there some APIs too.
    : : : :
    : : : : regards
    : : : :
    : : : :
    : : : : : : hi,
    : : : : : :
    : : : : : : i am looking for a way in where i can trap various keystrokes. no! i can't go for BIOS routines as that will be plateform dependent. what i am looking for is absolutely plateform independent.
    : : : : : :
    : : : : : : any idea!
    : : : : : :
    : : : : : : any help is appreciated.
    : : : : :
    : : : : : Sorry, each platform has it's own way of doing things.
    : : : : :
    : : : : : One way to do it is to write the code for each platform and use #if...#endif to compile the code necessary for each platform.
    : : : : :
    :
    :
    : ----------------
    : Walt
    :
    :
    :

  • Do you know about the Setwindowhookex API function ? don't really know if it applies to your problem. If not, just ignore.

    : well! there are not too many restictions. purpose is very simple
    : i want to trap F1. but don't want to use kbhit or assembly. is here
    : any API in Visual Studio by which i can trap a key.
    :
    : the whole idea is. as soon as user hits the key, a software interrupt is generated and invokes the application. any idea how to do this.
    :
    : these kbhit and all works for only the active window being displayed on console. but my process runs in background.
    : even in game programming i think things works in the same way as i said. if i am right instead of waiting for a key pressed they work on interrupt bases only.
    :
    : what do u say ?
    :
    :
    : : Better use DOS and ASM then. Too many restrictions make the use of any suggestions useless.
    : :
    : : : well! i think _kbhit will make processor always looking for a key hit and will cause loss of processor cycles. is there some way i can gererate a software interrupt whenever a particular key is hit.
    : : :
    : : :
    : : : : What you are asking sounds like it isn't processor dependent. It is actually compiler dependent. You don't need to go beyond your compiler. If you are using VC++, look at the _getch() and _kbhit() routines.
    : : : :
    : : : : : By plateform independent i mean hardware independene. CPU can be x86 or AMD. using bios will ask for INT9 interrupt and that may not be there in AMD. so i said plateform independence.
    : : : : :
    : : : : : I looked in visual studio. it provides some APIs which i can use in VC. and that should be plateform independent(i think so) for any windows flavor.
    : : : : :
    : : : : : what do u say for LINUX/UNIX. are there some APIs too.
    : : : : :
    : : : : : regards
    : : : : :
    : : : : :
    : : : : : : : hi,
    : : : : : : :
    : : : : : : : i am looking for a way in where i can trap various keystrokes. no! i can't go for BIOS routines as that will be plateform dependent. what i am looking for is absolutely plateform independent.
    : : : : : : :
    : : : : : : : any idea!
    : : : : : : :
    : : : : : : : any help is appreciated.
    : : : : : :
    : : : : : : Sorry, each platform has it's own way of doing things.
    : : : : : :
    : : : : : : One way to do it is to write the code for each platform and use #if...#endif to compile the code necessary for each platform.
    : : : : : :
    : :
    : :
    : : ----------------
    : : Walt
    : :
    : :
    : :
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories