We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1341

Summary: Keyboard keys ` [ ] \ ' / = and right shift don't work
Product: SDL Reporter: Carl Kenner <carl.kenner>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED ENDOFLIFE QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2    
Version: 1.2.13   
Hardware: x86   
OS: Windows (All)   

Description Carl Kenner 2011-12-12 09:06:45 UTC
This bug only occurs on a Windows laptop with a built in IR receiver that automatically installs a driver for "Microsoft eHome MCIR 109 Keyboard" even though no such keyboard comes with it, or has ever been used with it. This bug effects all programs using DirectInput to read keyboard scancodes, unless they are aware of it. Any keyboard used with such a PC, even the built-in laptop keyboard, will generate incorrect scancodes with DirectInput. But RawInput and Virtual Key codes will be correct.

This bug is documented in the DOSBox Manual, as it has a major effect on DOSBox since users can't change directories:
"KEYBOARD: Right Shift and "\" doesn't work in DOSBox. (Windows only)
This may happen if Windows thinks that you have more than one keyboard connected to your PC when you use some remote control devices. To verity this problem run cmd.exe, navigate to DOSBox program folder and type:
set sdl_videodriver=windib
dosbox.exe
check whether keyboard started to work properly. As windib is slower it is best to use one of the two solutions provided here: http://vogons.zetafleet.com/viewtopic.php?t=24072"

The bug can be detected like this (pascal):

    KeyboardDevice.SetDataFormat(c_dfDIKeyboard);
    KeyboardDevice.Acquire;
    // Check for Japanese Scan code bug
    didw.diph.dwSize:=sizeof(didw);
    didw.diph.dwHeaderSize:=sizeof(DIPROPHEADER);
    didw.diph.dwHow:=DIPH_BYOFFSET;
    didw.diph.dwObj:=$94;
    JapaneseScancodeBug:=Succeeded(KeyboardDevice.GetProperty(DIPROP_SCANCODE, didw.diph)) and (didw.dwData=$29);

This code gets the scancode for scancode $94, and if it succeeds and says the scancode for scancode $94 is $29 (`~), then the bug is present. (It should fail or return $14E0).

The bug can be fixed like this (pascal):

// This is the "DOSBox/SDL/DirectInput" bug caused by laptops with an IR sensor
// automatically installing keyboard device "Microsoft eHome MCIR 109 Keyboard"
function FixJapaneseScancode(badsc: Word): Word;
begin
  case badsc of
    $1A: Result:=$1B;
    $1B: Result:=$2B;
    $2B: Result:=$55;
    $90: Result:=$0D;
    $91: Result:=$1A;
    $92: Result:=$28;
    $94: Result:=$29;
    else Result:=badsc;
  end;
end;

If JapaneseScancodeBug is true, you should call this function for every scancode to get the real scancode.

I call it the JapaneseScancodeBug because 109 key keyboards, like the one it thinks is installed, are Japanese. The bug probably occurs with real Japanese keyboards too.
Comment 1 Ryan C. Gordon 2015-08-25 09:38:20 UTC
Hello, and sorry if you're getting several copies of this message by email, since we are closing many bugs at once here.

We have decided to mark all SDL 1.2-related bugs as RESOLVED ENDOFLIFE, as we don't intend to work on SDL 1.2 any further, but didn't want to mark a large quantity of bugs as RESOLVED WONTFIX, to clearly show what was left unattended to and make it easily searchable.

Our current focus is on SDL 2.0.

If you are still having problems with an ENDOFLIFE bug, your absolute best option is to move your program to SDL2, as it will likely fix the problem by default, and give you access to modern platforms and tons of super-cool new features.

Failing that, we _will_ accept small patches to fix these issues, and put them in revision control, although we do not intend to do any further official 1.2 releases.

Failing that, please feel free to contact me directly by email (icculus@icculus.org) and we'll try to find some way to help you out of your situation.

Thank you,
--ryan.