Samsung i730 Multiple Keypress Fix

Description of the Problem and the Fix
Known Issues and Limitations
Downloads

Description of the Problem and the Fix

  1. The Problem
    The Samsung i730 does not support multiple simultaneous keypresses. This is an issue especially for games, such as those that require the player to move and shoot at the same time.
  2. How Multiple Keypresses Are Supposed to Work
    When you press a key on the keyboard, Windows sends a WM_KEYDOWN message to the window that has the input focus. The WM_KEYDOWN message contains information such as which key was pressed. If you hold down a key, Windows sends repeated WM_KEYDOWN messages. When you release the key, Windows sends a WM_KEYUP message.

    As an example, suppose you press and hold down the A key. Windows will send repeated WM_KEYDOWN messages saying that the A key is down. Suppose you then press and hold the B key while still holding down the A key. Windows then begins sending repeated WM_KEYDOWN messages saying that the B key is down. Next you release the B key and Windows sends a WM_KEYUP message saying that the B key is up. Finally you release the A key, and Windows sends a WM_KEYUP message saying that the A key is up.
  3. How Multiple Keypresses (Don't) Work on the i730
    Using the same example as in the previous section, when you press and hold down the A key, Windows does send repeated WM_KEYDOWN messages saying that the A key is down. However, when you then press and hold the B key while still holding down the A key, Windows sends a WM_KEYUP message saying that the A key is up. Not only does it send an erroneous message about the A key being up, it also doesn't send any messages whatsoever about the B key.
  4. The Fix
    We need to fix the erroneous WM_KEYUP message for the first key that is pressed, and we need to generate our own WM_KEYDOWN message for the second key. We also need to monitor the keys so we can send a WM_KEYUP message when they are no longer pressed. Our solution is a program that runs in the background, hereafter referred to as "the fix program."

    First we create a keyboard hook with a call to SetWindowsHook, so that all keyboard messages pass through the fix program. When our keyboard hook procedure is called, we look to see if it's being called as a result of a WM_KEYUP message. If so, we check to see if the key really is up. If the key really is up, then we do nothing. If the key is actually down, then we know that the WM_KEYUP message is erroneous and another key has been pressed, so we need to determine which key that is. Once we know which key(s) are pressed, we start a timer. Whenever the timer fires, we send a WM_KEYDOWN message for each key that is actually down and a WM_KEYUP message for each key that is actually up (if we haven't already sent a WM_KEYUP message).

    To determine if a key is actually up or down, we access the KPASMKPx registers of the CPU, which are described in section 18.5.6 of the Intel PXA27x Processor Family Developer's Manual.
  5. Thanks
    Thanks to Emulamer for developing a similar fix for the HTC 6700 and to nemesisxiii for providing the source code for Emulamer's fix, which I used as a starting point for the i730 fix.

Known Issues and Limitations

Downloads

Version 0.1 (13 Feb 2008)
CAB file: i730kbfix_0_1.cab (36,392 bytes)
Source code: i730kbfix_src_0_1.zip (18,104 bytes)

To install, copy the CAB file to your i730 and run it from there. You will be asked where you want it to be installed.
The source code is a Microsoft Visual Studio 2005 solution. You will probably also need the Windows Mobile 5.0 SDK for Pocket PC in order to compile it.