g13d: Reformat all the files to Google style

This is closer to what I'm looking for, and gives us a style guide to boot.
This commit is contained in:
June Tate-Gans 2021-04-25 20:30:56 -05:00
parent 234b5aac7f
commit 1918d6875c
26 changed files with 766 additions and 654 deletions

View File

@ -1,27 +1,27 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortFunctionsOnASingleLine: false
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
@ -53,12 +53,12 @@ BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
@ -66,18 +66,21 @@ ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
- Regex: '^<ext/.*\.h>'
Priority: 2
SortPriority: 0
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
- Regex: '.*'
- Regex: '^<.*\.h>'
Priority: 1
SortPriority: 0
IncludeIsMainRegex: '(Test)?$'
- Regex: '^<.*'
Priority: 2
SortPriority: 0
- Regex: '.*'
Priority: 3
SortPriority: 0
IncludeIsMainRegex: '([-_](test|unittest))?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: true
IndentGotoLabels: true
@ -86,24 +89,52 @@ IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ''
BasedOnStyle: google
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
@ -118,7 +149,7 @@ SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
@ -126,7 +157,7 @@ SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Latest
Standard: Auto
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION

View File

@ -1,16 +1,18 @@
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/foreach.hpp>
#include "action.h"
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include "manager.h"
#include "repr.h"
namespace G13 {
G13_Action::~G13_Action() {}
G13_Action::~G13_Action() {
}
G13_Action_Keys::G13_Action_Keys(G13_Device &keypad,
const std::string &keys_string)
@ -29,7 +31,8 @@ G13_Action_Keys::G13_Action_Keys(G13_Device &keypad,
std::vector<int> _keys;
}
G13_Action_Keys::~G13_Action_Keys() {}
G13_Action_Keys::~G13_Action_Keys() {
}
void G13_Action_Keys::act(G13_Device &g13, bool is_down) {
for (auto key : _keys) {
@ -42,16 +45,18 @@ void G13_Action_Keys::dump(std::ostream &out) const {
out << " SEND KEYS: ";
for (size_t i = 0; i < _keys.size(); i++) {
if (i)
out << " + ";
if (i) out << " + ";
out << manager().find_input_key_name(_keys[i]);
}
}
G13_Action_PipeOut::G13_Action_PipeOut(G13_Device &keypad,
const std::string &out)
: G13_Action(keypad), _out(out + "\n") {}
G13_Action_PipeOut::~G13_Action_PipeOut() {}
: G13_Action(keypad),
_out(out + "\n") {
}
G13_Action_PipeOut::~G13_Action_PipeOut() {
}
void G13_Action_PipeOut::act(G13_Device &kp, bool is_down) {
if (is_down) {
@ -65,8 +70,11 @@ void G13_Action_PipeOut::dump(std::ostream &o) const {
G13_Action_Command::G13_Action_Command(G13_Device &keypad,
const std::string &cmd)
: G13_Action(keypad), _cmd(cmd) {}
G13_Action_Command::~G13_Action_Command() {}
: G13_Action(keypad),
_cmd(cmd) {
}
G13_Action_Command::~G13_Action_Command() {
}
void G13_Action_Command::act(G13_Device &kp, bool is_down) {
if (is_down) {
@ -78,4 +86,4 @@ void G13_Action_Command::dump(std::ostream &o) const {
o << "COMMAND : " << repr(_cmd);
}
}
} // namespace G13

View File

@ -1,9 +1,9 @@
#ifndef ACTION_H
#define ACTION_H
#include <memory>
#include <ostream>
#include <vector>
#include <memory>
#include "g13.h"
@ -17,16 +17,24 @@ class G13_Manager;
*/
class G13_Action {
public:
G13_Action(G13_Device &keypad) : _keypad(keypad) {}
G13_Action(G13_Device &keypad) : _keypad(keypad) {
}
virtual ~G13_Action();
virtual void act(G13_Device &, bool is_down) = 0;
virtual void dump(std::ostream &) const = 0;
void act(bool is_down) { act(keypad(), is_down); }
void act(bool is_down) {
act(keypad(), is_down);
}
G13_Device &keypad() { return _keypad; }
const G13_Device &keypad() const { return _keypad; }
G13_Device &keypad() {
return _keypad;
}
const G13_Device &keypad() const {
return _keypad;
}
G13_Manager &manager();
const G13_Manager &manager() const;
@ -79,24 +87,40 @@ public:
typedef std::shared_ptr<G13_Action> G13_ActionPtr;
template <class PARENT_T> class G13_Actionable {
template <class PARENT_T>
class G13_Actionable {
public:
G13_Actionable(PARENT_T &parent_arg, const std::string &name)
: _name(name), _parent_ptr(&parent_arg) {
: _name(name),
_parent_ptr(&parent_arg) {
}
virtual ~G13_Actionable() {
_parent_ptr = 0;
}
G13_ActionPtr action() const { return _action; }
const std::string &name() const { return _name; }
PARENT_T &parent() { return *_parent_ptr; }
const PARENT_T &parent() const { return *_parent_ptr; }
G13_Manager &manager() { return _parent_ptr->manager(); }
const G13_Manager &manager() const { return _parent_ptr->manager(); }
G13_ActionPtr action() const {
return _action;
}
const std::string &name() const {
return _name;
}
PARENT_T &parent() {
return *_parent_ptr;
}
const PARENT_T &parent() const {
return *_parent_ptr;
}
G13_Manager &manager() {
return _parent_ptr->manager();
}
const G13_Manager &manager() const {
return _parent_ptr->manager();
}
virtual void set_action(const G13_ActionPtr &action) { _action = action; }
virtual void set_action(const G13_ActionPtr &action) {
_action = action;
}
protected:
std::string _name;

View File

@ -7,10 +7,10 @@
namespace G13 {
template <class T> class Bounds {
template <class T>
class Bounds {
public:
Bounds(const Coord<T> &_tl, const Coord<T> &_br)
: tl(_tl), br(_br) {
Bounds(const Coord<T> &_tl, const Coord<T> &_br) : tl(_tl), br(_br) {
}
Bounds(T x1, T y1, T x2, T y2) : tl(x1, y1), br(x2, y2) {
@ -21,14 +21,10 @@ public:
}
void expand(const Coord<T> &pos) {
if (pos.x < tl.x)
tl.x = pos.x;
if (pos.y < tl.y)
tl.y = pos.y;
if (pos.x > br.x)
br.x = pos.x;
if (pos.y > br.y)
br.y = pos.y;
if (pos.x < tl.x) tl.x = pos.x;
if (pos.y < tl.y) tl.y = pos.y;
if (pos.x > br.x) br.x = pos.x;
if (pos.y > br.y) br.y = pos.y;
}
Coord<T> tl;
@ -37,10 +33,7 @@ public:
template <class T>
std::ostream &operator<<(std::ostream &o, const Bounds<T> &b) {
o << "{ "
<< b.tl.x << " x " << b.tl.y
<< " / "
<< b.br.x << " x " << b.br.y
o << "{ " << b.tl.x << " x " << b.tl.y << " / " << b.br.x << " x " << b.br.y
<< " }";
return o;

View File

@ -3,14 +3,13 @@
namespace G13 {
template <class T> class Coord {
template <class T>
class Coord {
public:
Coord()
: x(), y() {
Coord() : x(), y() {
}
Coord(T _x, T _y)
: x(_x), y(_y) {
Coord(T _x, T _y) : x(_x), y(_y) {
}
T x;

View File

@ -1,30 +1,28 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <signal.h>
#include "device.h"
#include <fcntl.h>
#include <libusb-1.0/libusb.h>
#include <linux/uinput.h>
#include <signal.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/foreach.hpp>
#include <iostream>
#include <boost/lexical_cast.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <fstream>
#include <iostream>
#include <string>
#include "logo.h"
#include "manager.h"
#include "repr.h"
#include "device.h"
namespace G13 {
static std::string describe_libusb_error_code(int code) {
#define TEST_libusb_error(r, data, elem) \
case BOOST_PP_CAT(LIBUSB_, elem): \
return BOOST_PP_STRINGIZE(elem);
@ -194,7 +192,6 @@ void G13_Device::cleanup() {
libusb_close(handle);
}
/*! reads and processes key state report from G13
*
*/
@ -206,7 +203,6 @@ int G13_Device::read_keys() {
buffer, G13_REPORT_SIZE, &size, 100);
if (error && error != LIBUSB_ERROR_TIMEOUT) {
G13_LOG(error, "Error while reading keys: "
<< error << " (" << describe_libusb_error_code(error)
<< ")");
@ -226,7 +222,6 @@ void G13_Device::read_config_file(const std::string &filename) {
G13_LOG(info, "reading configuration from " << filename);
while (s.good()) {
// grab a line
char buf[1024];
buf[0] = 0;
@ -288,8 +283,13 @@ void G13_Device::read_commands() {
G13_Device::G13_Device(G13_Manager &manager, libusb_device_handle *handle,
int _id)
: _id_within_manager(_id), handle(handle), ctx(0), _uinput_fid(-1),
_manager(manager), _lcd(*this), _stick(*this) {
: _id_within_manager(_id),
handle(handle),
ctx(0),
_uinput_fid(-1),
_manager(manager),
_lcd(*this),
_stick(*this) {
_current_profile = ProfilePtr(new G13_Profile(*this, "default"));
_profiles["default"] = _current_profile;
@ -324,7 +324,6 @@ ProfilePtr G13_Device::profile(const std::string &name) {
return rv;
}
G13_ActionPtr G13_Device::make_action(const std::string &action) {
if (!action.size()) {
throw G13_CommandException("empty action string");
@ -377,7 +376,9 @@ inline const char *advance_ws(const char* &source, std::string &dest) {
struct command_adder {
command_adder(G13_Device::CommandFunctionTable &t, const char *name)
: _t(t), _name(name) {}
: _t(t),
_name(name) {
}
G13_Device::CommandFunctionTable &_t;
std::string _name;
@ -432,10 +433,18 @@ void G13_Device::_init_commands() {
}
}
G13_DEVICE_COMMAND(profile) { switch_to_profile(remainder); }
G13_DEVICE_COMMAND(font) { switch_to_font(remainder); }
G13_DEVICE_COMMAND(mod) { set_mode_leds(atoi(remainder)); }
G13_DEVICE_COMMAND(textmode) { lcd().text_mode = atoi(remainder); }
G13_DEVICE_COMMAND(profile) {
switch_to_profile(remainder);
}
G13_DEVICE_COMMAND(font) {
switch_to_font(remainder);
}
G13_DEVICE_COMMAND(mod) {
set_mode_leds(atoi(remainder));
}
G13_DEVICE_COMMAND(textmode) {
lcd().text_mode = atoi(remainder);
}
G13_DEVICE_COMMAND(rgb) {
int red, green, blue;
@ -543,7 +552,6 @@ void G13_Device::command(char const *str) {
}
}
void G13_Device::init_lcd() {
int error = libusb_control_transfer(handle, 0, 9, 1, 0, 0, 0, 1000);
if (error) {

View File

@ -1,17 +1,17 @@
#ifndef DEVICE_H
#define DEVICE_H
#include <linux/input.h>
#include <libusb-1.0/libusb.h>
#include <linux/input.h>
#include <map>
#include <ostream>
#include <string>
#include <map>
#include "lcd.h"
#include "stick.h"
#include "font.h"
#include "lcd.h"
#include "profile.h"
#include "stick.h"
namespace G13 {
@ -21,13 +21,25 @@ class G13_Device {
public:
G13_Device(G13_Manager &manager, libusb_device_handle *handle, int id);
G13_Manager &manager() { return _manager; }
const G13_Manager &manager() const { return _manager; }
G13_Manager &manager() {
return _manager;
}
const G13_Manager &manager() const {
return _manager;
}
G13_LCD &lcd() { return _lcd; }
const G13_LCD &lcd() const { return _lcd; }
G13_Stick &stick() { return _stick; }
const G13_Stick &stick() const { return _stick; }
G13_LCD &lcd() {
return _lcd;
}
const G13_LCD &lcd() const {
return _lcd;
}
G13_Stick &stick() {
return _stick;
}
const G13_Stick &stick() const {
return _stick;
}
FontPtr switch_to_font(const std::string &name);
void switch_to_profile(const std::string &name);
@ -60,10 +72,16 @@ public:
void register_context(libusb_context *ctx);
void write_lcd_file(const std::string &filename);
G13_Font &current_font() { return *_current_font; }
G13_Profile &current_profile() { return *_current_profile; }
G13_Font &current_font() {
return *_current_font;
}
G13_Profile &current_profile() {
return *_current_profile;
}
int id_within_manager() const { return _id_within_manager; }
int id_within_manager() const {
return _id_within_manager;
}
typedef std::function<void(const char *)> COMMAND_FUNCTION;
typedef std::map<std::string, COMMAND_FUNCTION> CommandFunctionTable;

View File

@ -1,16 +1,20 @@
#include "device.h"
#include "font.h"
#include "device.h"
using namespace std;
namespace G13 {
#include "font8x8.h"
G13_Font::G13_Font() : _name("default"), _width(8) {}
G13_Font::G13_Font() : _name("default"), _width(8) {
}
G13_Font::G13_Font(const std::string &name, unsigned int width)
: _name(name), _width(width) {}
: _name(name),
_width(width) {
}
void G13_FontChar::set_character(unsigned char *data, int width,
unsigned flags) {
@ -35,7 +39,8 @@ void G13_FontChar::set_character(unsigned char *data, int width,
}
}
template <typename T, int size> int GetFontCharacterCount(T (&)[size]) {
template <typename T, int size>
int GetFontCharacterCount(T (&)[size]) {
return size;
}

View File

@ -1,10 +1,10 @@
#ifndef FONT_H
#define FONT_H
#include <memory>
#include <memory.h>
#include <memory>
namespace G13 {
class G13_FontChar {
@ -32,10 +32,16 @@ public:
template <class ARRAY_T, class FLAGST>
void install_font(ARRAY_T &data, FLAGST flags, int first = 0);
const std::string &name() const { return _name; }
unsigned int width() const { return _width; }
const std::string &name() const {
return _name;
}
unsigned int width() const {
return _width;
}
const G13_FontChar &char_data(unsigned int x) { return _chars[x]; }
const G13_FontChar &char_data(unsigned int x) {
return _chars[x];
}
protected:
std::string _name;

View File

@ -2,7 +2,6 @@
#define G13_H
#include <boost/log/trivial.hpp>
#include <string>
namespace G13 {
@ -43,9 +42,13 @@ typedef int G13_KEY_INDEX;
class G13_CommandException : public std::exception {
public:
G13_CommandException(const std::string &reason) : _reason(reason) {}
virtual ~G13_CommandException() throw() {}
virtual const char *what() const throw() { return _reason.c_str(); }
G13_CommandException(const std::string &reason) : _reason(reason) {
}
virtual ~G13_CommandException() throw() {
}
virtual const char *what() const throw() {
return _reason.c_str();
}
std::string _reason;
};

View File

@ -37,12 +37,9 @@
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/seq.hpp>
#include <boost/shared_ptr.hpp>
#include <exception>
#include <iomanip>
#include <iostream>
#include <exception>
#include <map>
#include <string>
#include <vector>
@ -53,9 +50,9 @@ namespace Helper {
// *************************************************************************
template <class MAP_T> struct _map_keys_out {
_map_keys_out(const MAP_T &c, const std::string &s)
: container(c), sep(s) {
template <class MAP_T>
struct _map_keys_out {
_map_keys_out(const MAP_T &c, const std::string &s) : container(c), sep(s) {
}
const MAP_T &container;

View File

@ -18,10 +18,11 @@
A0.01 A1.01 A2.01 ...
*/
#include <iostream>
#include <fstream>
#include "lcd.h"
#include <fstream>
#include <iostream>
#include "device.h"
namespace G13 {
@ -51,7 +52,6 @@ void G13_LCD::image_setpixel(unsigned row, unsigned col) {
}
void G13_LCD::image_clearpixel(unsigned row, unsigned col) {
unsigned offset =
image_byte_offset(row, col); // col + (row /8 ) * BYTES_PER_ROW * 8;
unsigned char mask = 1 << ((row)&7);

View File

@ -1,10 +1,10 @@
#ifndef LCD_H
#define LCD_H
#include "g13.h"
#include <memory.h>
#include "g13.h"
namespace G13 {
class G13_Device;
@ -20,10 +20,14 @@ public:
int text_mode;
void image(unsigned char *data, int size);
void image_send() { image(image_buf, G13_LCD_BUF_SIZE); }
void image_send() {
image(image_buf, G13_LCD_BUF_SIZE);
}
void image_test(int x, int y);
void image_clear() { memset(image_buf, 0, G13_LCD_BUF_SIZE); }
void image_clear() {
memset(image_buf, 0, G13_LCD_BUF_SIZE);
}
unsigned image_byte_offset(unsigned row, unsigned col) {
return col + (row / 8) * G13_LCD_BYTES_PER_ROW * 8;

View File

@ -1,7 +1,6 @@
#include <iostream>
#include <boost/program_options.hpp>
#include <boost/foreach.hpp>
#include <boost/program_options.hpp>
#include <iostream>
#include "g13.h"
#include "manager.h"
@ -64,5 +63,4 @@ int main(int argc, char *argv[]) {
return 0;
}
}

View File

@ -1,5 +1,8 @@
#include "manager.h"
#include <signal.h>
#include <boost/foreach.hpp>
#include <boost/log/attributes.hpp>
#include <boost/log/core/core.hpp>
#include <boost/log/expressions.hpp>
@ -12,15 +15,12 @@
#include <boost/log/utility/setup/console.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/preprocessor/stringize.hpp>
#include <boost/foreach.hpp>
#include <fstream>
#include <vector>
#include "helper.h"
#include "device.h"
#include "manager.h"
#include "find_or_throw.h"
#include "helper.h"
#include "repr.h"
namespace G13 {
@ -61,7 +61,6 @@ void G13_Manager::set_log_level(::boost::log::trivial::severity_level lvl) {
}
void G13_Manager::set_log_level(const std::string &level) {
#define CHECK_LEVEL(L) \
if (level == BOOST_PP_STRINGIZE(L)) { \
set_log_level(::boost::log::trivial::L); \
@ -89,13 +88,13 @@ void G13_Manager::cleanup() {
libusb_exit(ctx);
}
G13_Manager::G13_Manager()
: devs(0), ctx(0) {
G13_Manager::G13_Manager() : devs(0), ctx(0) {
}
bool G13_Manager::running = true;
void G13_Manager::set_stop(int) { running = false; }
void G13_Manager::set_stop(int) {
running = false;
}
std::string G13_Manager::string_config_value(const std::string &name) const {
try {
@ -241,7 +240,6 @@ G13_Manager::find_g13_key_value(const std::string &keyname) const {
LINUX_KEY_VALUE
G13_Manager::find_input_key_value(const std::string &keyname) const {
// if there is a KEY_ prefix, strip it off
if (!strncmp(keyname.c_str(), "KEY_", 4)) {
return find_input_key_value(keyname.c_str() + 4);

View File

@ -1,9 +1,9 @@
#ifndef MANAGER_H
#define MANAGER_H
#include <map>
#include <string>
#include <vector>
#include <map>
#include "action.h"
#include "device.h"
@ -23,7 +23,9 @@ public:
LINUX_KEY_VALUE find_input_key_value(const std::string &keyname) const;
std::string find_input_key_name(LINUX_KEY_VALUE) const;
void set_logo(const std::string &fn) { logo_filename = fn; }
void set_logo(const std::string &fn) {
logo_filename = fn;
}
int run();
std::string string_config_value(const std::string &name) const;

View File

@ -1,6 +1,7 @@
#include <string.h>
#include <cstdio>
#include <iostream>
#include <string.h>
#include <string>
using namespace std;
// convert a .pbm raw file to our custom .lpbm format
@ -32,10 +33,8 @@ int main(int argc, char *argv[]) {
unsigned char buf[160 * 48];
memset(buf, 0, 160 * 43);
while (cin >> c) {
if (i % 20 == 0)
row++;
if (row == 8)
row = 0;
if (i % 20 == 0) row++;
if (row == 8) row = 0;
buf[7 + (i % 20) * 8 + i / 160 * 160] |= ((c >> 0) & 0x01) << row;
buf[6 + (i % 20) * 8 + i / 160 * 160] |= ((c >> 1) & 0x01) << row;
buf[5 + (i % 20) * 8 + i / 160 * 160] |= ((c >> 2) & 0x01) << row;

View File

@ -2,14 +2,15 @@
*
*/
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/foreach.hpp>
#include "profile.h"
#include "manager.h"
#include "repr.h"
#include <boost/foreach.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include "find_or_throw.h"
#include "helper.h"
#include "manager.h"
#include "repr.h"
namespace G13 {
// *************************************************************************

View File

@ -52,13 +52,16 @@ class G13_Profile;
class G13_Key : public G13_Actionable<G13_Profile> {
public:
void dump(std::ostream &o) const;
G13_KEY_INDEX index() const { return _index.index; }
G13_KEY_INDEX index() const {
return _index.index;
}
void parse_key(unsigned char *byte, G13_Device *g13);
protected:
struct KeyIndex {
KeyIndex(int key) : index(key), offset(key / 8), mask(1 << (key % 8)) {}
KeyIndex(int key) : index(key), offset(key / 8), mask(1 << (key % 8)) {
}
int index;
unsigned char offset;
@ -69,12 +72,14 @@ protected:
friend class G13_Profile;
G13_Key(G13_Profile &mode, const std::string &name, int index)
: G13_Actionable<G13_Profile>(mode, name), _index(index),
: G13_Actionable<G13_Profile>(mode, name),
_index(index),
_should_parse(true) {
}
G13_Key(G13_Profile &mode, const G13_Key &key)
: G13_Actionable<G13_Profile>(mode, key.name()), _index(key._index),
: G13_Actionable<G13_Profile>(mode, key.name()),
_index(key._index),
_should_parse(key._should_parse) {
set_action(key.action());
}
@ -92,12 +97,15 @@ protected:
class G13_Profile {
public:
G13_Profile(G13_Device &keypad, const std::string &name_arg)
: _keypad(keypad), _name(name_arg) {
: _keypad(keypad),
_name(name_arg) {
_init_keys();
}
G13_Profile(const G13_Profile &other, const std::string &name_arg)
: _keypad(other._keypad), _name(name_arg), _keys(other._keys) {
: _keypad(other._keypad),
_name(name_arg),
_keys(other._keys) {
}
// search key by G13 keyname
@ -106,7 +114,9 @@ public:
void dump(std::ostream &o) const;
void parse_keys(unsigned char *buf);
const std::string &name() const { return _name; }
const std::string &name() const {
return _name;
}
const G13_Manager &manager() const;

View File

@ -1,7 +1,7 @@
#include <ostream>
#include "repr.h"
#include <ostream>
namespace G13 {
void string_repr_out::write_on(std::ostream &o) const {

View File

@ -1,13 +1,14 @@
#ifndef REPR_H
#define REPR_H
#include <string>
#include <ostream>
#include <string>
namespace G13 {
struct string_repr_out {
string_repr_out(const std::string &str) : s(str) {}
string_repr_out(const std::string &str) : s(str) {
}
void write_on(std::ostream &) const;
std::string s;
@ -18,7 +19,8 @@ inline std::ostream &operator<<(std::ostream &o, const string_repr_out &sro) {
return o;
}
template <class T> inline const T &repr(const T &v) {
template <class T>
inline const T &repr(const T &v) {
return v;
}
@ -30,6 +32,6 @@ inline string_repr_out repr(const std::string &s) {
return string_repr_out(s);
}
}
} // namespace G13
#endif // REPR_H

View File

@ -2,17 +2,18 @@
*
*/
#include <boost/foreach.hpp>
#include <iomanip>
#include <iostream>
#include <boost/foreach.hpp>
#include "device.h"
namespace G13 {
G13_Stick::G13_Stick(G13_Device &keypad)
: _keypad(keypad), _bounds(0, 0, 255, 255), _center_pos(127, 127),
: _keypad(keypad),
_bounds(0, 0, 255, 255),
_center_pos(127, 127),
_north_pos(127, 0) {
_stick_mode = STICK_KEYS;
@ -52,8 +53,7 @@ void G13_Stick::set_mode(stick_mode_t m) {
return;
}
if (_stick_mode == STICK_CALCENTER ||
_stick_mode == STICK_CALBOUNDS ||
if (_stick_mode == STICK_CALCENTER || _stick_mode == STICK_CALBOUNDS ||
_stick_mode == STICK_CALNORTH) {
_recalc_calibrated();
}
@ -106,7 +106,9 @@ void G13_StickZone::test(const G13_ZoneCoord &loc) {
G13_StickZone::G13_StickZone(G13_Stick &stick, const std::string &name,
const G13_ZoneBounds &b, G13_ActionPtr action)
: G13_Actionable<G13_Stick>(stick, name), _active(false), _bounds(b) {
: G13_Actionable<G13_Stick>(stick, name),
_active(false),
_bounds(b) {
set_action(action);
}

View File

@ -1,9 +1,9 @@
#ifndef STICK_H
#define STICK_H
#include "coord.h"
#include "bounds.h"
#include "action.h"
#include "bounds.h"
#include "coord.h"
namespace G13 {
@ -27,7 +27,9 @@ public:
void parse_key(unsigned char *byte, G13_Device *g13);
void test(const G13_ZoneCoord &loc);
void set_bounds(const G13_ZoneBounds &bounds) { _bounds = bounds; }
void set_bounds(const G13_ZoneBounds &bounds) {
_bounds = bounds;
}
protected:
bool _active;
@ -46,7 +48,9 @@ public:
G13_StickZone *zone(const std::string &, bool create = false);
void remove_zone(const G13_StickZone &zone);
const std::vector<G13_StickZone> &zones() const { return _zones; }
const std::vector<G13_StickZone> &zones() const {
return _zones;
}
void dump(std::ostream &) const;