home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / quake_src / in_amigapsx.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-17  |  15.7 KB  |  627 lines

  1. /* 
  2. Copyright (C) 1996-1997 Id Software, Inc. 
  3.  
  4. This program is free software; you can redistribute it and/or 
  5. modify it under the terms of the GNU General Public License 
  6. as published by the Free Software Foundation; either version 2 
  7. of the License, or (at your option) any later version. 
  8.  
  9. This program is distributed in the hope that it will be useful, 
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of 
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   
  12.  
  13. See the GNU General Public License for more details. 
  14.  
  15. You should have received a copy of the GNU General Public License 
  16. along with this program; if not, write to the Free Software 
  17. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
  18.  
  19. */ 
  20.  
  21. // Input-Sub-Module for Joystick
  22.  
  23. /*
  24.             Portability
  25.             ===========
  26.  
  27.             This file should compile under all Amiga-based Kernels,
  28.             including WarpUP, 68k and PowerUP. There might be some
  29.             changes in the OS-Includes included needed (for example
  30.             adding inline-includes for EGCS or something like that).
  31.  
  32.             Steffen Haeuser (MagicSN@Birdland.es.bawue.de)
  33. */
  34.  
  35. #include "quakedef.h" 
  36.  
  37. #pragma amiga-align
  38. #include <proto/lowlevel.h> 
  39. #include <intuition/intuition.h>
  40. #include <intuition/intuitionbase.h> 
  41. #include <devices/gameport.h> 
  42. #include <libraries/lowlevel.h>
  43. #include <proto/exec.h>
  44. #include <proto/lowlevel.h>
  45. #include "psxport.h" 
  46. #pragma default-align
  47.  
  48. extern cvar_t  joy_advanced;
  49. extern cvar_t  joy_forwardthreshold;
  50. extern cvar_t  joy_sidethreshold;
  51. extern cvar_t  joy_pitchthreshold;
  52. extern cvar_t  joy_pitchsensitivity;
  53. extern cvar_t  joy_sensitivity;
  54.  
  55. extern cvar_t  joy_side_reverse;
  56. extern cvar_t  joy_up_reverse;
  57. extern cvar_t  joy_forward_reverse;
  58.  
  59. extern cvar_t joy_forwardsensitivity;
  60. extern cvar_t joy_sidesensitivity;
  61. cvar_t joy_psxdeadzone={"joy_psxdeadzone","48",true};
  62.  
  63. int analog_centered=FALSE;
  64. int analog_clx, analog_cly;
  65. int analog_lx, analog_ly;
  66. int analog_crx, analog_cry;
  67. int analog_rx, analog_ry;
  68.  
  69. struct TheJoy
  70. {
  71.   int mv_a;
  72.   int mv_b;
  73.   int axis;
  74.   int value;
  75.   int nvalue;
  76. };
  77.  
  78. static struct TheJoy tj;
  79.  
  80. extern struct Screen *QuakeScreen;
  81. extern struct IntuitionBase *IntuitionBase;
  82.  
  83. struct GamePortTrigger gameport_gpt = {
  84.   GPTF_UPKEYS | GPTF_DOWNKEYS,    /* gpt_Keys */
  85.   0,                /* gpt_Timeout */
  86.   1,                /* gpt_XDelta */
  87.   1                /* gpt_YDelta */
  88. };
  89.  
  90. static struct InputEvent gameport_ie;
  91.  
  92. int psxport=0; 
  93.  
  94. static struct MsgPort *gameport_mp = NULL;
  95. static struct IOStdReq *gameport_io = NULL;
  96. static BYTE gameport_ct;
  97. static int gameport_is_open = FALSE;
  98. static int gameport_io_in_progress = FALSE;
  99. static int gameport_curr,gameport_prev;
  100.  
  101. void ResetPsx(void)
  102.   int ix;
  103.  
  104. #ifdef __STORM__
  105.   if ((gameport_mp = CreateMsgPort ()) == NULL ||
  106.       (gameport_io = (struct IOStdReq *)CreateIORequest (gameport_mp, sizeof(struct IOStdReq))) == NULL)
  107. #else
  108.   if ((gameport_mp = CreatePort(NULL,0)) ==NULL ||
  109.       (gameport_io = CreateStdIO(gameport_mp)) == NULL)
  110. #endif
  111.     Sys_Error ("Can't create MsgPort or IoRequest");
  112.  
  113.   for (ix=0; ix<4; ix++) 
  114.   {
  115.     if (OpenDevice ("psxport.device", ix, (struct IORequest *)gameport_io, 0) == 0) 
  116.     {
  117.       Con_Printf ("\npsxport.device unit %d opened.\n",ix);
  118.       gameport_io->io_Command = GPD_ASKCTYPE;
  119.       gameport_io->io_Length = 1;
  120.       gameport_io->io_Data = &gameport_ct;
  121.       DoIO ((struct IORequest *)gameport_io);
  122.       if (gameport_ct == GPCT_NOCONTROLLER) 
  123.       {
  124.         gameport_is_open = TRUE;
  125.         ix=4;
  126.       } 
  127.       else 
  128.       {
  129.         CloseDevice ((struct IORequest *)gameport_io);
  130.       }
  131.     } 
  132.   }
  133.  
  134.   if (!gameport_is_open) 
  135.   {
  136.     Con_Printf ("No psxport, or no free psx controllers!  Joystick disabled.\n");
  137.   } 
  138.   else 
  139.   {
  140.  
  141.     gameport_ct = GPCT_ALLOCATED;
  142.     gameport_io->io_Command = GPD_SETCTYPE;
  143.     gameport_io->io_Length = 1;
  144.     gameport_io->io_Data = &gameport_ct;
  145.     DoIO ((struct IORequest *)gameport_io);
  146.  
  147.     gameport_io->io_Command = GPD_SETTRIGGER;
  148.     gameport_io->io_Length = sizeof(struct GamePortTrigger);
  149.     gameport_io->io_Data = &gameport_gpt;
  150.     DoIO ((struct IORequest *)gameport_io);
  151.  
  152.     gameport_io->io_Command = GPD_READEVENT;
  153.     gameport_io->io_Length = sizeof (struct InputEvent);
  154.     gameport_io->io_Data = &gameport_ie;
  155.     SendIO ((struct IORequest *)gameport_io);
  156.     gameport_io_in_progress = TRUE;
  157.   }
  158.  
  159.  
  160. void IN_InitPsx()
  161. {
  162.   int numdevs;
  163.   cvar_t *cv;
  164.   char strValue[256];
  165.   float f;
  166.  
  167.   joy_advanced.value=Cvar_VariableValue("joy_advanced");
  168.   if (!Cvar_FindVar("joy_advanced")) joy_advanced.value=0;
  169.   joy_forwardthreshold.value=Cvar_VariableValue("joy_forwardthreshold");
  170.   if (!Cvar_FindVar("joy_forwardthreshold")) joy_forwardthreshold.value=0.15;
  171.   joy_sidethreshold.value=Cvar_VariableValue("joy_sidethreshold");
  172.   if (!Cvar_FindVar("joy_sidethreshold")) joy_sidethreshold.value=0.15;
  173.   joy_pitchthreshold.value=Cvar_VariableValue("joy_pitchthreshold");
  174.   if (!Cvar_FindVar("joy_pitchthreshold")) joy_pitchthreshold.value=0.15;
  175.   joy_pitchsensitivity.value=Cvar_VariableValue("joy_pitchsensitivity");
  176.   if (!Cvar_FindVar("joy_pitchsensitivity")) joy_pitchsensitivity.value=1;
  177.   joy_forward_reverse.value= Cvar_VariableValue("joy_forward_reverse");
  178.   if (!Cvar_FindVar("joy_forward_reverse")) joy_forward_reverse.value=0;
  179.   joy_side_reverse.value = Cvar_VariableValue("joy_side_reverse");
  180.   if (!Cvar_FindVar("joy_side_reverse")) joy_side_reverse.value=0;
  181.   joy_forwardsensitivity.value=Cvar_VariableValue("joy_forwardsensitivity");
  182.   if (!Cvar_FindVar("joy_forwardsensitivity")) joy_forwardsensitivity.value=-1;
  183.   joy_sidesensitivity.value=Cvar_VariableValue("joy_sidesensitivity");
  184.   if (!Cvar_FindVar("joy_sidesensitivity")) joy_sidesensitivity.value=-1;
  185.   joy_psxdeadzone.value=Cvar_VariableValue("joy_psxdeadzone");
  186.   if (!Cvar_FindVar("joy_psxdeadzone")) joy_psxdeadzone.value=48;
  187.  
  188.   f = Cvar_VariableValue("in_initjoy");
  189.   if (!Cvar_FindVar("in_initjoy")) f=1.0;
  190.   if ( !f) return;
  191.   
  192.   ResetPsx();
  193.   tj.mv_a=32768;
  194.   tj.mv_b=32768;
  195. }
  196.  
  197. void IN_ShutdownPsx(void) 
  198.  if (gameport_io_in_progress) 
  199.  {
  200.    AbortIO ((struct IORequest *)gameport_io);
  201.    WaitIO ((struct IORequest *)gameport_io);
  202.    gameport_io_in_progress = FALSE;
  203.    gameport_ct = GPCT_NOCONTROLLER;
  204.    gameport_io->io_Command = GPD_SETCTYPE;
  205.    gameport_io->io_Length = 1;
  206.    gameport_io->io_Data = &gameport_ct;
  207.    DoIO ((struct IORequest *)gameport_io);
  208.  }
  209.  if (gameport_is_open) 
  210.  {
  211.    CloseDevice ((struct IORequest *)gameport_io);
  212.    gameport_is_open = FALSE;
  213.  }
  214.  if (gameport_io != NULL) 
  215.  {
  216. #ifdef __STORM__
  217.    DeleteIORequest ((struct IORequest *)gameport_io);
  218. #else
  219.    DeleteStdIO(gameport_io);
  220. #endif
  221.    gameport_io = NULL;
  222.  }
  223.  if (gameport_mp != NULL) 
  224.  {
  225. #ifdef __STORM__
  226.    DeleteMsgPort (gameport_mp);
  227. #else
  228.    DeletePort(gameport_mp);
  229. #endif
  230.    gameport_mp = NULL;
  231.  }
  232.  
  233. void RawValuePointerPsx(usercmd_t *cmd)
  234. {
  235.   int x,y; 
  236.   if (IntuitionBase->FirstScreen != QuakeScreen) return;
  237.  
  238.   if (GetMsg (gameport_mp) != NULL) 
  239.   {
  240.  
  241.     if ((gameport_ie.ie_Class == PSX_CLASS_JOYPAD) 
  242.      || (gameport_ie.ie_Class == PSX_CLASS_WHEEL)) 
  243.       analog_centered = false;
  244.  
  245.     if (PSX_CLASS(gameport_ie) != PSX_CLASS_MOUSE)
  246.     {
  247.       gameport_curr = ~PSX_BUTTONS(gameport_ie);
  248.       if (gameport_curr !=gameport_prev)
  249.       {
  250.  
  251.         if (gameport_curr & PSX_TRIANGLE) tj.value = tj.value|1;
  252.         else if (tj.value&1)
  253.         {
  254.           tj.value=tj.value&~1;
  255.           tj.nvalue|=1;
  256.         }
  257.  
  258.         if (gameport_curr & PSX_SQUARE) tj.value=tj.value|4;
  259.         else if (tj.value&4)
  260.         {
  261.           tj.value=tj.value&~4;
  262.           tj.nvalue|=4;
  263.         }
  264.  
  265.         if (gameport_curr & PSX_CIRCLE) tj.value=tj.value|8;
  266.         else if (tj.value&8)
  267.         {
  268.           tj.value=tj.value&~8;
  269.           tj.nvalue|=8;
  270.         }
  271.  
  272.         if (gameport_curr & PSX_CROSS) tj.value=tj.value|2;
  273.         else if (tj.value&2)
  274.         {
  275.           tj.value=tj.value&~2;
  276.           tj.nvalue|=2;
  277.         }
  278.   
  279.         if (gameport_curr & PSX_LEFT) tj.mv_b=0;
  280.         else if (gameport_curr & PSX_RIGHT) tj.mv_b=65536;
  281.         else tj.mv_b=32768;
  282.        
  283.         if (gameport_curr & PSX_UP) tj.mv_a=0;
  284.         else if (gameport_curr & PSX_DOWN) tj.mv_a=65536;
  285.         else tj.mv_a=32768;
  286.  
  287.         if (gameport_curr & PSX_START) tj.value=tj.value|64;
  288.         else if (tj.value&64)
  289.         {
  290.           tj.value=tj.value&~64;
  291.           tj.nvalue|=64;
  292.         }
  293.  
  294.         if (gameport_curr & PSX_SELECT) tj.value=tj.value|128;
  295.         else if (tj.value&128)
  296.         {
  297.           tj.value=tj.value&~128;
  298.           tj.nvalue|=128;
  299.         }
  300.  
  301.         if (gameport_curr & PSX_R1) tj.value=tj.value|16;
  302.         else if (tj.value&16)
  303.         {
  304.           tj.value=tj.value&~16;
  305.           tj.nvalue|=16;
  306.         }
  307.  
  308.         if (gameport_curr & PSX_L1) tj.value=tj.value|32;
  309.         else if (tj.value&32)
  310.         {
  311.           tj.value=tj.value&~32;
  312.           tj.nvalue|=32;
  313.         }
  314.  
  315.         if (gameport_curr & PSX_R2) tj.value=tj.value|256;
  316.         else if (tj.value&256)
  317.         {
  318.           tj.value=tj.value&~256;
  319.           tj.nvalue|=256;
  320.         }
  321.  
  322.         if (gameport_curr & PSX_L2) tj.value=tj.value|512;
  323.         else if (tj.value&512)
  324.         {
  325.           tj.value=tj.value&~512;
  326.           tj.nvalue|=512;
  327.         }
  328.  
  329.         gameport_prev = gameport_curr;
  330.  
  331.       }
  332.  
  333.     }
  334.  
  335.     if ((PSX_CLASS(gameport_ie) == PSX_CLASS_ANALOG) 
  336.      || (PSX_CLASS(gameport_ie) == PSX_CLASS_ANALOG2) 
  337.      || (PSX_CLASS(gameport_ie) == PSX_CLASS_ANALOG_MODE2)) 
  338.     {
  339.       analog_lx = PSX_LEFTX(gameport_ie);
  340.       analog_ly = PSX_LEFTY(gameport_ie);
  341.       analog_rx = PSX_RIGHTX(gameport_ie);
  342.       analog_ry = PSX_RIGHTY(gameport_ie);
  343.  
  344.       if (!analog_centered) 
  345.       {
  346.         analog_clx = analog_lx;
  347.         analog_cly = analog_ly;
  348.         analog_crx = analog_rx;
  349.         analog_cry = analog_ry;
  350.         analog_centered = true;
  351.       }          
  352.  
  353.       x=analog_lx-analog_clx;
  354.       y=analog_cly-analog_ly;
  355.       if ((abs(x)>joy_psxdeadzone.value) || (abs(y)>joy_psxdeadzone.value))
  356.       {
  357.         x<<=1;
  358.         y<<=1;
  359.         x=x*sensitivity.value;
  360.         y=y*sensitivity.value;
  361.       if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) ))
  362.         cmd->sidemove += m_side.value * x;
  363.     else cl.viewangles[YAW] -= m_yaw.value * x;
  364.     
  365.         if ((in_strafe.state & 1) && noclip_anglehack) cmd->upmove += m_forward.value * y;
  366.         else cmd->forwardmove += m_forward.value * y;
  367.       }
  368.       
  369.       x=analog_rx-analog_crx;
  370.       y=analog_cry-analog_ry;
  371.       if ((abs(x)>joy_psxdeadzone.value) || (abs(y)>joy_psxdeadzone.value))
  372.       {
  373.         x<<=1;
  374.         y<<=1;
  375.         x=x*sensitivity.value;
  376.         y=y*sensitivity.value;
  377.         if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) ))
  378.         cmd->sidemove += m_side.value * x;
  379.     else cl.viewangles[YAW] -= m_yaw.value * x;
  380.     
  381.     V_StopPitchDrift ();
  382.         
  383.     cl.viewangles[PITCH] += m_pitch.value * y;
  384.         if (cl.viewangles[PITCH] > 80) cl.viewangles[PITCH] = 80;
  385.         if (cl.viewangles[PITCH] < -70) cl.viewangles[PITCH] = -70;
  386.       }
  387.  
  388.       if (gameport_curr & PSX_R3) tj.value=tj.value|1024;
  389.       else if (tj.value&1024)
  390.       {
  391.         tj.value=tj.value&~1024;
  392.         tj.nvalue|=1024;
  393.       }
  394.  
  395.       if (gameport_curr & PSX_L3) tj.value=tj.value|2048;
  396.       else if (tj.value&2048)
  397.       {
  398.         tj.value=tj.value&~2048;
  399.         tj.nvalue|=2048;
  400.       }
  401.     }
  402.  
  403.     if (gameport_ie.ie_Class == PSX_CLASS_MOUSE) 
  404.     {
  405.       gameport_curr = ~PSX_BUTTONS(gameport_ie);
  406.  
  407.       if (gameport_curr & PSX_LMB) tj.value = tj.value|1;
  408.       else if (tj.value&1)
  409.       {
  410.         tj.value=tj.value&~1;
  411.         tj.nvalue|=1;
  412.       }
  413.  
  414.       if (gameport_curr & PSX_RMB) tj.value=tj.value|4;
  415.       else if (tj.value&4)
  416.       {
  417.         tj.value=tj.value&~4;
  418.         tj.nvalue|=4;
  419.       }
  420.  
  421.  
  422.       x=PSX_MOUSEDX(gameport_ie);
  423.       y=-PSX_MOUSEDY(gameport_ie);
  424.       x<<=2;
  425.       y<<=2;
  426.       x=x*sensitivity.value;
  427.       y=y*sensitivity.value;
  428.       if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) ))
  429.       cmd->sidemove += m_side.value * x;
  430.       else cl.viewangles[YAW] -= m_yaw.value * x;
  431.     
  432.       if (in_mlook.state & 1) V_StopPitchDrift ();
  433.      
  434.       if ( (in_mlook.state & 1) && !(in_strafe.state & 1)) 
  435.       {
  436.         cl.viewangles[PITCH] += m_pitch.value * y;
  437.         if (cl.viewangles[PITCH] > 80) cl.viewangles[PITCH] = 80;
  438.         if (cl.viewangles[PITCH] < -70) cl.viewangles[PITCH] = -70;
  439.       }
  440.       else 
  441.       {
  442.         if ((in_strafe.state & 1) && noclip_anglehack) cmd->upmove -= m_forward.value * y;
  443.         else cmd->forwardmove -= m_forward.value * y;
  444.       }
  445.  
  446.     }
  447.  
  448.     gameport_io->io_Command = GPD_READEVENT;
  449.     gameport_io->io_Length = sizeof (struct InputEvent);
  450.     gameport_io->io_Data = &gameport_ie;
  451.     SendIO ((struct IORequest *)gameport_io);
  452.   }
  453. }
  454.  
  455. void IN_PsxMove (usercmd_t *cmd) 
  456.   float   speed, aspeed;
  457.   int   fAxisValue;
  458.   int key_index;
  459.   
  460.   if (!gameport_is_open) return;
  461.  
  462.   if (in_speed.state & 1) speed = cl_movespeedkey.value;
  463.   else speed = 1;
  464.   aspeed = speed * host_frametime;
  465.  
  466.   RawValuePointerPsx(cmd);
  467.   fAxisValue= tj.mv_a;
  468.   fAxisValue -= 32768;
  469.   fAxisValue /= 32768;
  470.  
  471.   cmd->forwardmove += (fAxisValue * joy_forwardsensitivity.value) * speed * cl_forwardspeed.value;
  472. #if 0
  473.   if ((joy_advanced.value == 0.0) && (in_mlook.state & 1))
  474.   {
  475.     if (fabs(fAxisValue) > joy_pitchthreshold.value)
  476.     {
  477.       if (m_pitch.value < 0.0) cl.viewangles[PITCH] -= (fAxisValue * joy_pitchsensitivity.value) * aspeed * cl_pitchspeed.value;
  478.       else cl.viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity.value) * aspeed * cl_pitchspeed.value;
  479.     }
  480.   }
  481.   else cmd->forwardmove += (fAxisValue * joy_forwardsensitivity.value) * speed * cl_forwardspeed.value;
  482. #endif
  483.  
  484.   fAxisValue = tj.mv_b;
  485.   fAxisValue -= 32768;
  486.   fAxisValue /= 32768;
  487.   cl.viewangles[YAW] -= (fAxisValue * 0.5 * joy_pitchsensitivity.value) * aspeed * cl_pitchspeed.value;
  488.   if (tj.value&1)
  489.   {
  490.     key_index = K_JOY1;
  491.     Key_Event(key_index+3,true);
  492.   }
  493.   else
  494.   {
  495.     if (tj.nvalue&1)
  496.     {
  497.       key_index = K_JOY1;
  498.       Key_Event(key_index+3,false);
  499.     }
  500.   }
  501.   if (tj.value&2)
  502.   {
  503.     key_index = K_JOY1;
  504.     Key_Event(key_index,true);
  505.   }
  506.   else
  507.   {
  508.     if (tj.nvalue&2)
  509.     {
  510.       key_index = K_JOY1;
  511.       Key_Event(key_index,false);
  512.     }
  513.   }
  514.   if (tj.value&4)
  515.   {
  516.     key_index = K_JOY1;
  517.     Key_Event(key_index+2,true);
  518.   }
  519.   else
  520.   {
  521.     if (tj.nvalue&4)
  522.     {
  523.       key_index = K_JOY1;
  524.       Key_Event(key_index+2,false);
  525.     }
  526.   }
  527.   if (tj.value&8)
  528.   {
  529.     key_index = K_JOY1;
  530.     Key_Event(key_index+1,true);
  531.   }
  532.   else
  533.   {
  534.     if (tj.nvalue&8)
  535.     {
  536.       key_index = K_JOY1;
  537.       Key_Event(key_index+1,false);
  538.     }
  539.   }
  540.   if (tj.value&16) cmd->sidemove -= (joy_sidesensitivity.value) * speed * cl_sidespeed.value;
  541.   if (tj.value&32) cmd->sidemove += (joy_sidesensitivity.value) * speed * cl_sidespeed.value;
  542.  
  543.   if (tj.value&64)
  544.   {
  545.     key_index = K_JOY1;
  546.     Key_Event(key_index+4,true);
  547.   }
  548.   else
  549.   {
  550.     if (tj.nvalue&64)
  551.     {
  552.       key_index=K_JOY1;
  553.       Key_Event(key_index+4,false);
  554.     }
  555.   }
  556.   if (tj.value&128)
  557.   {
  558.     key_index = K_JOY1;
  559.     Key_Event(key_index+5,true);
  560.   }
  561.   else
  562.   {
  563.     if (tj.nvalue&128)
  564.     {
  565.       key_index=K_JOY1;
  566.       Key_Event(key_index+5,false);
  567.     }
  568.   }
  569.   if (tj.value&256)
  570.   {
  571.     key_index = K_JOY1;
  572.     Key_Event(key_index+6,true);
  573.   }
  574.   else
  575.   {
  576.     if (tj.nvalue&256)
  577.     {
  578.       key_index=K_JOY1;
  579.       Key_Event(key_index+6,false);
  580.     }
  581.   }
  582.   if (tj.value&512)
  583.   {
  584.     key_index = K_JOY1;
  585.     Key_Event(key_index+7,true);
  586.   }
  587.   else
  588.   {
  589.     if (tj.nvalue&512)
  590.     {
  591.       key_index=K_JOY1;
  592.       Key_Event(key_index+7,false);
  593.     }
  594.   }
  595.   if (tj.value&1024)
  596.   {
  597.     key_index = K_JOY1;
  598.     Key_Event(key_index+8,true);
  599.   }
  600.   else
  601.   {
  602.     if (tj.nvalue&1024)
  603.     {
  604.       key_index=K_JOY1;
  605.       Key_Event(key_index+8,false);
  606.     }
  607.   }
  608.   if (tj.value&2048)
  609.   {
  610.     key_index = K_JOY1;
  611.     Key_Event(key_index+9,true);
  612.   }
  613.   else
  614.   {
  615.     if (tj.nvalue&2048)
  616.     {
  617.       key_index=K_JOY1;
  618.       Key_Event(key_index+9,false);
  619.     }
  620.   }
  621.