Skip to content

Commit

Permalink
Merge pull request #2 from nikolat/fix_#1
Browse files Browse the repository at this point in the history
Fix #1
  • Loading branch information
nikolat committed Dec 17, 2021
2 parents 093498f + 13b21cb commit 7a05194
Show file tree
Hide file tree
Showing 6 changed files with 303 additions and 18 deletions.
69 changes: 54 additions & 15 deletions ghost/master/main.azr
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ int display_height = -1;
int dance = 0;
int saved_dance = 0;
int maxscope = 0;
int stayontop = 0;
int icon_no = 0;
array isdragging;
array surface_width;
array surface_height;
array ismouseleft;
double CHECK_MOUSE_INTERVAL = 0.125;
double DANCE_ICON_INTERVAL = 2.000;
int THRESHOLD_DISTANCE = 300;

load()
{
_saoriload("saori\HandUtil\HandUtil.dll", "HandUtil");
_saoriload("saori\ccpuid\ccpuid.dll", "ccpuid");
maxscope = count_scope();
for (int i = 0; i <= maxscope; i++)
{
Expand All @@ -23,10 +27,12 @@ load()
ismouseleft += 0;
}
_create_thread("TH_CheckMouse");
_create_thread("TH_DanceIcon");
}
unload()
{
_saoriunload("HandUtil");
_saoriunload("ccpuid");
unloaded = 1;
}

Expand Down Expand Up @@ -98,11 +104,11 @@ string OnUpdateBegin()
{
saved_dance = dance;
dance = 0;
return show_update_info("Update Begin.") + "\e";
return show_info("Network Update", "Update Begin.") + "\e";
}
string OnUpdateReady()
{
return show_update_info("Updating...") + "\e";
return show_info("Network Update", "Updating...") + "\e";
}
string OnUpdateComplete(dict ref)
{
Expand All @@ -112,18 +118,17 @@ string OnUpdateComplete(dict ref)
dance = saved_dance;
else if (reason == "changed")
s += show_scope_all();
s += show_update_info(reason) + "\e";
s += show_info("Network Update", reason) + "\e";
return s;
}
string OnUpdateFailure(dict ref)
{
string reason = ref["Reference0"];
dance = saved_dance;
return show_update_info(reason) + "\e";
return show_info("Network Update", reason) + "\e";
}
string show_update_info(string text)
string show_info(string title, string text)
{
string title = "Network Update";
string icon = "info";
return "\![set,trayballoon,--icon=" + icon + ",--title=" + title + ",--text=" + text + "]";
}
Expand Down Expand Up @@ -183,22 +188,34 @@ OnPartyParrotSetDragging(dict ref)
isdragging[scope] = n;
}

string OnSecondChange(dict ref)
TH_DanceIcon()
{
if (!dance)
return "";
return dance_icon() + "\e";
while(1)
{
if (unloaded)
break;
if (dance)
{
string s = dance_icon();
if (s != "")
_speak(s);
}
_sleep(DANCE_ICON_INTERVAL);
}
}
string dance_icon()
{
dict d = _saorirequest("ccpuid", "cpu.usage");
int cpu_usage = d["Result"];
int offset = 30;
int wait = offset + 50 - (cpu_usage / 2);
string s = "";
for (int i = 0; i < 10; i++)
for (int t = 0; t < 1000 * DANCE_ICON_INTERVAL; t += wait)
{
s += "\![set,tasktrayicon,icon/parrot" + i + ".ico]";
if (i < 9)
s += "\_w[50]";
s += "\![set,tasktrayicon,icon/parrot" + icon_no + ".ico]";
s += "\_w[" + wait + "]";
icon_no = (icon_no + 1) % 10;
}
s += "\_w[50]" + s;
return s;
}

Expand Down Expand Up @@ -412,3 +429,25 @@ delete_scope(int scope)
string file = basepath + "surfaces" + fill2(maxscope) + ".txt";
_fdelete(file);
}

