Ejemplo n.º 1
0
U0 DrawIt(CTask *task,CDC *dc)
{
  U8 buf[128];
  I64 i;
//<CTLR-T> to see the syntax of the
//"Insert Binary" statement in the following.
  for (i=0;i<NUM_TREES;i++)
    SpritePlot3(dc,trees_x[i],trees_y[i]-cur_screen_y,0,$IB,"<2>",2$);

  dc->collision_cnt=0;
  dc->color=ROP_COLLISION;
  dc->bkcolor=WHITE;
  SpritePlot3(dc,x,y,0,$IB,"<1>",1$);
  if (dc->collision_cnt) {
    Snd(400);
    penalty++;
  } else
    Snd(0);

  dc->color=ROP_EQU;
  SpritePlot3(dc,x,y,0,$IB,"<1>",1$);
//Text attr include forground in the
//lowest 4 bits and background in the upper 4.
  SPrintF(buf,"Penalty:%d",penalty);
  PlotWinStr(task,buf,BLACK+WHITE*16,1,1);
}
Ejemplo n.º 2
0
U0 Song()
{
  CTask *task;
  Fs->task_end_cb=&SndTaskEndCB;
  music_tempo=2.5;
  try {
  task=PopUpViewStr(
    "$$WW+H,1$$$LK-A,"BF:Matthew,22:35"$\n\n"
    "How many people hear \"Love God with all heart "
    "mind and soul; and neighbor as self,\" but walk "
    "away thinking \"Love neighbor with all heart "
    "mind and soul?\"\n"
    );
  TaskWait(task);
  SetWinHorz(Fs->win_left,Fs->win_right,task);
  SetWinVert(Fs->win_bottom+3,Fs->win_bottom+15,task);
  while (!ScanKey) {
	Play("3qFeA2G3qBeGBqEetDCBqEeFF",
	"First, \0lo\0ve \0God \0with \0 \0ALL \0$$FG,RED$$heart$$FG$$, \0mind \0and \0soul.\n\0 \0 \0");
	PutSprite($IB,"<heart>",1$);
	"$$CM,0,6$$";
	Play("qFeA2G3qBeGBqEetDCBqEeFF",
	"First, \0lo\0ve \0God \0with \0 \0ALL \0$$FG,RED$$heart$$FG$$, \0mind \0and \0soul.\n\0 \0 \0");
	PutSprite($IB,"<heart>",1$);
	"$$CM,0,6$$";
	Play("GBsADADqE2G3eCDqG2sG3B2G3BetBDB",
	"What's \0 \0 \0 \0 \0 \0left?\0 \0I \0don't\0know.\n\0 \0 \0 \0 \0 \0 \0 \0");
	Play("eGBsADADqE2G3eCDqG2sG3B2G3BetBDB",
	"What's \0 \0 \0 \0 \0 \0left?\0 \0I \0don't\0know.\n\0 \0 \0 \0 \0 \0 \0 \0");
  }
  } catch
    CatchAll;
  Snd(0);
}
Ejemplo n.º 3
0
//8 has words
U0 Song()
{
    CTask *task;
    Fs->task_end_cb=&SndTaskEndCB;
    try {
        task=PopUpViewStr(
                 "$LK-A,"BF:Matthew,19:16"$\n"
             );
        TaskWait(task);
        SetWinHorz(Fs->win_left,Fs->win_right,task);
        SetWinVert(Fs->win_bottom+3,Fs->win_bottom+15,task);
        "$$WW+H,1$$";
        while (!ScanKey) {
            Play("3eGAetCCCFFDqAeAAFAAFqG",
                 "I\0\0have\0\0\0kept\0\0\0\0\0\0the\0\0\0com\0mands.\n\0");
            Play("eGAetCCCFFDqAeAAFAAFqG",
                 "I\0\0have\0\0\0kept\0\0\0\0\0\0the\0\0\0com\0mands.\n\0");
            Play("EeEGqEeEEqDBetCCGqC",
                 "What\0\0\0else\0\0\0must\0I\0do?\n\0\0\0\0");
            Play("EeEGqEeEEqDBetCCGqC",
                 "What\0\0\0else\0\0\0must\0I\0do?\n\0\0\0\0");
            "$$FG,GREEN$$(Christ said sell all and follow me.)\n$$FG$$";
        }
    } catch
        CatchAll;
    Snd(0);
}
Ejemplo n.º 4
0
U0 SettingsPop2(CTask *task,CTaskSettings *tempse)
{
  CDoc *doc;

  if (doc=DocPut(task)) {
    LBEqu(&doc->flags,DOCf_HIDE_CURSOR,!tempse->cursor);
    LBEqu(&doc->flags,DOCf_NO_SCROLL_BARS,!tempse->scroll);
  }

  WinBorder(tempse->border,task);
  SetWinHorz(tempse->left,tempse->right,task);
  SetWinVert(tempse->top,tempse->bottom,task);
  task->win_scroll_x=tempse->scroll_x;
  task->win_scroll_y=tempse->scroll_y;
  task->win_scroll_z=tempse->scroll_z;
  MemCpy(&task->snap,&tempse->snap,sizeof(CSnap));
  task->win_inhibit=tempse->win_inhibit;
  task->win_max_refresh=tempse->win_max_refresh;
  task->text_attr=tempse->text_attr;
  task->border_attr=tempse->border_attr;
  task->border_src =tempse->border_src;
  task->title_src  =tempse->title_src;
  StrCpy(task->task_title,tempse->task_title);
  WordStat(tempse->wordstat);
  SetVGAPalette4(tempse->palette4);
  Snd(0);
}
Ejemplo n.º 5
0
public CTaskSettings *SettingsPush(CTask *task=NULL,I64 flags=0)
{ //This is typically used at the start of an application.
  //It saves many settings so they can be restored
  //at the end of the application with $LK,"SettingsPop","MN:SettingsPop"$().

  CTaskSettings *tempse;
  CDoc *doc;
  if (!task) task=Fs;
  if (!TaskValidate(task)) return NULL;
  tempse=CAlloc(sizeof(CTaskSettings),task);
  tempse->draw_it=task->draw_it;
  GetVGAPalette4(tempse->palette4);
  tempse->task_end_cb=task->task_end_cb;

  if (!(flags&TSF_SAME_SONG)) {
    if (tempse->song_task=task->song_task) {
      Suspend(task->song_task);
      Snd(0);
    }
    task->song_task=NULL;
  }

  if (tempse->animate_task=task->animate_task)
    Suspend(task->animate_task);
  task->animate_task=NULL;

  if (doc=DocPut(task)) {
    tempse->cursor=!Bt(&doc->flags,DOCf_HIDE_CURSOR);
    tempse->scroll=!Bt(&doc->flags,DOCf_NO_SCROLL_BARS);
  }

  tempse->left=task->win_left;
  tempse->right=task->win_right;
  tempse->top=task->win_top;
  tempse->bottom=task->win_bottom;

  tempse->scroll_x=task->win_scroll_x;
  tempse->scroll_y=task->win_scroll_y;
  tempse->scroll_z=task->win_scroll_z;

  tempse->win_inhibit=task->win_inhibit;
  MemCpy(&tempse->snap,&task->snap,sizeof(CSnap));

  tempse->win_max_refresh=task->win_max_refresh;
  tempse->text_attr=task->text_attr;
  StrCpy(tempse->task_title,task->task_title);
  tempse->title_src  =task->title_src;
  tempse->border_attr=task->border_attr;
  tempse->border_src =task->border_src;
  tempse->border=!Bt(&task->display_flags,DISPLAYf_NO_BORDER);
  tempse->preempt=Bt(&task->task_flags,TASKf_PREEMPT);
  if (TaskValidate(ws_task))
    tempse->wordstat=TRUE;
  else
    tempse->wordstat=FALSE;

  tempse->next=task->next_settings;
  task->next_settings=tempse;
  return tempse;
}
Ejemplo n.º 6
0
//7 has words
U0 Song()
{
  CTask *task;
  Fs->task_end_cb=&SndTaskEndCB;
  task=PopUpViewStr(
    "$LK-A,"BF:Luke,7:42"$\n"
    "\n"
    "Prodigal Son\n"
    "$LK-A,"BF:Luke,15:21"$\n"
    );
  TaskWait(task);
  SetWinHorz(Fs->win_left,Fs->win_right,task);
  SetWinVert(Fs->win_bottom+3,Fs->win_bottom+15,task);
  music_tempo=2.5;
  try {
  "$$WW+H,1$$";
  while (!ScanKey) {
	Play("3qGGsEAEAqAsF2G3F2G3qCeEFqD",
		"Life,\0life,\0isn't\0\0\0\0fair.\0Isn't\0\0\0\0fair.\n\0\0\0\0");
	Play("GGsEAEAqAsF2G3F2G3qCeEFqD",
		"Waaa,\0waaa,\0isn't\0\0\0\0fair.\0Isn't\0\0\0\0fair.\n\0\0\0\0");
	Play("eFCqEBDBE2eG3EsFEFE",
		"\0\0I\0\0ne\0ver\0sin.\n\0\0\0\0\0\0\0");
	Play("eFCqEBDBE2eG3EsFEFE",
		"\0\0I\0\0ne\0ver\0win.\n\0\0\0\0\0\0\0");
	"$$FG,GREEN$$(A warning on presumption. 'Who loves more man -- forgiven big debt or little?'  See prodigal son.)$$FG$$\n";
  }
  } catch
    CatchAll;
  Snd(0);
}
Ejemplo n.º 7
0
bool Msg::Snd(const void *data, const size_t size, const int mType) {
	if (mType <= 0) {
		return false;
	}
	mSize = size;
	if (mSize > IPC_MAX_MSG_SZ) {
		return false;
	}
	memcpy(msgbuf.mdata, data, mSize);
	msgbuf.mtype = mType;
	return Snd();
}
Ejemplo n.º 8
0
U0 MenuSprite()
{
  I64 i;
  DocPut->flags|=DOCF_FORM; //Cursor navigation will skip empty locations.
  do {
    DocClear;
    NewLine(1);

//Sprite with flags for left-expression and an exit.
//See $LK,"doc_dft_flags1","MN:doc_dft_flags1"$.	Note the %d in the string for the sprite number.
    PutSprite($IB,"<1>",1$,"$$FG,LTBLUE$$$$SP+LE+X,\"50 Hz\",50,%d$$");

    NewLine(3);
    "$$MU,\"100 Hz\",100$$\n";
    "$$MU,\"200 Hz\",200$$\n";
    "$$MU,\"CANCEL\",DOCM_CANCEL$$\n";
    i=DocMenuDo(DocPut);
    if (i>0) Snd(i);
  } while (i>=0);
  Snd(0);
  DocClear;
  NewLine(1);
  DocPut->flags&=~DOCF_FORM;
}
Ejemplo n.º 9
0
//8 has words
U0 Song()
{
  Fs->task_end_cb=&SndTaskEndCB;
  music_tempo=2.5;
  try {
  while (!ScanKey) {
	Play("2eG3DGDqGetA2G3B2qG3GCE",
	" \0 \0 \0 \0 \0 \0 \0 \0 \0It's \0ko\0sher.\n\0");
	Play("2eG3DGDqGetA2G3B2qG3GCE",
	" \0 \0 \0 \0 \0 \0 \0 \0 \0It's \0ko\0sher.\n\0");
	Play("C2G3sGFGFDCDCetE2G3CGFAqDeFC");
	Play("qC2G3sGFGFDCDCetE2G3CGFAqDeFC");
  }
  } catch
    CatchAll;
  Snd(0);
}
Ejemplo n.º 10
0
//8 no nothing
U0 Song()
{
  Fs->task_end_cb=&SndTaskEndCB;
  MusicSettingsRst;
  music_tempo= 2.480;
  music_stacatto_factor= 0.902;
  try {
  while (!ScanKey) {
	Play("4etEEEqBetDDqtDqBetCCqtCqBhB");
	Play("etEEEqBetDDqtDqBetCCqtCqBhB");
	Play("etABCqDetBCCqDetDCBqAhA");
	Play("etABCqDetBCCqDetDCBqAhA");
	Play("qAetCAEsGCGCetBC3G4ADAqAGetDAD");
	Play("qAetCAEsGCGCetBC3G4ADAqAGetDAD");
  }
  } catch
    CatchAll;
  Snd(0);
}
Ejemplo n.º 11
0
U0 Song()
{
  Fs->task_end_cb=&SndTaskEndCB;
  MusicSettingsRst;
  music_tempo= 2.480;
  music_stacatto_factor= 0.902;
  try {
  while (!ScanKey) {
	Play("3qF2GsGGGG3GFGFqAeD2G3etDBEsFCFC",
		"Love\0\0\0\0\0\0ev\0\0ery\0\0sec\0ond.\n\0\0\0\0\0\0\0\0\0");
	Play("qF2GsGGGG3GFGFqAeD2G3etDBEsFCFC",
		"World--\0\0\0\0\0\0all\0\0that\0\0beck\0ons.\n\0\0\0\0\0\0\0\0\0");
	Play("qBGFsEAEAqEFGeFC",
		"\0Life\0is\0too\0\0\0\0prec\0i\0ous.\n\0\0\0");
	Play("qBGFsEAEAqEFGeFC",
		"\0Can\0be\0\0\0\0\0worr\0i\0ous.\n\0\0\0");
  }
  } catch
    CatchAll;
  Snd(0);
}
Ejemplo n.º 12
0
//8 has words
U0 Song()
{
  Fs->task_end_cb=&SndTaskEndCB;
  MusicSettingsRst;
  music_tempo= 3.360;
  music_stacatto_factor= 0.846;
  try {
  while (!ScanKey) {
	Play("M5/4");
	Play("2qGGG3qtCBA2qGGG3qtCetBBqtA",
		"Hymn's\0not\0long.\n\0\0\0\0Nor\0this\0song.\n\0\0\0\0\0");
	Play("qEeCCqDqtCBAM4/4",
		"For\0\0\0give!\n\0\0\0\0");
	Play("qDeA2G3DG2G3DFFAC2qG3eAE",
		"That's\0\0\0all\0\0I\0\0say.\n\0\0\0\0\0\0\0");
	Play("qDeA2G3DG2G3DFFAC2qG3eAE",
		"This\0\0\0I\0\0\0\0pray.\n\0\0\0\0\0\0\0");
  }
  } catch
    CatchAll;
  Snd(0);
}
Ejemplo n.º 13
0
U0 Song()
{ //Song by Terry A. Davis
  Fs->task_end_cb=&SndTaskEndCB;
  MusicSettingsRst;
  try //Catch <CTRL-ALT-C> exit
    while (!ScanChar) {
	Play("4hEqDCBCDhE",
	    "God\0is\0a\0g\0od\0of\0love.\n\0");
	Play("3GqFEFhG4E",
	    "\0\0\0\0\0He\0");
	Play("qDCBCDhE3G",
	    "wat\0ches\0us\0from\0a\0bove.\n\0\0");
	Play("qFEFhG4BqC",
	    "\0\0\0\0Our\0world\0");
	Play("DhCeDChB3G",
	    "is\0n't\0al\0ways\0nice.\n\0\0");
	Play("qFEFhG4EqD",
	    "\0\0\0\0Be\0fore\0");
	Play("CBCDhE3G",
	    "you\0gr\0ipe\0think\0twice.\n\0\0");
	Play("qFEFhG4EqD",
	    "\0\0\0\0He\0wat\0");
	Play("CBCDhE3G",
	    "ches\0us\0from\0a\0bove.\n\0\0");
	Play("qFEFhG4EqD",
	    "\0\0\0\0He'll\0smack\0");
	Play("CBCDhE3G",
	    "you\0with\0out\0a\0glove.\n\0\0");
	Play("qFEFhG4BqC",
	    "\0\0\0\0Our\0world\0");
	Play("DhCeDChB3G",
	    "is\0n't\0al\0ways\0nice.\n\0\0");
	Play("qFEFhG");
      }
  catch
    CatchAll;
  NewLine;
  Snd(0);
}
Ejemplo n.º 14
0
char	*FootSnd(const char *id)
{
	return Snd(id, footstepTable);
}
Ejemplo n.º 15
0
U0 EdCodeTools2(CDoc *doc,I64 tool_action)
{
  Bool okay,unlock=DocLock(doc),start_of_line=TRUE;
  CDocEntry *doc_e,*doc_ne;
  I64 i,start_y,end_y,x,r,goto_line_num;
  U8 *b,*st,*st2,*prj_file;
  CTask *task=NULL;
  CSrvCmd *tempc;
  CQueVectU8 *indent;

  DocRecalc(doc);
  goto_line_num=doc->cur_entry->y+1;

  DocCaptureUndo(doc,TRUE);
  switch (tool_action) {
    case EF_CHK_COMPILE:
      okay=FALSE;
      if (doc->flags&DOCF_PLAIN_TEXT)
	DocFlagsToggle(doc,DOCF_PLAIN_TEXT);
      DocWrite(doc);
      task=Spawn(&SrvUserCmdLine,NULL,"Srv",,Fs);
      st2=CurDir;
      st=MSPrintF("Cd(\"%s\");",st2);
      tempc=TaskExeStrQue(task,Fs,st,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
      Free(st2);
      Free(st);
      SetWinHorz(Fs->win_left,Fs->win_right, task);
      SetWinVert(Fs->win_top, Fs->win_bottom,task);
      if (ScanResult(tempc,&r)) {
	st=DirFile(doc->filename.name,,"PRJ.Z"),
	      prj_file=FileNameAbs(st,FUF_Z_OR_NOT_Z);
	Free(st);
	if (FileFind(prj_file)) {
	  st2=DirFile(prj_file),
	  st=MSPrintF("Cd(\"%s\");",st2);
	  Free(st2);
	  tempc=TaskExeStrQue(task,Fs,st,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER|1<<SVCf_FREE_ON_COMPLETE);
	  Free(st);
	  st=MSPrintF("\"$$WW,1$$\";Cmp(\"%s\",\"SysTemp\",\"SysTemp\");",prj_file);
	  tempc=TaskExeStrQue(task,Fs,st,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
	  Free(st);
	  if (ScanResult(tempc,&r))
	    if (!r) {
	      tempc=TaskExeStrQue(task,Fs,
		    "Load(\"SysTemp\",LDF_JUST_LOAD);",1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
	      if (ScanResult(tempc,&r))
		okay=TRUE;
	    }
	  tempc=TaskExeStrQue(task,Fs,"Del(\"SysTemp.*\");",1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
	  ScanResult(tempc,&r);
	} else {
	  Free(prj_file);
	  st=DirFile(doc->filename.name,"Load","CPP.Z");
	  prj_file=FileNameAbs(st,FUF_Z_OR_NOT_Z);
	  Free(st);
	  if (FileFind(prj_file))
	    st=MSPrintF("\"$$WW,1$$\";ExeFile(\"%s\",TRUE);",prj_file);
	  else
	    st=MSPrintF("\"$$WW,1$$\";ExeFile(\"%s\",TRUE);",doc->filename.name);
	  tempc=TaskExeStrQue(task,Fs,st,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
	  Free(st);
	  if (ScanResult(tempc,&r) && r)
	    okay=TRUE;
	}
	Free(prj_file);
      }
      if (!okay) {
	PopUpOk("Has Errors");
	while (LBts(&sys_semas[SYS_SEMA_FIX],0))
	  Yield;
	ToFileLine(sys_fix_file_line,&st,&i);
	LBtr(&sys_semas[SYS_SEMA_FIX],0);
	if (!StrCmp(st,doc->filename.name))
	  goto_line_num=i;
	Free(st);
      }
      break;
    case EF_REINDENT:
      if (EdGoToFun(doc,FALSE,FALSE)) {
	start_y=doc->cur_entry->y;
	indent=EdRICode(doc);
	DocUnlock(doc);
	Snd(2000); Sleep(150); Snd(0);
	Sleep(100);
	Snd(2000); Sleep(150); Snd(0);
	DocLock(doc);
	EdRemFunLeadingSpace(doc);
	DocLineNumGoTo(doc,start_y+1);
	doc_e=doc->cur_entry;
	end_y=start_y+indent->total_cnt;
	while (start_y<=doc_e->y<end_y) {
	  if (doc_e!=doc && doc_e!=doc->cur_entry &&
		!(doc_e->flags1&(DOCEG1_DONT_EDIT-DOCEF1_SCROLLING_X)) &&
		!(doc_e->flags2&DOCEG2_DONT_EDIT)) {
	    if (doc_e->type_u8==DOCT_NEW_LINE||doc_e->type_u8==DOCT_SOFT_NEW_LINE)
	      start_of_line=TRUE;
	    else {
	      if (start_of_line) {
		i=QueVectU8Get(indent,doc_e->y)*C_INDENT_SPACES;
		x=doc_e->x+1;
		while (i>8) {
		  doc_ne=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
		  doc_ne->type=DOCT_TAB | doc->settings_root.dft_text_attr << 8;
		  doc_ne->x=x;
		  doc_ne->y=doc_e->y;
		  doc_ne->page_line_num=doc_e->page_line_num;
		  QueIns(doc_ne,doc_e->last);
		  i-=8;
		  x+=8;
		}
		if (i>0) {
		  b=MAlloc(i+1,doc->mem_task);
		  MemSet(b,CH_SPACE,i);
		  b[i]=0;
		  doc_ne=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
		  doc_ne->type=DOCT_TEXT | doc->settings_root.dft_text_attr << 8;
		  doc_ne->tag=b;
		  doc_ne->max_col=1;
		  doc_ne->x=x;
		  doc_ne->y=doc_e->y;
		  doc_ne->page_line_num=doc_e->page_line_num;
		  QueIns(doc_ne,doc_e->last);
		}
	      }
	      start_of_line=FALSE;
	    }
	  }
	  doc_e=doc_e->next;
	}
	QueVectU8Del(indent);
      }
      break;
    case EF_RENUM_ASM:
      if (EdGoToFun(doc,FALSE,TRUE)) {
	if (EdCurU8(doc)=='{') {
	  EdCursorRight(doc);
	  DocRecalc(doc);
	} else if (EdCurU8(doc)==':') {
	  EdCursorRight(doc);
	  if (EdCurU8(doc)==':')
	    EdCursorRight(doc);
	  DocRecalc(doc);
	}
	DocUnlock(doc);
	Snd(2000); Sleep(150); Snd(0);
	Sleep(100);
	Snd(2000); Sleep(150); Snd(0);
	DocLock(doc);
	EdRenumAsm(doc);
      }
      break;
  }
Ejemplo n.º 16
0
int noteye_eventtokey(SDL_Event *ev) {
  SDL_KeyboardEvent& kev(ev->key);
  // int mod = kev.keysym.mod;

  if(ev->type == SDL_TEXTINPUT)
    return kev.keysym.sym;
  
  bool down = ev->type == SDL_KEYDOWN;

  int retkey = 0;

  if(!down) return 0;

  int sym = kev.keysym.sym;
  
  #define Snd(key, x) else if(sym == SDLK_ ## key) retkey = x;
  #define SndKP(key, x) else if(sym == SDLK_KP_ ## key) retkey = x;
  
  if(sym == SDLK_LSHIFT) return 0;
  else if(sym == SDLK_RSHIFT) return 0;
  else if(sym == SDLK_LCTRL) return 0;
  else if(sym == SDLK_RCTRL) return 0;
  else if(sym == SDLK_LALT) return 0;
  else if(sym == SDLK_RALT) return 0;
  else if(sym == SDLK_CAPSLOCK) return 0;

  else if(sym == SDLK_RETURN) retkey = '\n';
  Snd(KP_ENTER, '\n')

  Snd(BACKSPACE, '\b')
  Snd(TAB, '\t')
  Snd(F1, KEY_F0+1)
  Snd(F2, KEY_F0+2)
  Snd(F3, KEY_F0+3)
  Snd(F4, KEY_F0+4)
  Snd(F5, KEY_F0+5)
  Snd(F6, KEY_F0+6)
  Snd(F7, KEY_F0+7)
  Snd(F8, KEY_F0+8)
  Snd(F9, KEY_F0+9)
  Snd(F10, KEY_F0+10)
  Snd(F11, KEY_F0+11)
  Snd(F12, KEY_F0+12)

  // linux terminal
  Snd(UP, D_UP)
  Snd(DOWN, D_DOWN)
  Snd(RIGHT, D_RIGHT)
  Snd(LEFT, D_LEFT)
  Snd(HOME, D_HOME)
  Snd(END, D_END)
  Snd(PAGEUP, D_PGUP)
  Snd(PAGEDOWN, D_PGDN)

  SndKP(8, D_UP)
  SndKP(2, D_DOWN)
  SndKP(6, D_RIGHT)
  SndKP(4, D_LEFT)
  SndKP(7, D_HOME)
  SndKP(1, D_END)
  SndKP(9, D_PGUP)
  SndKP(3, D_PGDN)
  SndKP(5, D_CTR)

  #undef Snd
  #undef SndKP
  
  if(sym > 0 && sym < 32) return sym;

  if(sym >= 'a' && sym <= 'z' && (ev->key.keysym.mod & (KMOD_LCTRL|KMOD_RCTRL))) 
    return sym - 96;

  // added by JT: maybe we need to do this differently, but it seems to work
  if(sym >= 'a' && sym <= 'z' && (ev->key.keysym.mod & KMOD_LALT)) 
    return sym;
  
  // use this for NotEye specials
  if((sym >= 1024 && sym < 0x10000000) || sym < 0)
    return sym;

  return retkey;
  }
Ejemplo n.º 17
0
int noteye_eventtokey(SDL_Event *ev) {
  SDL_KeyboardEvent& kev(ev->key);
  int symbol = kev.keysym.sym;
  int mod = kev.keysym.mod;
  bool down = ev->type == SDL_KEYDOWN;
  int unicode = kev.keysym.unicode;

  int retkey;

  if(!down) return 0;

  int sym = symbol;
  
  char ac = unicode;
  
  #define Snd(key, x) else if(sym == SDLK_ ## key) retkey = x;
  
  if(sym == SDLK_LSHIFT) return 0;
  else if(sym == SDLK_RSHIFT) return 0;
  else if(sym == SDLK_LCTRL) return 0;
  else if(sym == SDLK_RCTRL) return 0;
  else if(sym == SDLK_LALT) return 0;
  else if(sym == SDLK_RALT) return 0;
  else if(sym == SDLK_CAPSLOCK) return 0;

  else if(sym == SDLK_RETURN) retkey = '\n';
  Snd(BACKSPACE, '\b')
  Snd(TAB, '\t')
  Snd(F1, KEY_F0+1)
  Snd(F2, KEY_F0+2)
  Snd(F3, KEY_F0+3)
  Snd(F4, KEY_F0+4)
  Snd(F5, KEY_F0+5)
  Snd(F6, KEY_F0+6)
  Snd(F7, KEY_F0+7)
  Snd(F8, KEY_F0+8)
  Snd(F9, KEY_F0+9)
  Snd(F10, KEY_F0+10)
  Snd(F11, KEY_F0+11)
  Snd(F12, KEY_F0+12)

  // linux terminal
  Snd(UP, D_UP)
  Snd(DOWN, D_DOWN)
  Snd(RIGHT, D_RIGHT)
  Snd(LEFT, D_LEFT)
  Snd(HOME, D_HOME)
  Snd(END, D_END)
  Snd(PAGEUP, D_PGUP)
  Snd(PAGEDOWN, D_PGDN)

  Snd(KP8, D_UP)
  Snd(KP2, D_DOWN)
  Snd(KP6, D_RIGHT)
  Snd(KP4, D_LEFT)
  Snd(KP7, D_HOME)
  Snd(KP1, D_END)
  Snd(KP9, D_PGUP)
  Snd(KP3, D_PGDN)
  Snd(KP5, D_CTR)

  #undef Snd

  else retkey = ac;
  
  return retkey;
  }