1. Scan codes
- Posted by Brent Hugh <bhugh at GRIFFON.MWSC.EDU> Jun 21, 2000
- 499 views
Hi all, I'm using win32lib 0.45q and trying to use the top line of the computer keyboard as a "response keyboard". I am using keys "qwertyui" and mapping those to the musical notes CDEFGABC. So naturally, I want this row on the keyboard to always come out CDEFGABC no matter what keyboard layout is selected under windows. I thought I had licked this problem by using "onKeyDown" which supposedly returns "scan codes" as opposed to key codes. However, I discover that when I engage the German (standard) keyboard layout (which, as compared to English (US), exchanges the Y and Z keys of the keyboard), my program breaks. Now I would want qwertzui to equal CDEFGABC, but it doesn't. Any bright ideas? Anyone know how to penetrate the tricky windoze remapping business to get closer to the physical layout of the keyboard, regardless of windows remappings? Any help greatly appreciated! --Brent ++++++++++++ Brent Hugh / bhugh at griffon.mwsc.edu ++++++++++++++ + Missouri Western St College Dept of Music, St. Joseph, MO + + Piano Home Page: http://www.mwsc.edu/~bhugh + + Internet Piano Concert: http://www.mwsc.edu/~bhugh/recit + ++++ Classical Piano MP3s: http://www.mp3.com/brent_d_hugh ++++
2. Re: Scan codes
- Posted by Bernie <xotron at PCOM.NET> Jun 21, 2000
- 472 views
On Wed, 21 Jun 2000 10:43:12 -0500, Brent Hugh <bhugh at GRIFFON.MWSC.EDU> wrote: >Hi all, > >I'm using win32lib 0.45q and trying to use the top line of the computer >keyboard as a "response keyboard". I am using keys "qwertyui" and mapping >those to the musical notes CDEFGABC. > >So naturally, I want this row on the keyboard to always come out CDEFGABC >no matter what keyboard layout is selected under windows. Brent: You could build a translation table for each type of keyboard and on start up have the user select which keyboard he is using. When user is playing the notes you would monitor the key pressed look it up in the table (sequence) and return the corrected key code. Bernie
3. Re: Scan codes
- Posted by "Cuny, David at DSS" <David.Cuny at DSS.CA.GOV> Jun 21, 2000
- 476 views
Brent Hugh wrote: > However, I discover that when I engage the German > (standard) keyboard layout (which, as compared to > English (US), exchanges the Y and Z keys of the > keyboard), my program breaks. Now I would want > qwertzui to equal CDEFGABC, but it doesn't. Trackers use a similar scheme; you might want to take a look at how they do it. Impulse Tracker (a DOS tracker) is distributed with a set of files for different countries. You could also looks at ModPlug Tracker, a Win32 tracker, and see how they handle it. -- David Cuny
4. Re: Scan codes
- Posted by Brent Hugh <bhugh at CSTP.UMKC.EDU> Jun 25, 2000
- 498 views
- Last edited Jun 26, 2000
Just FYI, my solution to this was found in the win32 function found in user32.dll: DWORD OemKeyScan( WORD wOemChar // ASCII value of OEM character ); The low-order word of the returned value is the scan code of the given OEM character. So by taking the ASCII code I get from onKeyPress and feeding it into this function I can find out the scan code of the key that was pressed. This scan code that it returns *is* invariant under different keyboard layouts. This works pretty well, with only a few exceptions that don't seem important for my purposes (the problems come up because many keyboard layouts have "dead keys" and OemKeyScan chokes on these). Probably the ultimate solution to this problem is Bernie's (see below) but I'll try this and see if it works under different situations. The advantage of this solution is that, ideally, it will allow any user to have a correct keyboard setup instantly, without having to go in and setup the keyboard for their own keyboard layout. --Brent http://www.sunflower.org/~bhugh/eartest.spm At 12:33 PM 06/21/2000 -0400, you wrote: >On Wed, 21 Jun 2000 10:43:12 -0500, Brent Hugh <bhugh at GRIFFON.MWSC.EDU> >wrote: > > >Hi all, > > > >I'm using win32lib 0.45q and trying to use the top line of the computer > >keyboard as a "response keyboard". I am using keys "qwertyui" and mapping > >those to the musical notes CDEFGABC. > > > >So naturally, I want this row on the keyboard to always come out CDEFGABC > >no matter what keyboard layout is selected under windows. > > > Brent: > You could build a translation table for each type of keyboard and > on start up have the user select which keyboard he is using. > > When user is playing the notes you would monitor the key pressed > look it up in the table (sequence) and return the corrected key code. > Bernie ++++++++++++++++++++ Brent Hugh / bhugh at cstp.umkc.edu ++++++++++++++++++++ + University of Missouri-Kansas City, Conservatory of Music + + Sheet Music/Recordings: http://www.sunflower.org/~bhugh/pathetic.spm + + Internet Piano Concert: http://cctr.umkc.edu/userx/bhugh/recital.html + ++++++++++ Classical Piano MP3s http://www.mp3.com/brent_d_hugh ++++++++++