string OnKeyPress(dict ref)
{
return _fncstr("key_" + ref["Reference0"], ref);
}
string key_t(dict ref)
{
stayontop = !stayontop;
string s;
if (stayontop)
{
s += "\![set,windowstate,stayontop]";
s += show_info("Always on top", "ON");
}
else
{
s += "\![set,windowstate,!stayontop]";
s += show_info("Always on top", "OFF");
}
s += "\e";
return s;
}
77 changes: 77 additions & 0 deletions ghost/master/saori/ccpuid/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
[UTF-8 English]
CCPUID (CSAORI saori_cpuid)

CCPUID is a saori_cpuid rewritten by using CSAORI.
CCPUID is fully compatible with saori_cpuid.dll by Ewi Nanase, see saori_cpuid_README.txt for details.

New Functions:
cpu.features - list all CCPUID known CPU features (short name) with space separated.
cpu.cache - return CPU caches sizes in KB with space separated, format: "L1-Data L1-Inst L2 L3"
cpu.usage - return CPU usage (0 - 100)
mem.viraex - return available extended virtual memory (over 4GB memory) (by ukiya)

Version History:
20100420 - Release 4
- add mem.viraex
- add "cpu.usage" function
- remove "Microsoft " from os.name
- fix mem.*(except mem.os) to match description in saori_cpuid_README.txt (All in MB, not in bytes)
20090903 - Release 3
- add fallback when branding can't be retrieved from CPUID
- fix: don't try to retrieve CPUID information which is higher than reported highest CPUID
20090831 - Release 2
- add "cpu.cache" function
- fix cpu.clockex always return with ".000" ending problem
20090830 - Release 1
- initial release

Credits:
CCPUID by Roy Tam.
Part of code are modified from the orginal codes:
CPUID.C - V0.2 - Jim Howes <jimhowes@ (exactly the same again).net>
CPU Speed functions are copied from:
http://www.rohitab.com/discuss/lofiversion/index.php/t26562.html
Getting the System Version:
http://msdn.microsoft.com/en-us/library/ms724429(VS.85).aspx
CPUID Sample: Determines CPU Capabilities
http://msdn.microsoft.com/en-us/library/xs6aek1h(VS.80).aspx
如何获得CPU使用率 (How to get CPU usage)
http://www.4oa.com/Article/html/6/33/487/2005/17522.html

[UTF-8 Chinese Traditional]
ccpuid是用CSAORI把saori_cpuid的功能重寫。
而這次是完全跟saori_cpuid兼容的,再加上新指令。

新指令:
cpu.features - 列出所有CCPUID已知的CPU功能的簡寫,並以空格隔開回傳。
cpu.cache - 回傳所有 CPU 的快取大小 (KB) 並以空格隔開,格式: "L1-Data L1-Inst L2 L3"
cpu.usage - 回傳 CPU 使用率 (0 - 100)
mem.viraex - 回傳可用的延伸虛擬記憶體 (超過 4GB 的虛擬記憶體) (ukiya)

版本歷史:
20100420 - Release 4
- 新增 mem.viraex
- 新增 "cpu.usage" 功能
- 自 os.name 中移除 "Microsoft "
- 修正 mem.*(除 mem.os) 讓功能和 saori_cpuid_README.txt 中的描述一致(皆為 MB,非位元組)
20090903 - Release 3
- 新增當 CCPUID 不能從 CPUID 中獲得 CPU 名稱時的應變策略
- 修正:不嘗試獲得高於最高 CPUID 代碼的 CPUID 資訊
20090831 - Release 2
- 新增 "cpu.cache" 功能
- 修正 cpu.clockex 回傳 ".000" 為結尾的問題
20090830 - Release 1
- 初版

鳴謝:
CCPUID 由 Roy Tam 所寫。
部份源程式碼修改自以下的代碼:
CPUID.C - V0.2 - Jim Howes <jimhowes@ (exactly the same again).net>
CPU Speed 功能源自:
http://www.rohitab.com/discuss/lofiversion/index.php/t26562.html
Getting the System Version:
http://msdn.microsoft.com/en-us/library/ms724429(VS.85).aspx
CPUID Sample: Determines CPU Capabilities
http://msdn.microsoft.com/en-us/library/xs6aek1h(VS.80).aspx
如何获得CPU使用率
http://www.4oa.com/Article/html/6/33/487/2005/17522.html
Binary file added ghost/master/saori/ccpuid/ccpuid.dll
Binary file not shown.
157 changes: 157 additions & 0 deletions ghost/master/saori/ccpuid/saori_cpuid_README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#######################################################
SAORI CPU/OS情報取得プラグイン saori_cpuid.dll

