Results 1 to 5 of 5

Thread: X11 KeySyms and KeyCodes

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    I'm using scancodes everywhere and here is my old solution...
    Code:
    function xkey_to_scancode( XKey, KeyCode : Integer ) : Byte;
    begin
      case XKey of
        XK_Pause:        Result := K_PAUSE;
    
        XK_Up:           Result := K_UP;
        XK_Down:         Result := K_DOWN;
        XK_Left:         Result := K_LEFT;
        XK_Right:        Result := K_RIGHT;
    
        XK_Insert:       Result := K_INSERT;
        XK_Delete:       Result := K_DELETE;
        XK_Home:         Result := K_HOME;
        XK_End:          Result := K_END;
        XK_Page_Up:      Result := K_PAGEUP;
        XK_Page_Down:    Result := K_PAGEDOWN;
    
        XK_Control_R:    Result := K_CTRL_R;
        XK_Alt_R:        Result := K_ALT_R;
        XK_Super_L:      Result := K_SUPER_L;
        XK_Super_R:      Result := K_SUPER_R;
        XK_Menu:         Result := K_APP_MENU;
    
        XK_KP_Divide:    Result := K_KP_DIV;
      else
        Result := ( KeyCode - 8 ) and $FF;
      end;
    end;
    
    // Somewhere in code
    xkey_to_scancode( XLookupKeysym( @event.xkey, 0 ), event.xkey.keycode );
    Last edited by Andru; 29-08-2011 at 07:29 PM.

  2. #2
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Not a bad snippet there. After further study I did find that if made a simple console application and wrote out the Ord(Readkey()) I could get it to match the X11 keysyms as scancodes or whatever.... So I guess I will have to make do with 'non-sdl compatible' code

    Not a big deal - just me being picky.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •