X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_in.c;h=5bccecafde8529eb59983c6a1674d35a2a92f877;hb=afebb0aa9e93ca48e0955877d5cbd883e650d35f;hp=61d6e689995e8b7fbf984ad8ecea8637500fb3e4;hpb=a4a353b388af74bf17f62e10f2cb3b031e668b35;p=16.git diff --git a/src/lib/16_in.c b/src/lib/16_in.c index 61d6e689..5bccecaf 100755 --- a/src/lib/16_in.c +++ b/src/lib/16_in.c @@ -38,7 +38,7 @@ #include "src/lib/16_in.h" -byte testkeyin=0,testcontrolnoisy=0,testctrltype=0; +boolean testkeyin=0,testcontrolnoisy=0,testctrltype=0; /* ============================================================================= @@ -51,7 +51,6 @@ struct inconfig { boolean MousePresent; boolean JoysPresent[MaxJoys]; -// boolean JoyPadPresent[MaxPads]; boolean Keyboard[NumCodes]; boolean Paused; char LastASCII; @@ -59,7 +58,6 @@ struct inconfig KeyboardDef KbdDefs[MaxKbds]; JoystickDef JoyDefs[MaxJoys]; -// JoypadDef JoypadDefs[MaxPads]; } inpu; //extern inconfig inpu; @@ -237,7 +235,7 @@ static boolean special; if (INL_KeyHook && !special) INL_KeyHook(); //#ifdef TESTKEYIN - if(testkeyin > 0) printf("%c [0x%x %u] %u\n", c, k, k, inpu.Keyboard[k]); + if(testkeyin > 0) printf("%c %u [0x%x %u] %u\n", c, c, k, k, inpu.Keyboard[k]); //endif outp(0x20,0x20); } @@ -380,6 +378,41 @@ static word lasttime; IN_GetJoyAbs(joy,&x,&y); def = inpu.JoyDefs + joy; + //TODO: inject p16 input controls! + //which is this + /* if(DIRECTIONIFELSE) + { + if(!inpu.Keyboard[def->left] && !inpu.Keyboard[def->right]){ + if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])) + my = motion_Up; + if((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up])) + my = motion_Down; + }else if(!inpu.Keyboard[def->up] && !inpu.Keyboard[def->down]){ + if((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right])) + mx = motion_Left; + if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left]))// || player[pn].pdir != 1) + mx = motion_Right; + }else + //if(mx+my!=1 && mx+my!=-1 && mx!=my!=0) + { //2 keys pressed + switch (player[pn].pdir) + { + case 0: + case 4: + if((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right])) dir = DirTable[1]; + else if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left])) dir = DirTable[3]; + break; + case 1: + case 3: + if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])) dir = DirTable[0]; + else if((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up])) dir = DirTable[4]; + break; + default: + break; + } + if(testcontrolnoisy > 0){ printf("dir=%c ", dirchar(dir)); printf("pdir=%c ", dirchar(player[pn].pdir)); } + }//else printf(" "); + }*/ if (x < def->threshMinX) { if (x < def->joyMinX) @@ -678,8 +711,6 @@ IN_Default(boolean gotit,player_t *player,ControlType nt) || ((nt == ctrl_Joystick1) && !inpu.JoysPresent[0]) || ((nt == ctrl_Joystick2) && !inpu.JoysPresent[1]) || ((nt == ctrl_Mouse) && !inpu.MousePresent) -// || ((nt == ctrl_Joypad1) && !inpu.JoyPadPresent[0]) -// || ((nt == ctrl_Joypad2) && !inpu.JoyPadPresent[1]) ) nt = ctrl_Keyboard1; inpu.KbdDefs[0].button0 = 0x1c; @@ -898,8 +929,6 @@ register KeyboardDef *def; buttons += 1 << 1; realdelta = false; break; -// case ctrl_Joypad1: -// case ctrl_Joypad2: case ctrl_Joystick1: case ctrl_Joystick2: INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy,false); @@ -1253,3 +1282,19 @@ boolean IN_qb(byte kee) if(inpu.Keyboard[kee]==true) return 1; else return 0; } + +//init player! +void IN_initplayer(player_t *player, word pn) +{ + player[pn].x = player[pn].tx*TILEWH; + player[pn].y = player[pn].ty*TILEWH; + player[pn].triggerx = player[pn].tx; + player[pn].triggery = player[pn].ty+1; +/* player[0].info.x = player[0].tx; + player[0].info.xaxis = player[0].tx*TILEWH; + player[0].info.y = player[0].ty; + player[0].info.yaxis = player[0].ty*TILEWH;*/ + player[pn].q=1; + player[pn].d=2; + player[pn].hp=4; +}