外设天下 - 电脑外设发烧友聚集地

我的人缘0
21
发表于 2014-10-9 22:23 只看该作者
AndroidOL 发表于 2014-10-9 21:59
当前进度:
  渐变算法初步完成

感谢分享,明天回家翻出g19来试试。
回复 支持 反对

使用道具 举报

我的人缘0
22
发表于 2014-10-9 22:46 只看该作者

RGB 渐变基本实现,精度为 1 色度

本帖最后由 AndroidOL 于 2014-10-12 15:33 编辑
cS铁杆粉丝 发表于 2014-10-9 22:23
感谢分享,明天回家翻出g19来试试。

请麻烦测试以下脚本

目前存在的问题:
  由于 Logitech Gaming Software 不提供多线程支持,无法检测结束条件,目前正在查找解决方案

关闭脚本的方式:
  在脚本编辑器中按下 Ctrl + S 保存脚本或退出 Logitech Gaming Software,系统将重置脚本并停止死循环。
  1. function OnEvent(event, arg)
  2.         if (event == "G_PRESSED" and arg == 1) then
  3.                 colorList = {}
  4.                 table.insert(colorList, {
  5.                         Name = "#FF1B1B",
  6.                         Red = 255,
  7.                         Green = 27,
  8.                         Blue = 27
  9.                 })
  10.                 table.insert(colorList, {
  11.                         Name = "#FF761B",
  12.                         Red = 255,
  13.                         Green = 118,
  14.                         Blue = 27
  15.                 })
  16.                 table.insert(colorList, {
  17.                         Name = "#FFA41B",
  18.                         Red = 255,
  19.                         Green = 164,
  20.                         Blue = 27
  21.                 })
  22.                 table.insert(colorList, {
  23.                         Name = "#FFD21B",
  24.                         Red = 255,
  25.                         Green = 210,
  26.                         Blue = 27
  27.                 })
  28.                 table.insert(colorList, {
  29.                         Name = "#FEFF1B",
  30.                         Red = 254,
  31.                         Green = 255,
  32.                         Blue = 27
  33.                 })
  34.                 table.insert(colorList, {
  35.                         Name = "#B1E819",
  36.                         Red = 177,
  37.                         Green = 232,
  38.                         Blue = 25
  39.                 })
  40.                 table.insert(colorList, {
  41.                         Name = "#17D21B",
  42.                         Red = 23,
  43.                         Green = 210,
  44.                         Blue = 27
  45.                 })
  46.                 table.insert(colorList, {
  47.                         Name = "#17A2D2",
  48.                         Red = 23,
  49.                         Green = 162,
  50.                         Blue = 210
  51.                 })
  52.                 table.insert(colorList, {
  53.                         Name = "#1763D2",
  54.                         Red = 23,
  55.                         Green = 99,
  56.                         Blue = 210
  57.                 })
  58.                 table.insert(colorList, {
  59.                         Name = "#3817D2",
  60.                         Red = 56,
  61.                         Green = 23,
  62.                         Blue = 210
  63.                 })
  64.                 table.insert(colorList, {
  65.                         Name = "#9717D2",
  66.                         Red = 151,
  67.                         Green = 23,
  68.                         Blue = 210
  69.                 })
  70.                 table.insert(colorList, {
  71.                         Name = "#DE1888",
  72.                         Red = 222,
  73.                         Green = 24,
  74.                         Blue = 136
  75.                 })

  76.                 colorTemp = {
  77.                         ["Red"] = 255,
  78.                         ["Green"] = 255,
  79.                         ["Blue"] = 255
  80.                 }

  81.                 SetBacklightColor(255, 255, 255)

  82.                 while true do
  83.                         for loop = 1, #colorList do
  84.                                 OutputLogMessage("Color-No." .. loop .. ":\t" .. colorList[loop].Name .. "\n")
  85.                                 r = colorTemp.Red
  86.                                 g = colorTemp.Green
  87.                                 b = colorTemp.Blue
  88.                                 rIV = (colorList[loop].Red - r) / 50 - ((colorList[loop].Red - r) / 50) % 0.01
  89.                                 gIV = (colorList[loop].Green - g) / 50 - ((colorList[loop].Green - g) / 50) % 0.01
  90.                                 bIV = (colorList[loop].Blue - b) / 50 - ((colorList[loop].Blue - b) / 50) % 0.01
  91.                                 OutputLogMessage("rIV.Red: " .. rIV .. ",\tgIV: " .. gIV .. ",\tbIV: " .. bIV .. "\n")
  92.                                 for loopColor = 1, 50 do
  93.                                         colorTemp.Red = colorTemp.Red + rIV
  94.                                         colorTemp.Green = colorTemp.Green + gIV
  95.                                         colorTemp.Blue = colorTemp.Blue + bIV
  96.                                         SetBacklightColor(colorTemp.Red, colorTemp.Green, colorTemp.Blue)
  97.                                         --OutputLogMessage("colorTemp.Red: " .. colorTemp.Red .. ",\tcolorTemp.Green: " .. colorTemp.Green .. ",\tcolorTemp.Blue: " .. colorTemp.Blue .. "\n")
  98.                                         Sleep(50)
  99.                                         --if (event == "G_PRESSED" and arg == 6) then
  100.                                                 --break
  101.                                         --end
  102.                                 end
  103.                                 colorTemp.Red = math.ceil(colorTemp.Red)
  104.                                 colorTemp.Green = math.ceil(colorTemp.Green)
  105.                                 colorTemp.Blue = math.ceil(colorTemp.Blue)
  106.                                 --OutputLogMessage("Loop: " .. loop .. ". Target. To. R: " .. colorTemp.Red .. "/G: " .. colorTemp.Green .. "/B: " .. colorTemp.Blue .. "\n")
  107.                                 --OutputLogMessage("Loop: " .. loop .. ". Target. To. R: " .. colorList[loop].Red .. "/G: " .. colorList[loop].Green .. "/B: " .. colorList[loop].Blue .. "\n\n")
  108.                                 colorTemp.Red = colorList[loop].Red
  109.                                 colorTemp.Green = colorList[loop].Green
  110.                                 colorTemp.Blue = colorList[loop].Blue
  111.                                 SetBacklightColor(colorTemp.Red, colorTemp.Green, colorTemp.Blue)
  112.                         end
  113.                 end
  114.         end
  115. end