Copyright 2002-2003 Ewi Nanase ([email protected])
#######################################################

######################################################
# 概要
######################################################
saori_cpuid.dllはCPU/OSの情報を取得するSAORIモジュールです。


######################################################
# 使用方法
######################################################
下記のパラメータを渡してやると、それについての情報を
返してきます。

美坂での使用例
{$os_name={$saori("saori_cpuid.dll","os.name")}}
にて{$os_name}にオペレーティングシステムの名称が代入されます。


######################################################
# 引数
#
######################################################
# オペレーティングシステム関連
#
os.name オペレーティングシステムの名称
例: Windows XP Home Edition
Windows 98

os.version オペレーティングシステムのバージョン番号
例:Windows XP = 5.1
Windows 2000 = 5.0
Windows Me = 4.90
Windows 98= 4.10

os.build オペレーティングシステムのビルド番号


#####################################################
# CPU関連情報
#

cpu.num CPUの個数

cpu.vender CPUのベンダー名
例:GenuineIntel

cpu.name CPUの名称
※必ずしも詳しく名称が出るとは限らない。

cpu.ptype CPUプロセッサータイプコード

cpu.family CPUファミリコード

cpu.model CPUモデルコード

cpu.stepping CPUステッピングコード

cpu.mmx MMX機能の有無
有り: Ready
無し: Not Ready

cpu.sse SSE機能の有無
有り: Ready
無し: Not Ready

cpu.sse2 SSE2機能の有無
有り: Ready
無し: Not Ready

cpu.tdn 3DNow!機能の有無
有り: Ready
無し: Not Ready

cpu.mmx+ MMX+機能の有無
有り: Ready
無し: Not Ready

cpu.tdn+ 3DNow!+機能の有無
有り: Ready
無し: Not Ready


cpu.htt Hyper Threading Tecnology機能の有無
有り: Ready
無し: Not Ready

cpu.clock CPUのクロックスピード
MH単位で取得

cpu.clockex CPUのクロックスピード
MH単位で取得(小数点3桁まで)


#####################################################
# メモリ関連情報
#

mem.os メモリの使用率

mem.phyt 物理メモリ 全体(MB)

mem.phya 物理メモリ 空き(MB)

mem.pagt ページファイルサイズ 全体(MB)

mem.paga ページファイルサイズ 空き(MB)

mem.virt 仮想メモリ 全体(MB)

mem.vira 仮想メモリ 空き(MB)


#####################################################
# その他
#
platform プラットフォーム名称
何か: materia.exe,embryo.exe等
SSP: ssp.exe
何かみたいな何か: duet.exe


#####################################################

<< 改変履歴 >>
Version 2.1.0 2004/04/17 STLライブラリをスタティックリンクしていなかった不具合を修正

Version 2.0.0 2004/04/09 3GHz以上のCPUクロックが正常に検出できない不具合を修正

Version 1.0.5 2003/08/05 "cpu.htt"でCPUがHyper Threading Technology機能
の有無を取得できるようにしました。

Version 1.0.4 2002/04/01 "cpu.clock"、"cpu.clockex"でCPUのクロックスピード
を取得できるようにしました。

Version 1.0.3 2002/03/31 cpu.famiry → cpu.familyに修正(スペルミス)
cpu.steppingが取得できない不具合を修正
ドキュメントにcpu.pnameとあるが実際にはcpu.ptype(ドキュメントの修正)

Version 1.0.2 2002/03/31 "platform"の追加。
デバッグでsaori.txtを出力していた不具合を修正。

Version 1.0.1 2002/03/30 Pentium以外のCPUのCPU名称の不具合を修正しました。

Version 1.0.0 2002/03/30 ファーストリリース



#####################################################
<<連絡先>>
七瀬いーうぃ ([email protected])
http://www.himawari-c.com/

Loading

0 comments on commit 7a05194

Please sign in to comment.