kbd.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef __KBD
  2. #define __KBD
  3. #ifndef KERNEL_NEW
  4. #include <default.h>
  5. #endif
  6. /* We have to use this internal macro since _keytest needs to be able to
  7. accept single parameters (in particular, the RR_... constant pairs). */
  8. #define __keytest(row,col) (!!(_rowread_inverted(1<<(row))&(1<<(col))))
  9. /* If you can read the macro below, you must be a really good C programmer.
  10. But I hope I can make it understandable:
  11. __current_row and __current_rowread_result are defined by BEGIN_KEYTEST
  12. and initialized to dummy values.
  13. The definition is sort of the same as the one above, but
  14. _rowread_inverted (1 << (row))
  15. is replaced with
  16. (__current_row == row ? __current_rowread_result : (__current_row = row, __current_rowread_result = _rowread_inverted (1 << (row))))
  17. So,
  18. if the row which was read the last time this macro was called equals the
  19. one that is to be read now,
  20. then use the last result in place of _rowread_inverted (1 << (row)),
  21. otherwise
  22. set __current_row,
  23. set __current_rowread_result by calling _rowread_inverted,
  24. and also return this value
  25. (see the section in the doc about the ',' operator). */
  26. #define __keytest_optimized(row,col) (!!((__current_row==((short)(row))?__current_rowread_result:(__current_row=((short)(row)),__current_rowread_result=_rowread_inverted(1<<(row))))&(1<<(col))))
  27. /* Begin Auto-Generated Part */
  28. #define KB_AUTOREPEAT (1<<11)
  29. #define NULL ((void*)0)
  30. #ifndef __HAVE_Bool
  31. #define __HAVE_Bool
  32. enum Bool{FALSE,TRUE};
  33. #endif
  34. #ifndef __HAVE_SCR_RECT
  35. #define __HAVE_SCR_RECT
  36. typedef union{struct{unsigned char x0,y0,x1,y1;}xy;unsigned long l;}SCR_RECT;
  37. #endif
  38. enum Arrows{ARROW_UP=1,ARROW_LEFT=2,ARROW_DOWN=3,ARROW_RIGHT=4};
  39. #ifndef __HAVE_CommonKeys
  40. #define __HAVE_CommonKeys
  41. enum CommonKeys{KEY_F1=268,KEY_F2=269,KEY_F3=270,KEY_F4=271,KEY_F5=272,KEY_F6=273,KEY_F7=274,KEY_F8=275,KEY_ESC=264,KEY_QUIT=4360,KEY_APPS=265,KEY_SWITCH=4361,KEY_MODE=266,KEY_BACKSPACE=257,KEY_INS=4353,KEY_CLEAR=263,KEY_VARLNK=4141,KEY_CHAR=4139,KEY_ENTER=13,KEY_ENTRY=4109,KEY_STO=258,KEY_RCL=4354,KEY_SIGN=173,KEY_MATH=4149,KEY_MEM=4150,KEY_ON=267,KEY_OFF=4363};
  42. #endif
  43. enum GKeyFlags{GKF_NORMAL=0,GKF_MODAL=1,GKF_REPUSH_KEY=2,GKF_ACCEPT=4,GKF_SYS=8,GKF_NO_EVS=16};
  44. enum StatKeys{STAT_2ND=1,STAT_DIAMOND=2,STAT_SHIFT=3,STAT_HAND=4};
  45. #define OSFastArrows (*((unsigned char*)(_rom_call_addr_hack_concat(0x15C,_ROM_CALL_15C,((unsigned char*)((unsigned long)(*(((short*)(_rom_call_addr(51)))+0x80)))),200,0x508))))
  46. #define _keytest_optimized(rowcol...) (__keytest_optimized(rowcol))
  47. #define _keytest(rowcol...) (__keytest(rowcol))
  48. #define _rowread_internal(row) (~(_rowread(row)))
  49. #define _rowread_inverted(row) (_rowread(~((short)(row))))
  50. extern unsigned short _rowread(short asm("d0"))__ATTR_LIB_ASM__;
  51. #define GKeyDown ({__need_in_use_bit;_rom_call(short,(void),17F);})
  52. #define GKeyFlush ({__need_in_use_bit;_rom_call(void,(void),180);})
  53. #define GKeyIn ({__need_in_use_bit;_rom_call(short,(SCR_RECT*,short),17E);})
  54. #define kbhit ({__need_in_use_bit;_rom_call(short,(void),52);})
  55. #define ngetchx ({__need_in_use_bit;_rom_call(short,(void),51);})
  56. #define OSGetStatKeys _rom_call(short,(void),299)
  57. #define OSInitBetweenKeyDelay(rate) ({short __oldRate=_OSInitBetweenKeyDelay(48);(__oldRate*48-1)/_OSInitBetweenKeyDelay((rate))+1;})
  58. #define OSInitKeyInitDelay _rom_call(short,(short),248)
  59. #define pushkey ({__need_in_use_bit;_rom_call(void,(short),50);})
  60. #define BEGIN_KEYTEST {register short __current_row=RR_NO_KEY;register unsigned short __current_rowread_result=0;
  61. #define END_KEYTEST }
  62. #if MIN_AMS>=200
  63. #define alphaLockOff _rom_call(void,(unsigned char*),482)
  64. #define alphaLockOn _rom_call(void,(unsigned char*),481)
  65. #define GetAlphaStatus _rom_call(unsigned char,(void),164)
  66. #define KeyYesOrNo _rom_call(short,(short),3EB)
  67. #define restoreAlphaLock _rom_call(void,(unsigned char*),483)
  68. #define SetAlphaStatus _rom_call(void,(char),163)
  69. #endif
  70. /* End Auto-Generated Part */
  71. #define _OSInitBetweenKeyDelay _rom_call(short,(short),249)
  72. #endif