复制代码
回复 支持 反对

使用道具 举报

我的人缘0
23
发表于 2014-10-10 09:51 只看该作者
Logitech Gaming Software G 系列 Lua API 中文参考文档 | 更新 RGB 渐变及键值输出

结束循环然后各种问题。。
回复 支持 反对

使用道具 举报

我的人缘0
24
发表于 2014-10-12 15:07 只看该作者

任意包含特殊字符字符串输出(暂无法区分大小写)

本帖最后由 AndroidOL 于 2014-10-12 19:21 编辑

目前效率无法提升,由于 Logitech 尚未提供直接输出的 API 函数故只能通过模拟按键的方式进行输出,仅列举部分常用按键未增加大小写识别。

  1. function putChar(makeString)
  2.         if (makeString == "") then
  3.         else
  4.                 for loop = 1, #makeString do
  5.                         tempString = string.sub(makeString, loop, loop)
  6.                         if (tempString == " ") then
  7.                                 PressAndReleaseKey("spacebar")
  8.                         elseif (tempString == "`") then
  9.                                 PressAndReleaseKey("tilde")
  10.                         elseif (tempString == "-") then
  11.                                 PressAndReleaseKey("minus")
  12.                         elseif (tempString == "=") then
  13.                                 PressAndReleaseKey("equal")
  14.                         elseif (tempString == "\b") then
  15.                                 PressAndReleaseKey("backspace")
  16.                         elseif (tempString == "\t") then
  17.                                 PressAndReleaseKey("tab")
  18.                         elseif (tempString == "[") then
  19.                                 PressAndReleaseKey("lbracket")
  20.                         elseif (tempString == "]") then
  21.                                 PressAndReleaseKey("rbracket")
  22.                         elseif (tempString == "\\") then
  23.                                 PressAndReleaseKey("backslash")
  24.                         elseif (tempString == ";") then
  25.                                 PressAndReleaseKey("semicolon")
  26.                         elseif (tempString == "'") then
  27.                                 PressAndReleaseKey("quote")
  28.                         elseif (tempString == "\n") then
  29.                                 PressAndReleaseKey("enter")
  30.                         elseif (tempString == ",") then
  31.                                 PressAndReleaseKey("comma")
  32.                         elseif (tempString == ".") then
  33.                                 PressAndReleaseKey("period")
  34.                         elseif (tempString == "/") then
  35.                                 PressAndReleaseKey("slash")
  36.                         elseif (tempString == ":") then
  37.                                 PressKey("lshift")
  38.                                 PressKey("semicolon")
  39.                                 ReleaseKey("semicolon")
  40.                                 ReleaseKey("lshift")
  41.                         elseif (tempString == "!") then
  42.                                 PressKey("lshift")
  43.                                 PressKey("1")
  44.                                 ReleaseKey("1")
  45.                                 ReleaseKey("lshift")
  46.                         elseif (tempString == "@") then
  47.                                 PressKey("lshift")
  48.                                 PressKey("2")
  49.                                 ReleaseKey("2")
  50.                                 ReleaseKey("lshift")
  51.                         elseif (tempString == "#") then
  52.                                 PressKey("lshift")
  53.                                 PressKey("3")
  54.                                 ReleaseKey("3")
  55.                                 ReleaseKey("lshift")
  56.                         elseif (tempString == "[        DISCUZ_CODE_0        ]quot;) then
  57.                                 PressKey("lshift")
  58.                                 PressKey("4")
  59.                                 ReleaseKey("4")
  60.                                 ReleaseKey("lshift")
  61.                         elseif (tempString == "%") then
  62.                                 PressKey("lshift")
  63.                                 PressKey("5")
  64.                                 ReleaseKey("5")
  65.                                 ReleaseKey("lshift")
  66.                         elseif (tempString == "^") then
  67.                                 PressKey("lshift")
  68.                                 PressKey("6")
  69.                                 ReleaseKey("6")
  70.                                 ReleaseKey("lshift")
  71.                         elseif (tempString == "&") then
  72.                                 PressKey("lshift")
  73.                                 PressKey("7")
  74.                                 ReleaseKey("7")
  75.                                 ReleaseKey("lshift")
  76.                         elseif (tempString == "*") then
  77.                                 PressKey("lshift")
  78.                                 PressKey("8")
  79.                                 ReleaseKey("8")
  80.                                 ReleaseKey("lshift")
  81.                         elseif (tempString == "(") then
  82.                                 PressKey("lshift")
  83.                                 PressKey("9")
  84.                                 ReleaseKey("9")
  85.                                 ReleaseKey("lshift")
  86.                         elseif (tempString == ")") then
  87.                                 PressKey("lshift")
  88.                                 PressKey("0")
  89.                                 ReleaseKey("0")
  90.                                 ReleaseKey("lshift")
  91.                         elseif (tempString == "_") then
  92.                                 PressKey("lshift")
  93.                                 PressKey("minus")
  94.                                 ReleaseKey("minus")
  95.                                 ReleaseKey("lshift")
  96.                         elseif (tempString == "+") then
  97.                                 PressKey("lshift")
  98.                                 PressKey("equal")
  99.                                 ReleaseKey("equal")
  100.                                 ReleaseKey("lshift")
  101.                         elseif (tempString == "{") then
  102.                                 PressKey("lshift")
  103.                                 PressKey("lbracket")
  104.                                 ReleaseKey("lbracket")
  105.                                 ReleaseKey("lshift")
  106.                         elseif (tempString == "}") then
  107.                                 PressKey("lshift")
  108.                                 PressKey("rbracket")
  109.                                 ReleaseKey("rbracket")
  110.                                 ReleaseKey("lshift")
  111.                         elseif (tempString == "|") then
  112.                                 PressKey("lshift")
  113.                                 PressKey("backslash")
  114.                                 ReleaseKey("backslash")
  115.                                 ReleaseKey("lshift")
  116.                         elseif (tempString == "\"") then
  117.                                 PressKey("lshift")
  118.                                 PressKey("quote")
  119.                                 ReleaseKey("quote")
  120.                                 ReleaseKey("lshift")
  121.                         elseif (tempString == "<") then
  122.                                 PressKey("lshift")
  123.                                 PressKey("comma")
  124.                                 ReleaseKey("comma")
  125.                                 ReleaseKey("lshift")
  126.                         elseif (tempString == ">") then
  127.                                 PressKey("lshift")
  128.                                 PressKey("period")
  129.                                 ReleaseKey("period")
  130.                                 ReleaseKey("lshift")
  131.                         elseif (tempString == "?") then
  132.                                 PressKey("lshift")
  133.                                 PressKey("slash")
  134.                                 ReleaseKey("slash")
  135.                                 ReleaseKey("lshift")
  136.                         else
  137.                                 PressAndReleaseKey(tempString)
  138.                         end
  139.                 end
  140.         end
  141. end

  142. function OnEvent(event, arg)
  143.         if (event == "G_PRESSED") then
  144.                 tempChar = GetDate()
  145.                 putChar(tempChar)
  146.         end
  147. end
复制代码


目前未找到更优方法,table.find() 以及 table.maxn() 方法将隐式消耗 CPU 时间故弃用。
回复 支持 反对

使用道具 举报

我的人缘0
25
发表于 2014-10-12 15:36 只看该作者
测试
目录编辑测试:
  1. [index]
  2. [#583705,6844900]使用 G1~G5 联合 M1~M3 输出数字 1~18
  3. [#583705,6846293]调用 API 移动鼠标以及输出按键信息
  4. [#583705,6862120]M1~M3 键捕捉同时移动鼠标
  5. [#583705,6897975]RGB 渐变基本实现,精度为 1 色度
  6. [#583705,6908090]R任意包含特殊字符字符串输出(赞无法区分大小写)
  7. [\index]
复制代码
回复 支持 反对

使用道具 举报

我的人缘0
26
发表于 2014-10-12 16:31 只看该作者
AndroidOL 发表于 2014-9-25 19:12
问几个问题哈~

罗技G系列最便宜的是100s么?100似乎停产?

G系列鼠标最便宜的应该是G90吧?100停产了。
G602是中端产品,作为第一款02结尾的G系列鼠标G602充其量也就是罗技的一个试水产品,
G700算是高端,引擎、微动、滚轮等多方面因素决定了价格。
G600定位一样也是中端但是刚上市的时候价格太高,前几年我看玩白色G600的人挺多的,那会儿我也一直想搞一个白色G600,最后还是搁浅了,最近感觉一个都看不到了,
至于国行G600只有黑色,再加上奇葩的造型,估计很多密集恐惧症的人都望而却步了……
回复 支持 反对

使用道具 举报

我的人缘0
27
发表于 2014-10-12 16:35 只看该作者
LuckyBird929 发表于 2014-9-26 17:43
碉堡 工科男表示看不懂 - -

同工科,而且专业还是能源矿物类,大学C语言考试都是靠短信通过……
回复 支持 反对

使用道具 举报

我的人缘0
28
发表于 2014-10-12 16:41 只看该作者
bink1990 发表于 2014-10-12 16:31
G系列鼠标最便宜的应该是G90吧?100停产了。
G602是中端产品,作为第一款02结尾的G系列鼠标G602充其量也 ...

谢谢,目前只要是 RGB + 多侧键就行了,G90 只有一个 DPI 更改。
G600 以及 G13 之间准备买一个做测试,外观我一点也无所谓,不是买来看得。
回复 支持 反对

使用道具 举报

我的人缘0
29
发表于 2014-10-12 17:51 只看该作者
AndroidOL 发表于 2014-10-12 16:41
谢谢,目前只要是 RGB + 多侧键就行了,G90 只有一个 DPI 更改。
G600 以及 G13 之间准备买一个做测试, ...

玩儿RGB灯何不尝试RIVAL呢?要是你能等罗技更新固件也可以入个G502,据说这玩意的灯是RGB,反正我是没琢磨出来怎么让他变色……
回复 支持 反对

使用道具 举报

我的人缘0
30
发表于 2014-10-12 19:12 只看该作者
测试
本帖最后由 AndroidOL 于 2014-10-12 19:18 编辑
bink1990 发表于 2014-10-12 17:51
玩儿RGB灯何不尝试RIVAL呢?要是你能等罗技更新固件也可以入个G502,据说这玩意的灯是RGB,反正我是没琢 ...

不是玩,我不玩外设,家里的情况也没可能给我玩这些东西,当时买机械纯粹为了码代码。到目前为止,除了 Logitech 以外,没有任何厂商提供可编程支持,所以那些那 RGB 对我来说也就停留在花哨的层面。
我买来是准备测试脚本用的,但又没多少钱去买。目前最便宜的应该是G600了,12侧键+RGB。

G502 不能使用 SetBacklightColor() 方法,蓝色呼吸灯+DPI变色吧好像。

多余的话:
来外设天下看见不少人签名档里各种鼠标、键盘、耳机,我只想问你们买那么多是准备天天换还是见人就送?实在看不懂,不明白何必在这上面花那么多钱。

点评

是吧,其实我也不懂……  详情 回复 发表于 2014-10-12 22:52
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则