Adding support for relative movement mouse keys
- Includes kll.py cleanup - Fixed negative number generation and parsing
This commit is contained in:
parent
55ffc6bdc5
commit
d3e0c3d7a7
36
kll.py
36
kll.py
@ -1,8 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
# KLL Compiler
|
||||
# Keyboard Layout Langauge
|
||||
#
|
||||
# Copyright (C) 2014-2015 by Jacob Alexander
|
||||
'''
|
||||
KLL Compiler
|
||||
Keyboard Layout Langauge
|
||||
'''
|
||||
|
||||
# Copyright (C) 2014-2016 by Jacob Alexander
|
||||
#
|
||||
# This file is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -21,21 +23,16 @@
|
||||
|
||||
import argparse
|
||||
import importlib
|
||||
import io
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import token
|
||||
|
||||
from pprint import pformat
|
||||
from re import VERBOSE
|
||||
from tokenize import generate_tokens
|
||||
|
||||
from kll_lib.containers import *
|
||||
from kll_lib.hid_dict import *
|
||||
|
||||
from funcparserlib.lexer import make_tokenizer, Token, LexerError
|
||||
from funcparserlib.parser import (some, a, many, oneplus, skip, finished, maybe, skip, forward_decl, NoParseError)
|
||||
from funcparserlib.parser import (some, a, many, oneplus, finished, maybe, skip, NoParseError)
|
||||
|
||||
|
||||
|
||||
@ -150,12 +147,12 @@ def tokenize( string ):
|
||||
( 'String', ( r'"[^"]*"', ) ),
|
||||
( 'SequenceString', ( r"'[^']*'", ) ),
|
||||
( 'Operator', ( r'=>|:\+|:-|::|:|=', ) ),
|
||||
( 'Number', ( r'(-[ \t]*)?((0x[0-9a-fA-F]+)|(0|([1-9][0-9]*)))', VERBOSE ) ),
|
||||
( 'Comma', ( r',', ) ),
|
||||
( 'Dash', ( r'-', ) ),
|
||||
( 'Plus', ( r'\+', ) ),
|
||||
( 'Parenthesis', ( r'\(|\)', ) ),
|
||||
( 'None', ( r'None', ) ),
|
||||
( 'Number', ( r'-?(0x[0-9a-fA-F]+)|(0|([1-9][0-9]*))', VERBOSE ) ),
|
||||
( 'Name', ( r'[A-Za-z_][A-Za-z_0-9]*', ) ),
|
||||
( 'VariableContents', ( r'''[^"' ;:=>()]+''', ) ),
|
||||
( 'EndOfLine', ( r';', ) ),
|
||||
@ -398,14 +395,27 @@ def oneLayerFlatten( items ):
|
||||
|
||||
return mainList
|
||||
|
||||
# Capability arguments may need to be expanded (e.g. 1 16 bit argument needs to be 2 8 bit arguments for the state machine)
|
||||
def capArgExpander( items ):
|
||||
'''
|
||||
Capability arguments may need to be expanded
|
||||
(e.g. 1 16 bit argument needs to be 2 8 bit arguments for the state machine)
|
||||
|
||||
If the number is negative, determine width of the final value, mask to max, subtract,
|
||||
then convert to multiple bytes
|
||||
'''
|
||||
newArgs = []
|
||||
# For each defined argument in the capability definition
|
||||
for arg in range( 0, len( capabilities_dict[ items[0] ][1] ) ):
|
||||
argLen = capabilities_dict[ items[0] ][1][ arg ][1]
|
||||
num = items[1][ arg ]
|
||||
byteForm = num.to_bytes( argLen, byteorder='little' ) # XXX Yes, little endian from how the uC structs work
|
||||
|
||||
# Set last bit if value is negative
|
||||
if num < 0:
|
||||
max_val = 2 ** (argLen * 8)
|
||||
num += max_val
|
||||
|
||||
# XXX Yes, little endian from how the uC structs work
|
||||
byteForm = num.to_bytes( argLen, byteorder='little' )
|
||||
|
||||
# For each sub-argument, split into byte-sized chunks
|
||||
for byte in range( 0, argLen ):
|
||||
|
@ -1,17 +1,32 @@
|
||||
Name = mouseTest;
|
||||
Version = 0.3d;
|
||||
Version = 0.2;
|
||||
Author = "HaaTa (Jacob Alexander) 2016";
|
||||
KLL = 0.3d;
|
||||
|
||||
# Modified Date
|
||||
Date = 2016-03-20;
|
||||
Date = 2016-03-21;
|
||||
|
||||
U"1" : mouseOut( 1 );
|
||||
U"2" : mouseOut( 2 );
|
||||
U"3" : mouseOut( 3 );
|
||||
U"4" : mouseOut( 4 );
|
||||
U"5" : mouseOut( 5 );
|
||||
U"6" : mouseOut( 6 );
|
||||
U"7" : mouseOut( 7 );
|
||||
U"8" : mouseOut( 8 );
|
||||
# mouseOut
|
||||
# Arg1, button, 1-8
|
||||
# Arg2, mouse x relative axis -127 to 127
|
||||
# Arg3, mouse y relative axis -127 to 127
|
||||
|
||||
U"1" : mouseOut( 1, 0, 0 );
|
||||
U"2" : mouseOut( 2, 0, 0 );
|
||||
U"3" : mouseOut( 3, 0, 0 );
|
||||
U"4" : mouseOut( 4, 0, 0 );
|
||||
U"5" : mouseOut( 5, 0, 0 );
|
||||
U"6" : mouseOut( 6, 0, 0 );
|
||||
U"7" : mouseOut( 7, 0, 0 );
|
||||
U"8" : mouseOut( 8, 0, 0 );
|
||||
|
||||
U"Up" : mouseOut( 0, 0, 1 );
|
||||
U"Down" : mouseOut( 0, 0, -1 );
|
||||
U"Left" : mouseOut( 0, -1, 0 );
|
||||
U"Right" : mouseOut( 0, 1, 0 );
|
||||
|
||||
U"W" : mouseOut( 0, 0, 5 );
|
||||
U"S" : mouseOut( 0, 0, -5 );
|
||||
U"A" : mouseOut( 0, -5, 0 );
|
||||
U"D" : mouseOut( 0, 5, 0 );
|
||||
|
||||
|
Reference in New Issue
Block a user