Advertisement
Guest User

g15daemon.patch

a guest
Apr 23rd, 2015
1,240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 21.83 KB | None | 0 0
  1. diff -Nuar g15daemon-1.9.5.3.orig/g15daemon/utility_funcs.c g15daemon-1.9.5.3/g15daemon/utility_funcs.c
  2. --- g15daemon-1.9.5.3.orig/g15daemon/utility_funcs.c    2008-01-26 07:02:07.000000000 +0200
  3. +++ g15daemon-1.9.5.3/g15daemon/utility_funcs.c 2011-11-09 09:19:43.000000000 +0200
  4. @@ -356,7 +356,7 @@
  5.      config_items_t * item=NULL;
  6.      char line[1024];
  7.      
  8. -    config_fd = open(filename,O_CREAT|O_RDWR|O_TRUNC);
  9. +    config_fd = open(filename,O_CREAT|O_RDWR|O_TRUNC, 0644);
  10.      if(config_fd){
  11.      snprintf(line,1024,"# G15Daemon Configuration File\n# any items entered before a [section] header\n# will be in the Global config space\n# comments you wish to keep should start with a semicolon';'\n");
  12.      write(config_fd,line,strlen(line));
  13.  
  14. --- g15daemon-1.9.5.3.orig/libg15daemon_client/g15daemon_net.c
  15. +++ g15daemon-1.9.5.3/libg15daemon_client/g15daemon_net.c
  16. @@ -217,7 +217,7 @@
  17.      if(poll(pfd,1,100)>0){
  18.         if(pfd[0].revents & POLLPRI && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) {
  19.               memset(packet,0,sizeof(packet));
  20. -             msgret = recv(sock, packet, 10 , MSG_OOB);
  21. +             msgret = recv(sock, packet, sizeof(packet) , MSG_OOB);
  22.               if (msgret < 1) {
  23.                    return -1;
  24.                }
  25. --- a/plugins/g15_plugin_uinput.c 2008-01-24 12:51:07.000000000 +0000
  26. +++ b/plugins/g15_plugin_uinput.c 2015-02-19 20:07:05.367774209 +0000
  27. @@ -43,9 +43,16 @@
  28.  
  29.  #include <libg15.h>
  30.  
  31. +static char cmd[256];
  32.  static int uinp_fd = -1;
  33.  static config_section_t *uinput_cfg=NULL;
  34.  static int map_Lkeys = 0;
  35. +static int vol_state = 0;
  36. +static int mkey_state = 0;
  37. +static int mr_state = 0;
  38. +static unsigned int mled_state = G15_LED_M1;
  39. +/*mkey state 0,1 and 2 = M1, M2 and M3*/
  40. +
  41.  
  42.  #define GKEY_OFFSET 167
  43.  #define MKEY_OFFSET 185
  44. @@ -125,6 +132,16 @@
  45.      event.value = G15KEY_DOWN;
  46.      
  47.      write (uinp_fd, &event, sizeof(event));
  48. +
  49. +    /* Need to write sync event */
  50. +    memset(&event, 0, sizeof(event));
  51. +
  52. +    event.type = EV_SYN;
  53. +    event.code = SYN_REPORT;
  54. +    event.value = 0;
  55. +
  56. +    write(uinp_fd, &event, sizeof(event));
  57. +
  58.  }
  59.  
  60.  static void g15_uinput_keyup(unsigned char code)
  61. @@ -137,8 +154,17 @@
  62.      event.value = G15KEY_UP;
  63.      
  64.      write (uinp_fd, &event, sizeof(event));
  65. -}
  66.  
  67. +    /* Need to write sync event */
  68. +    memset(&event, 0, sizeof(event));
  69. +
  70. +    event.type = EV_SYN;
  71. +    event.code = SYN_REPORT;
  72. +    event.value = 0;
  73. +
  74. +    write(uinp_fd, &event, sizeof(event));
  75. +
  76. +}
  77.      void (*keyup)(unsigned char code) = &g15_uinput_keyup;
  78.      void (*keydown)(unsigned char code) = &g15_uinput_keydown;
  79.  #else
  80. @@ -147,148 +173,338 @@
  81.  #endif
  82.  #endif
  83.      
  84. +/*The layout of the 'G' keys is now hard-coded here below. See /usr/include/linux/input.h for details on the keys you can use*/
  85.  static void g15_process_keys(g15daemon_t *masterlist, unsigned int currentkeys, unsigned int lastkeys)
  86.  {
  87. -    /* 'G' keys */
  88. -    if((currentkeys & G15_KEY_G1) && !(lastkeys & G15_KEY_G1))
  89. -        keydown(GKEY_OFFSET);
  90. -    else if(!(currentkeys & G15_KEY_G1) && (lastkeys & G15_KEY_G1))
  91. -        keyup(GKEY_OFFSET);
  92. -
  93. -    if((currentkeys & G15_KEY_G2) && !(lastkeys & G15_KEY_G2))
  94. -        keydown(GKEY_OFFSET+1);
  95. -    else if(!(currentkeys & G15_KEY_G2) && (lastkeys & G15_KEY_G2))
  96. -        keyup(GKEY_OFFSET+1);
  97. -
  98. -    if((currentkeys & G15_KEY_G3) && !(lastkeys & G15_KEY_G3))
  99. -        keydown(GKEY_OFFSET+2);
  100. -    else if(!(currentkeys & G15_KEY_G3) && (lastkeys & G15_KEY_G3))
  101. -        keyup(GKEY_OFFSET+2);
  102. -
  103. -    if((currentkeys & G15_KEY_G4) && !(lastkeys & G15_KEY_G4))
  104. -        keydown(GKEY_OFFSET+3);
  105. -    else if(!(currentkeys & G15_KEY_G4) && (lastkeys & G15_KEY_G4))
  106. -        keyup(GKEY_OFFSET+3);
  107. -
  108. -    if((currentkeys & G15_KEY_G5) && !(lastkeys & G15_KEY_G5))
  109. -        keydown(GKEY_OFFSET+4);
  110. -    else if(!(currentkeys & G15_KEY_G5) && (lastkeys & G15_KEY_G5))
  111. -        keyup(GKEY_OFFSET+4);
  112. -
  113. -    if((currentkeys & G15_KEY_G6) && !(lastkeys & G15_KEY_G6))
  114. -        keydown(GKEY_OFFSET+5);
  115. -    else if(!(currentkeys & G15_KEY_G6) && (lastkeys & G15_KEY_G6))
  116. -        keyup(GKEY_OFFSET+5);
  117. -
  118. -    if((currentkeys & G15_KEY_G7) && !(lastkeys & G15_KEY_G7))
  119. -        keydown(GKEY_OFFSET+6);
  120. -    else if(!(currentkeys & G15_KEY_G7) && (lastkeys & G15_KEY_G7))
  121. -        keyup(GKEY_OFFSET+6);
  122. -
  123. -    if((currentkeys & G15_KEY_G8) && !(lastkeys & G15_KEY_G8))
  124. -        keydown(GKEY_OFFSET+7);
  125. -    else if(!(currentkeys & G15_KEY_G8) && (lastkeys & G15_KEY_G8))
  126. -        keyup(GKEY_OFFSET+7);
  127. -
  128. -    if((currentkeys & G15_KEY_G9) && !(lastkeys & G15_KEY_G9))
  129. -        keydown(GKEY_OFFSET+8);
  130. -    else if(!(currentkeys & G15_KEY_G9) && (lastkeys & G15_KEY_G9))
  131. -        keyup(GKEY_OFFSET+8);
  132. -
  133. -    if((currentkeys & G15_KEY_G10) && !(lastkeys & G15_KEY_G10))
  134. -        keydown(GKEY_OFFSET+9);
  135. -    else if(!(currentkeys & G15_KEY_G10) && (lastkeys & G15_KEY_G10))
  136. -        keyup(GKEY_OFFSET+9);
  137. -
  138. -    if((currentkeys & G15_KEY_G11) && !(lastkeys & G15_KEY_G11))
  139. -        keydown(GKEY_OFFSET+10);
  140. -    else if(!(currentkeys & G15_KEY_G11) && (lastkeys & G15_KEY_G11))
  141. -        keyup(GKEY_OFFSET+10);
  142. -
  143. -    if((currentkeys & G15_KEY_G12) && !(lastkeys & G15_KEY_G12))
  144. -        keydown(GKEY_OFFSET+11);
  145. -    else if(!(currentkeys & G15_KEY_G12) && (lastkeys & G15_KEY_G12))
  146. -        keyup(GKEY_OFFSET+11);
  147. -
  148. -    if((currentkeys & G15_KEY_G13) && !(lastkeys & G15_KEY_G13))
  149. -        keydown(GKEY_OFFSET+12);
  150. -    else if(!(currentkeys & G15_KEY_G13) && (lastkeys & G15_KEY_G13))
  151. -        keyup(GKEY_OFFSET+12);
  152. -
  153. -    if((currentkeys & G15_KEY_G14) && !(lastkeys & G15_KEY_G14))
  154. -        keydown(GKEY_OFFSET+13);
  155. -    else if(!(currentkeys & G15_KEY_G14) && (lastkeys & G15_KEY_G14))
  156. -        keyup(GKEY_OFFSET+13);
  157. -
  158. -    if((currentkeys & G15_KEY_G15) && !(lastkeys & G15_KEY_G15))
  159. -        keydown(GKEY_OFFSET+14);
  160. -    else if(!(currentkeys & G15_KEY_G15) && (lastkeys & G15_KEY_G15))
  161. -        keyup(GKEY_OFFSET+14);
  162. -
  163. -    if((currentkeys & G15_KEY_G16) && !(lastkeys & G15_KEY_G16))
  164. -        keydown(GKEY_OFFSET+15);
  165. -    else if(!(currentkeys & G15_KEY_G16) && (lastkeys & G15_KEY_G16))
  166. -        keyup(GKEY_OFFSET+15);
  167. -
  168. -    if((currentkeys & G15_KEY_G17) && !(lastkeys & G15_KEY_G17))
  169. -        keydown(GKEY_OFFSET+16);
  170. -    else if(!(currentkeys & G15_KEY_G17) && (lastkeys & G15_KEY_G17))
  171. -        keyup(GKEY_OFFSET+16);
  172. -
  173. -    if((currentkeys & G15_KEY_G18) && !(lastkeys & G15_KEY_G18))
  174. -        keydown(GKEY_OFFSET+17);
  175. -    else if(!(currentkeys & G15_KEY_G18) && (lastkeys & G15_KEY_G18))
  176. -        keyup(GKEY_OFFSET+17);
  177. -
  178. -    /* 'M' keys */
  179. -
  180. -    if((currentkeys & G15_KEY_M1) && !(lastkeys & G15_KEY_M1))
  181. -        keydown(MKEY_OFFSET);
  182. -    else if(!(currentkeys & G15_KEY_M1) && (lastkeys & G15_KEY_M1))
  183. -        keyup(MKEY_OFFSET);
  184. -
  185. -    if((currentkeys & G15_KEY_M2) && !(lastkeys & G15_KEY_M2))
  186. -        keydown(MKEY_OFFSET+1);
  187. -    else if(!(currentkeys & G15_KEY_M2) && (lastkeys & G15_KEY_M2))
  188. -        keyup(MKEY_OFFSET+1);
  189. -
  190. -    if((currentkeys & G15_KEY_M3) && !(lastkeys & G15_KEY_M3))
  191. -        keydown(MKEY_OFFSET+2);
  192. -    else if(!(currentkeys & G15_KEY_M3) && (lastkeys & G15_KEY_M3))
  193. -        keyup(MKEY_OFFSET+2);
  194. -
  195. -    if((currentkeys & G15_KEY_MR) && !(lastkeys & G15_KEY_MR))
  196. -        keydown(MKEY_OFFSET+3);
  197. -    else if(!(currentkeys & G15_KEY_MR) && (lastkeys & G15_KEY_MR))
  198. -        keyup(MKEY_OFFSET+3);
  199. -    
  200. -    if(map_Lkeys){
  201. -        /* 'L' keys...  */
  202. -        if((currentkeys & G15_KEY_L1) && !(lastkeys & G15_KEY_L1))
  203. -            keydown(LKEY_OFFSET);
  204. -        else if(!(currentkeys & G15_KEY_L1) && (lastkeys & G15_KEY_L1))
  205. -            keyup(LKEY_OFFSET);
  206. -
  207. -        if((currentkeys & G15_KEY_L2) && !(lastkeys & G15_KEY_L2))
  208. -            keydown(LKEY_OFFSET+1);
  209. -        else if(!(currentkeys & G15_KEY_L2) && (lastkeys & G15_KEY_L2))
  210. -            keyup(LKEY_OFFSET+1);
  211. -
  212. -        if((currentkeys & G15_KEY_L3) && !(lastkeys & G15_KEY_L3))
  213. -            keydown(LKEY_OFFSET+2);
  214. -        else if(!(currentkeys & G15_KEY_L3) && (lastkeys & G15_KEY_L3))
  215. -            keyup(LKEY_OFFSET+2);
  216. -
  217. -        if((currentkeys & G15_KEY_L4) && !(lastkeys & G15_KEY_L4))
  218. -            keydown(LKEY_OFFSET+3);
  219. -        else if(!(currentkeys & G15_KEY_L4) && (lastkeys & G15_KEY_L4))
  220. -            keyup(LKEY_OFFSET+3);
  221. -
  222. -        if((currentkeys & G15_KEY_L5) && !(lastkeys & G15_KEY_L5))
  223. -            keydown(LKEY_OFFSET+4);
  224. -        else if(!(currentkeys & G15_KEY_L5) && (lastkeys & G15_KEY_L5))
  225. -            keyup(LKEY_OFFSET+4);
  226. +    if(!(currentkeys & G15_KEY_LIGHT))
  227. +    {
  228. +if((currentkeys & G15_KEY_G1) && !(lastkeys & G15_KEY_G1))
  229. +    {   snprintf(cmd, sizeof cmd,
  230. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G1 on %d", mkey_state);
  231. +        system(cmd);
  232. +    }
  233. +else if(!(currentkeys & G15_KEY_G1) && (lastkeys & G15_KEY_G1))
  234. +    {   snprintf(cmd, sizeof cmd,
  235. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G1 off %d", mkey_state);
  236. +        system(cmd);
  237. +    }
  238. +
  239. +if((currentkeys & G15_KEY_G2) && !(lastkeys & G15_KEY_G2))
  240. +    {   snprintf(cmd, sizeof cmd,
  241. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G2 on %d", mkey_state);
  242. +        system(cmd);
  243. +    }
  244. +else if(!(currentkeys & G15_KEY_G2) && (lastkeys & G15_KEY_G2))
  245. +    {   snprintf(cmd, sizeof cmd,
  246. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G2 off %d", mkey_state);
  247. +        system(cmd);
  248. +    }
  249. +    
  250. +if((currentkeys & G15_KEY_G3) && !(lastkeys & G15_KEY_G3))
  251. +    {   snprintf(cmd, sizeof cmd,
  252. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G3 on %d", mkey_state);
  253. +        system(cmd);
  254. +    }
  255. +else if(!(currentkeys & G15_KEY_G3) && (lastkeys & G15_KEY_G3))
  256. +    {   snprintf(cmd, sizeof cmd,
  257. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G3 off %d", mkey_state);
  258. +        system(cmd);
  259. +    }
  260. +    
  261. +if((currentkeys & G15_KEY_G4) && !(lastkeys & G15_KEY_G4))
  262. +    {   snprintf(cmd, sizeof cmd,
  263. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G4 on %d", mkey_state);
  264. +        system(cmd);
  265. +    }
  266. +else if(!(currentkeys & G15_KEY_G4) && (lastkeys & G15_KEY_G4))
  267. +    {   snprintf(cmd, sizeof cmd,
  268. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G4 off %d", mkey_state);
  269. +        system(cmd);
  270. +    }
  271. +    
  272. +if((currentkeys & G15_KEY_G5) && !(lastkeys & G15_KEY_G5))
  273. +    {   snprintf(cmd, sizeof cmd,
  274. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G5 on %d", mkey_state);
  275. +        system(cmd);
  276. +    }
  277. +else if(!(currentkeys & G15_KEY_G5) && (lastkeys & G15_KEY_G5))
  278. +    {   snprintf(cmd, sizeof cmd,
  279. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G5 off %d", mkey_state);
  280. +        system(cmd);
  281. +    }
  282. +    
  283. +if((currentkeys & G15_KEY_G6) && !(lastkeys & G15_KEY_G6))
  284. +    {   snprintf(cmd, sizeof cmd,
  285. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G6 on %d", mkey_state);
  286. +        system(cmd);
  287. +    }
  288. +else if(!(currentkeys & G15_KEY_G6) && (lastkeys & G15_KEY_G6))
  289. +    {   snprintf(cmd, sizeof cmd,
  290. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G6 off %d", mkey_state);
  291. +        system(cmd);
  292. +    }
  293. +    
  294. +if((currentkeys & G15_KEY_G7) && !(lastkeys & G15_KEY_G7))
  295. +    {   snprintf(cmd, sizeof cmd,
  296. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G7 on %d", mkey_state);
  297. +        system(cmd);
  298. +    }
  299. +else if(!(currentkeys & G15_KEY_G7) && (lastkeys & G15_KEY_G7))
  300. +    {   snprintf(cmd, sizeof cmd,
  301. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G7 off %d", mkey_state);
  302. +        system(cmd);
  303. +    }
  304. +    
  305. +if((currentkeys & G15_KEY_G8) && !(lastkeys & G15_KEY_G8))
  306. +    {   snprintf(cmd, sizeof cmd,
  307. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G8 on %d", mkey_state);
  308. +        system(cmd);
  309. +    }
  310. +else if(!(currentkeys & G15_KEY_G8) && (lastkeys & G15_KEY_G8))
  311. +    {   snprintf(cmd, sizeof cmd,
  312. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G8 off %d", mkey_state);
  313. +        system(cmd);
  314. +    }
  315. +    
  316. +if((currentkeys & G15_KEY_G9) && !(lastkeys & G15_KEY_G9))
  317. +    {   snprintf(cmd, sizeof cmd,
  318. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G9 on %d", mkey_state);
  319. +        system(cmd);
  320. +    }
  321. +else if(!(currentkeys & G15_KEY_G9) && (lastkeys & G15_KEY_G9))
  322. +    {   snprintf(cmd, sizeof cmd,
  323. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G9 off %d", mkey_state);
  324. +        system(cmd);
  325. +    }
  326. +    
  327. +if((currentkeys & G15_KEY_G10) && !(lastkeys & G15_KEY_G10))
  328. +    {   snprintf(cmd, sizeof cmd,
  329. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G10 on %d", mkey_state);
  330. +        system(cmd);
  331. +    }
  332. +else if(!(currentkeys & G15_KEY_G10) && (lastkeys & G15_KEY_G10))
  333. +    {   snprintf(cmd, sizeof cmd,
  334. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G10 off %d", mkey_state);
  335. +        system(cmd);
  336. +    }
  337. +    
  338. +if((currentkeys & G15_KEY_G11) && !(lastkeys & G15_KEY_G11))
  339. +    {   snprintf(cmd, sizeof cmd,
  340. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G11 on %d", mkey_state);
  341. +        system(cmd);
  342.      }
  343. +else if(!(currentkeys & G15_KEY_G11) && (lastkeys & G15_KEY_G11))
  344. +    {   snprintf(cmd, sizeof cmd,
  345. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G11 off %d", mkey_state);
  346. +        system(cmd);
  347. +    }
  348. +    
  349. +if((currentkeys & G15_KEY_G12) && !(lastkeys & G15_KEY_G12))
  350. +    {   snprintf(cmd, sizeof cmd,
  351. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G12 on %d", mkey_state);
  352. +        system(cmd);
  353. +    }
  354. +else if(!(currentkeys & G15_KEY_G12) && (lastkeys & G15_KEY_G12))
  355. +    {   snprintf(cmd, sizeof cmd,
  356. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G12 off %d", mkey_state);
  357. +        system(cmd);
  358. +    }
  359. +    
  360. +if((currentkeys & G15_KEY_G13) && !(lastkeys & G15_KEY_G13))
  361. +    {   snprintf(cmd, sizeof cmd,
  362. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G13 on %d", mkey_state);
  363. +        system(cmd);
  364. +    }
  365. +else if(!(currentkeys & G15_KEY_G13) && (lastkeys & G15_KEY_G13))
  366. +    {   snprintf(cmd, sizeof cmd,
  367. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G13 off %d", mkey_state);
  368. +        system(cmd);
  369. +    }
  370. +    
  371. +if((currentkeys & G15_KEY_G14) && !(lastkeys & G15_KEY_G14))
  372. +    {   snprintf(cmd, sizeof cmd,
  373. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G14 on %d", mkey_state);
  374. +        system(cmd);
  375. +    }
  376. +else if(!(currentkeys & G15_KEY_G14) && (lastkeys & G15_KEY_G14))
  377. +    {   snprintf(cmd, sizeof cmd,
  378. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G14 off %d", mkey_state);
  379. +        system(cmd);
  380. +    }
  381. +    
  382. +if((currentkeys & G15_KEY_G15) && !(lastkeys & G15_KEY_G15))
  383. +    {   snprintf(cmd, sizeof cmd,
  384. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G15 on %d", mkey_state);
  385. +        system(cmd);
  386. +    }
  387. +else if(!(currentkeys & G15_KEY_G15) && (lastkeys & G15_KEY_G15))
  388. +    {   snprintf(cmd, sizeof cmd,
  389. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G15 off %d", mkey_state);
  390. +        system(cmd);
  391. +    }
  392. +
  393. +if((currentkeys & G15_KEY_G16) && !(lastkeys & G15_KEY_G16))
  394. +    {   snprintf(cmd, sizeof cmd,
  395. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G16 on %d", mkey_state);
  396. +        system(cmd);
  397. +    }
  398. +else if(!(currentkeys & G15_KEY_G16) && (lastkeys & G15_KEY_G16))
  399. +    {   snprintf(cmd, sizeof cmd,
  400. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G16 off %d", mkey_state);
  401. +        system(cmd);
  402. +    }
  403. +
  404. +if((currentkeys & G15_KEY_G17) && !(lastkeys & G15_KEY_G17))
  405. +    {   snprintf(cmd, sizeof cmd,
  406. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G17 on %d", mkey_state);
  407. +        system(cmd);
  408. +    }
  409. +else if(!(currentkeys & G15_KEY_G17) && (lastkeys & G15_KEY_G17))
  410. +    {   snprintf(cmd, sizeof cmd,
  411. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G17 off %d", mkey_state);
  412. +        system(cmd);
  413. +    }
  414. +    
  415. +if((currentkeys & G15_KEY_G18) && !(lastkeys & G15_KEY_G18))
  416. +     {   snprintf(cmd, sizeof cmd,
  417. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G18 on %d", mkey_state);
  418. +        system(cmd);
  419. +    }
  420. +else if(!(currentkeys & G15_KEY_G18) && (lastkeys & G15_KEY_G18))
  421. +    {   snprintf(cmd, sizeof cmd,
  422. +        "sudo -H -u '#1000' /usr/share/g15daemon/macros/G18 off %d", mkey_state);
  423. +        system(cmd);
  424. +    }
  425. +    
  426. +        /* 'M' keys... */
  427. +    
  428. +        if((currentkeys & G15_KEY_M1) && !(lastkeys & G15_KEY_M1))
  429. +            //keydown(MKEY_OFFSET);
  430. +        mkey_state = 0;
  431. +        /*else if(!(currentkeys & G15_KEY_M1) && (lastkeys & G15_KEY_M1))
  432. +            keyup(MKEY_OFFSET);*/
  433. +    
  434. +        if((currentkeys & G15_KEY_M2) && !(lastkeys & G15_KEY_M2))
  435. +            //keydown(MKEY_OFFSET+1);
  436. +        mkey_state = 1;
  437. +        /*else if(!(currentkeys & G15_KEY_M2) && (lastkeys & G15_KEY_M2))
  438. +            keyup(MKEY_OFFSET+1);*/
  439. +    
  440. +        if((currentkeys & G15_KEY_M3) && !(lastkeys & G15_KEY_M3))
  441. +            //keydown(MKEY_OFFSET+2);
  442. +        mkey_state = 2;
  443. +        /*else if(!(currentkeys & G15_KEY_M3) && (lastkeys & G15_KEY_M3))
  444. +            keyup(MKEY_OFFSET+2);*/
  445. +    
  446. +    if((currentkeys & G15_KEY_MR) && !(lastkeys & G15_KEY_MR) && mr_state == 0){
  447. +        mr_state = 1;
  448. +        system("sudo -H -u '#1000' /usr/share/g15daemon/macros/MacroRecord on & disown");
  449. +    }
  450. +    else if(!(currentkeys & G15_KEY_MR) && (lastkeys & G15_KEY_MR) && mr_state == 1){
  451. +    /*Toggle function on first key release*/
  452. +    }
  453. +    else if((currentkeys & G15_KEY_MR) && !(lastkeys & G15_KEY_MR) && mr_state == 1){
  454. +        mr_state = 0;
  455. +        system("sudo -H -u '#1000' /usr/share/g15daemon/macros/MacroRecord off & disown");
  456. +    }
  457. +    else if(!(currentkeys & G15_KEY_MR) && (lastkeys & G15_KEY_MR) && mr_state == 0){
  458. +    /*Úntoggle function on second key release*/
  459. +    }
  460. +        
  461. +        if(map_Lkeys){
  462. +            /* 'L' keys...  */
  463. +            if((currentkeys & G15_KEY_L1) && !(lastkeys & G15_KEY_L1))
  464. +                keydown(LKEY_OFFSET);
  465. +            else if(!(currentkeys & G15_KEY_L1) && (lastkeys & G15_KEY_L1))
  466. +                keyup(LKEY_OFFSET);
  467. +    
  468. +            if((currentkeys & G15_KEY_L2) && !(lastkeys & G15_KEY_L2))
  469. +                keydown(LKEY_OFFSET+1);
  470. +            else if(!(currentkeys & G15_KEY_L2) && (lastkeys & G15_KEY_L2))
  471. +                keyup(LKEY_OFFSET+1);
  472. +    
  473. +            if((currentkeys & G15_KEY_L3) && !(lastkeys & G15_KEY_L3))
  474. +                keydown(LKEY_OFFSET+2);
  475. +            else if(!(currentkeys & G15_KEY_L3) && (lastkeys & G15_KEY_L3))
  476. +                keyup(LKEY_OFFSET+2);
  477. +    
  478. +            if((currentkeys & G15_KEY_L4) && !(lastkeys & G15_KEY_L4))
  479. +                keydown(LKEY_OFFSET+3);
  480. +            else if(!(currentkeys & G15_KEY_L4) && (lastkeys & G15_KEY_L4))
  481. +                keyup(LKEY_OFFSET+3);
  482. +    
  483. +            if((currentkeys & G15_KEY_L5) && !(lastkeys & G15_KEY_L5))
  484. +                keydown(LKEY_OFFSET+4);
  485. +            else if(!(currentkeys & G15_KEY_L5) && (lastkeys & G15_KEY_L5))
  486. +                keyup(LKEY_OFFSET+4);
  487. +        }
  488. +
  489. +    }
  490. +
  491. +
  492. +     else
  493. +     {
  494. +        // G15_KEY_LIGHT - Key modifier for Logitech G510 Media Keys implementation
  495. +
  496. +        // XF86AudioPlay
  497. +        if((currentkeys & G15_KEY_G1) && !(lastkeys & G15_KEY_G1))
  498. +            keydown(KEY_PLAYPAUSE);
  499. +        else if(!(currentkeys & G15_KEY_G1) && (lastkeys & G15_KEY_G1))
  500. +            keyup(KEY_PLAYPAUSE);
  501. +
  502. +        // XF86AudioStop
  503. +        if((currentkeys & G15_KEY_G2) && !(lastkeys & G15_KEY_G2))
  504. +            keydown(KEY_STOPCD);
  505. +        else if(!(currentkeys & G15_KEY_G2) && (lastkeys & G15_KEY_G2))
  506. +            keyup(KEY_STOPCD);
  507. +
  508. +        // XF86AudioPrev
  509. +        if((currentkeys & G15_KEY_G3) && !(lastkeys & G15_KEY_G3))
  510. +            keydown(KEY_PREVIOUSSONG);
  511. +        else if(!(currentkeys & G15_KEY_G3) && (lastkeys & G15_KEY_G3))
  512. +            keyup(KEY_PREVIOUSSONG);
  513. +
  514. +        // XF86AudioNext
  515. +        if((currentkeys & G15_KEY_G4) && !(lastkeys & G15_KEY_G4))
  516. +            keydown(KEY_NEXTSONG);
  517. +        else if(!(currentkeys & G15_KEY_G4) && (lastkeys & G15_KEY_G4))
  518. +            keyup(KEY_NEXTSONG);
  519. +
  520. +        // XF86AudioMute
  521. +        if((currentkeys & G15_KEY_G5) && !(lastkeys & G15_KEY_G5))
  522. +            keydown(KEY_MUTE);
  523. +        else if(!(currentkeys & G15_KEY_G5) && (lastkeys & G15_KEY_G5))
  524. +            keyup(KEY_MUTE);
  525. +
  526. +        // XF86AudioRaise/LowerVolume (this was a pain to figure out, i dropped it at one point while it was semi-functioning and fixed it later)
  527. +        if(((currentkeys & G15_KEY_G6) && !(lastkeys & G15_KEY_G6)) && (vol_state == 0 || vol_state == 1)){
  528. +        keydown(KEY_VOLUMEUP);
  529. +        vol_state = 1;
  530. +    }
  531. +        else if(((currentkeys & G15_KEY_G7) && !(lastkeys & G15_KEY_G7)) && (vol_state == 0 || vol_state == 2)){
  532. +        keydown(KEY_VOLUMEDOWN);
  533. +        vol_state = 2;
  534. +    }
  535. +    else if((!(currentkeys & G15_KEY_G6) || !(currentkeys & G15_KEY_G7)) && ((lastkeys & G15_KEY_G7) || (lastkeys & G15_KEY_G6))){
  536. +        keyup(KEY_VOLUMEUP);
  537. +            keyup(KEY_VOLUMEDOWN);
  538. +        vol_state = 0;  
  539. +        }
  540. +    }
  541. +/*Set led states per M key (Doing this in the switch was slow and didn't activate till after button release)*/
  542. +    if(mkey_state == 0)
  543. +    mled_state = G15_LED_M1;
  544. +    else if(mkey_state == 1)
  545. +    mled_state = G15_LED_M2;
  546. +    else if(mkey_state == 2)
  547. +    mled_state = G15_LED_M3;
  548. +
  549. +/*Set leds and toggle MR led depending on mr_state*/
  550. +    if(mr_state == 0)
  551. +    setLEDs(mled_state -0x20);
  552. +    else if(mr_state == 1)
  553. +    setLEDs(mled_state -0x20 | G15_LED_MR -0x20);
  554. +
  555.  }
  556.  
  557.  
  558.  
  559. --- a/contrib/xmodmaprc 2008-01-24 12:51:08.000000000 +0000
  560. +++ b/contrib/xmodmaprc 2013-04-11 15:25:26.000000000 +0000
  561. @@ -3,7 +3,7 @@
  562.  keycode 130 = XF86Launch9
  563.  keycode 131 = XF86Launch2
  564.  keycode 132 = XF86Phone
  565. -keycode 133 = XF86Messenger
  566. +keycode 133 = Super_L
  567.  keycode 136 = XF86LaunchD
  568.  keycode 137 = XF86Support
  569.  keycode 138 = XF86Word
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement