mirror of
https://github.com/jtgans/g13gui.git
synced 2025-06-20 08:23:50 -04:00
g13d: Reformat all the files using clang-format
This should help with maintainability.
This commit is contained in:
parent
c32950bfcb
commit
c7992d52b5
137
.clang-format
Normal file
137
.clang-format
Normal file
@ -0,0 +1,137 @@
|
||||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -2
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveMacros: false
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: MultiLine
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 80
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentCaseLabels: false
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: false
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Right
|
||||
ReflowComments: true
|
||||
SortIncludes: true
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
Standard: Latest
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 8
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
...
|
||||
|
191
g13d/g13.cc
191
g13d/g13.cc
@ -3,16 +3,16 @@
|
||||
#include <fstream>
|
||||
|
||||
#if 0
|
||||
#include <boost/log/attributes.hpp>
|
||||
#include <boost/log/core/core.hpp>
|
||||
#include <boost/log/expressions.hpp>
|
||||
#include <boost/log/expressions/formatters/stream.hpp>
|
||||
#include <boost/log/sources/severity_feature.hpp>
|
||||
#include <boost/log/sources/severity_logger.hpp>
|
||||
#include <boost/log/core/core.hpp>
|
||||
#include <boost/log/attributes.hpp>
|
||||
#include <boost/log/support/date_time.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/log/expressions.hpp>
|
||||
#include <boost/log/utility/setup.hpp>
|
||||
#include <boost/log/utility/setup/console.hpp>
|
||||
#include <boost/log/expressions/formatters/stream.hpp>
|
||||
#include <boost/log/support/date_time.hpp>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
@ -43,9 +43,9 @@ void G13_Device::set_mode_leds(int leds) {
|
||||
|
||||
unsigned char usb_data[] = {5, 0, 0, 0, 0};
|
||||
usb_data[1] = leds;
|
||||
int r = libusb_control_transfer(handle,
|
||||
LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, 9, 0x305, 0,
|
||||
usb_data, 5, 1000);
|
||||
int r = libusb_control_transfer(
|
||||
handle, LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, 9, 0x305,
|
||||
0, usb_data, 5, 1000);
|
||||
if (r != 5) {
|
||||
G13_LOG(error, "Problem sending data");
|
||||
return;
|
||||
@ -58,9 +58,9 @@ void G13_Device::set_key_color(int red, int green, int blue) {
|
||||
usb_data[2] = green;
|
||||
usb_data[3] = blue;
|
||||
|
||||
error = libusb_control_transfer(handle,
|
||||
LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, 9, 0x307, 0,
|
||||
usb_data, 5, 1000);
|
||||
error = libusb_control_transfer(
|
||||
handle, LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, 9, 0x307,
|
||||
0, usb_data, 5, 1000);
|
||||
if (error != 5) {
|
||||
G13_LOG(error, "Problem sending data");
|
||||
return;
|
||||
@ -116,8 +116,9 @@ int g13_create_uinput(G13_Device *g13) {
|
||||
struct uinput_user_dev uinp;
|
||||
struct input_event event;
|
||||
const char *dev_uinput_fname =
|
||||
access("/dev/input/uinput", F_OK) == 0 ? "/dev/input/uinput" :
|
||||
access("/dev/uinput", F_OK) == 0 ? "/dev/uinput" : 0;
|
||||
access("/dev/input/uinput", F_OK) == 0
|
||||
? "/dev/input/uinput"
|
||||
: access("/dev/uinput", F_OK) == 0 ? "/dev/uinput" : 0;
|
||||
if (!dev_uinput_fname) {
|
||||
G13_LOG(error, "Could not find an uinput device");
|
||||
return -1;
|
||||
@ -188,7 +189,6 @@ void G13_Device::register_context(libusb_context *_ctx) {
|
||||
|
||||
_uinput_fid = g13_create_uinput(this);
|
||||
|
||||
|
||||
_input_pipe_name = _manager.make_pipe_name(this, true);
|
||||
_input_pipe_fid = g13_create_fifo(_input_pipe_name.c_str());
|
||||
_output_pipe_name = _manager.make_pipe_name(this, false);
|
||||
@ -223,17 +223,16 @@ 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 ); \
|
||||
return BOOST_PP_STRINGIZE(elem);
|
||||
|
||||
switch (code) {
|
||||
|
||||
BOOST_PP_SEQ_FOR_EACH(TEST_libusb_error, _,
|
||||
(SUCCESS)(ERROR_IO)(ERROR_INVALID_PARAM)(ERROR_ACCESS)
|
||||
(ERROR_NO_DEVICE)(ERROR_NOT_FOUND)(ERROR_BUSY)
|
||||
(ERROR_TIMEOUT)(ERROR_OVERFLOW)(ERROR_PIPE)
|
||||
(ERROR_INTERRUPTED)(ERROR_NO_MEM)(ERROR_NOT_SUPPORTED)
|
||||
(ERROR_OTHER))
|
||||
|
||||
BOOST_PP_SEQ_FOR_EACH(
|
||||
TEST_libusb_error, _,
|
||||
(SUCCESS)(ERROR_IO)(ERROR_INVALID_PARAM)(ERROR_ACCESS)(ERROR_NO_DEVICE)(
|
||||
ERROR_NOT_FOUND)(ERROR_BUSY)(ERROR_TIMEOUT)(ERROR_OVERFLOW)(
|
||||
ERROR_PIPE)(ERROR_INTERRUPTED)(ERROR_NO_MEM)(ERROR_NOT_SUPPORTED)(
|
||||
ERROR_OTHER))
|
||||
}
|
||||
return "unknown error";
|
||||
}
|
||||
@ -246,14 +245,15 @@ static std::string describe_libusb_error_code(int code) {
|
||||
int G13_Device::read_keys() {
|
||||
unsigned char buffer[G13_REPORT_SIZE];
|
||||
int size;
|
||||
int error = libusb_interrupt_transfer( handle,
|
||||
LIBUSB_ENDPOINT_IN | G13_KEY_ENDPOINT, buffer, G13_REPORT_SIZE,
|
||||
&size, 100);
|
||||
int error =
|
||||
libusb_interrupt_transfer(handle, LIBUSB_ENDPOINT_IN | G13_KEY_ENDPOINT,
|
||||
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) << ")" );
|
||||
G13_LOG(error, "Error while reading keys: "
|
||||
<< error << " (" << describe_libusb_error_code(error)
|
||||
<< ")");
|
||||
// G13_LOG( error, "Stopping daemon" );
|
||||
// return -1;
|
||||
}
|
||||
@ -265,7 +265,6 @@ int G13_Device::read_keys() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void G13_Device::read_config_file(const std::string &filename) {
|
||||
std::ifstream s(filename);
|
||||
|
||||
@ -282,7 +281,8 @@ void G13_Device::read_config_file( const std::string &filename ) {
|
||||
char *comment = strchr(buf, '#');
|
||||
if (comment) {
|
||||
comment--;
|
||||
while( comment > buf && isspace( *comment ) ) comment--;
|
||||
while (comment > buf && isspace(*comment))
|
||||
comment--;
|
||||
*comment = 0;
|
||||
}
|
||||
|
||||
@ -309,7 +309,8 @@ void G13_Device::read_commands() {
|
||||
ret = read(_input_pipe_fid, buf, 1024 * 1024);
|
||||
G13_LOG(trace, "read " << ret << " characters");
|
||||
|
||||
if (ret == 960) { // TODO probably image, for now, don't test, just assume image
|
||||
if (ret ==
|
||||
960) { // TODO probably image, for now, don't test, just assume image
|
||||
lcd().image(buf, ret);
|
||||
} else {
|
||||
std::string buffer = reinterpret_cast<const char *>(buf);
|
||||
@ -320,7 +321,8 @@ void G13_Device::read_commands() {
|
||||
std::vector<std::string> command_comment;
|
||||
boost::split(command_comment, cmd, boost::is_any_of("#"));
|
||||
|
||||
if (command_comment.size() > 0 && command_comment[0] != std::string("")) {
|
||||
if (command_comment.size() > 0 &&
|
||||
command_comment[0] != std::string("")) {
|
||||
G13_LOG(info, "command: " << command_comment[0]);
|
||||
command(command_comment[0].c_str());
|
||||
}
|
||||
@ -330,19 +332,12 @@ void G13_Device::read_commands() {
|
||||
}
|
||||
|
||||
G13_Device::G13_Device(G13_Manager &manager, libusb_device_handle *handle,
|
||||
int _id) :
|
||||
_manager(manager),
|
||||
_lcd(*this),
|
||||
_stick(*this),
|
||||
handle(handle),
|
||||
_id_within_manager(_id),
|
||||
_uinput_fid(-1),
|
||||
ctx(0)
|
||||
{
|
||||
int _id)
|
||||
: _manager(manager), _lcd(*this), _stick(*this), handle(handle),
|
||||
_id_within_manager(_id), _uinput_fid(-1), ctx(0) {
|
||||
_current_profile = ProfilePtr(new G13_Profile(*this, "default"));
|
||||
_profiles["default"] = _current_profile;
|
||||
|
||||
|
||||
for (int i = 0; i < sizeof(keys); i++)
|
||||
keys[i] = false;
|
||||
|
||||
@ -362,7 +357,6 @@ FontPtr G13_Device::switch_to_font(const std::string &name) {
|
||||
|
||||
void G13_Device::switch_to_profile(const std::string &name) {
|
||||
_current_profile = profile(name);
|
||||
|
||||
}
|
||||
|
||||
ProfilePtr G13_Device::profile(const std::string &name) {
|
||||
@ -376,12 +370,11 @@ ProfilePtr G13_Device::profile(const std::string &name) {
|
||||
|
||||
// *************************************************************************
|
||||
|
||||
G13_Action::~G13_Action() {
|
||||
}
|
||||
G13_Action::~G13_Action() {}
|
||||
|
||||
G13_Action_Keys::G13_Action_Keys(G13_Device & keypad, const std::string &keys_string) :
|
||||
G13_Action(keypad)
|
||||
{
|
||||
G13_Action_Keys::G13_Action_Keys(G13_Device &keypad,
|
||||
const std::string &keys_string)
|
||||
: G13_Action(keypad) {
|
||||
std::vector<std::string> keys;
|
||||
boost::split(keys, keys_string, boost::is_any_of("+"));
|
||||
|
||||
@ -396,8 +389,7 @@ G13_Action_Keys::G13_Action_Keys(G13_Device & keypad, const std::string &keys_st
|
||||
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) {
|
||||
if (is_down) {
|
||||
@ -410,7 +402,6 @@ void G13_Action_Keys::act(G13_Device &g13, bool is_down) {
|
||||
g13.send_event(EV_KEY, _keys[i], is_down);
|
||||
G13_LOG(trace, "sending KEY UP " << _keys[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,17 +409,16 @@ 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() {
|
||||
}
|
||||
const std::string &out)
|
||||
: 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) {
|
||||
@ -440,13 +430,10 @@ void G13_Action_PipeOut::dump( std::ostream &o ) const {
|
||||
o << "WRITE PIPE : " << repr(_out);
|
||||
}
|
||||
|
||||
|
||||
G13_Action_Command::G13_Action_Command(G13_Device &keypad,
|
||||
const std::string &cmd) :
|
||||
G13_Action(keypad), _cmd(cmd) {
|
||||
}
|
||||
G13_Action_Command::~G13_Action_Command() {
|
||||
}
|
||||
const std::string &cmd)
|
||||
: 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) {
|
||||
@ -494,17 +481,17 @@ void G13_Device::dump(std::ostream &o, int detail ) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// *************************************************************************
|
||||
|
||||
#define RETURN_FAIL(message) \
|
||||
{ \
|
||||
G13_LOG(error, message); \
|
||||
return; \
|
||||
} \
|
||||
}
|
||||
|
||||
struct command_adder {
|
||||
command_adder( G13_Device::CommandFunctionTable & t, const char *name ) : _t(t), _name(name) {}
|
||||
command_adder(G13_Device::CommandFunctionTable &t, const char *name)
|
||||
: _t(t), _name(name) {}
|
||||
|
||||
G13_Device::CommandFunctionTable &_t;
|
||||
std::string _name;
|
||||
@ -518,20 +505,13 @@ struct command_adder {
|
||||
; \
|
||||
command_adder BOOST_PP_CAT(add_, name)(_command_table, \
|
||||
BOOST_PP_STRINGIZE(name)); \
|
||||
BOOST_PP_CAT(add_, name ) += \
|
||||
[this]( const char *remainder ) \
|
||||
|
||||
BOOST_PP_CAT(add_, name) += [this](const char *remainder)
|
||||
|
||||
void G13_Device::_init_commands() {
|
||||
|
||||
|
||||
using Helper::advance_ws;
|
||||
|
||||
|
||||
G13_DEVICE_COMMAND( out ) {
|
||||
lcd().write_string(remainder);
|
||||
}
|
||||
|
||||
G13_DEVICE_COMMAND(out) { lcd().write_string(remainder); }
|
||||
|
||||
G13_DEVICE_COMMAND(pos) {
|
||||
int row, col;
|
||||
@ -556,23 +536,16 @@ void G13_Device::_init_commands() {
|
||||
}
|
||||
G13_LOG(trace, "bind " << keyname << " [" << action << "]");
|
||||
} catch (const std::exception &ex) {
|
||||
RETURN_FAIL( "bind " << keyname << " " << action << " failed : " << ex.what() );
|
||||
RETURN_FAIL("bind " << keyname << " " << action
|
||||
<< " failed : " << ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
G13_DEVICE_COMMAND( profile ) {
|
||||
switch_to_profile(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(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;
|
||||
@ -590,9 +563,10 @@ void G13_Device::_init_commands() {
|
||||
if (mode == BOOST_PP_STRINGIZE(elem)) { \
|
||||
_stick.set_mode(BOOST_PP_CAT(STICK_, elem)); \
|
||||
return; \
|
||||
} else \
|
||||
} else
|
||||
|
||||
BOOST_PP_SEQ_FOR_EACH( STICKMODE_TEST, _,
|
||||
BOOST_PP_SEQ_FOR_EACH(
|
||||
STICKMODE_TEST, _,
|
||||
(ABSOLUTE)(RELATIVE)(KEYS)(CALCENTER)(CALBOUNDS)(CALNORTH)) {
|
||||
RETURN_FAIL("unknown stick mode : <" << mode << ">");
|
||||
}
|
||||
@ -613,8 +587,7 @@ void G13_Device::_init_commands() {
|
||||
zone->set_action(make_action(remainder));
|
||||
} else if (operation == "bounds") {
|
||||
double x1, y1, x2, y2;
|
||||
if (sscanf(remainder, "%lf %lf %lf %lf", &x1, &y1, &x2,
|
||||
&y2) != 4) {
|
||||
if (sscanf(remainder, "%lf %lf %lf %lf", &x1, &y1, &x2, &y2) != 4) {
|
||||
throw G13_CommandException("bad bounds format");
|
||||
}
|
||||
zone->set_bounds(G13_ZoneBounds(x1, y1, x2, y2));
|
||||
@ -647,9 +620,7 @@ void G13_Device::_init_commands() {
|
||||
manager().set_log_level(level);
|
||||
}
|
||||
|
||||
G13_DEVICE_COMMAND( refresh ) {
|
||||
lcd().image_send();
|
||||
}
|
||||
G13_DEVICE_COMMAND(refresh) { lcd().image_send(); }
|
||||
|
||||
G13_DEVICE_COMMAND(clear) {
|
||||
lcd().image_clear();
|
||||
@ -668,7 +639,6 @@ void G13_Device::command(char const *str) {
|
||||
std::string cmd;
|
||||
advance_ws(remainder, cmd);
|
||||
|
||||
|
||||
auto i = _command_table.find(cmd);
|
||||
if (i == _command_table.end()) {
|
||||
RETURN_FAIL("unknown command : " << cmd)
|
||||
@ -681,29 +651,22 @@ void G13_Device::command(char const *str) {
|
||||
}
|
||||
}
|
||||
|
||||
G13_Manager::G13_Manager() :
|
||||
ctx(0), devs(0) {
|
||||
}
|
||||
G13_Manager::G13_Manager() : ctx(0), devs(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 {
|
||||
return find_or_throw(_string_config_values, name);
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
} catch (...) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
void G13_Manager::set_string_config_value( const std::string &name, const std::string &value ) {
|
||||
void G13_Manager::set_string_config_value(const std::string &name,
|
||||
const std::string &value) {
|
||||
G13_LOG(info, "set_string_config_value " << name << " = " << repr(value));
|
||||
_string_config_values[name] = value;
|
||||
}
|
||||
@ -715,21 +678,25 @@ std::string G13_Manager::make_pipe_name( G13_Device *d, bool is_input ) {
|
||||
if (d->id_within_manager() == 0) {
|
||||
return config_base;
|
||||
} else {
|
||||
return config_base + "-" + boost::lexical_cast<std::string>(d->id_within_manager());
|
||||
return config_base + "-" +
|
||||
boost::lexical_cast<std::string>(d->id_within_manager());
|
||||
}
|
||||
}
|
||||
return CONTROL_DIR+ "g13-" + boost::lexical_cast<std::string>(d->id_within_manager());
|
||||
return CONTROL_DIR + "g13-" +
|
||||
boost::lexical_cast<std::string>(d->id_within_manager());
|
||||
} else {
|
||||
std::string config_base = string_config_value("pipe_out");
|
||||
if (config_base.size()) {
|
||||
if (d->id_within_manager() == 0) {
|
||||
return config_base;
|
||||
} else {
|
||||
return config_base + "-" + boost::lexical_cast<std::string>(d->id_within_manager());
|
||||
return config_base + "-" +
|
||||
boost::lexical_cast<std::string>(d->id_within_manager());
|
||||
}
|
||||
}
|
||||
|
||||
return CONTROL_DIR+ "g13-" + boost::lexical_cast<std::string>(d->id_within_manager()) +"_out";
|
||||
return CONTROL_DIR + "g13-" +
|
||||
boost::lexical_cast<std::string>(d->id_within_manager()) + "_out";
|
||||
}
|
||||
}
|
||||
|
||||
@ -792,5 +759,3 @@ int G13_Manager::run() {
|
||||
return 0;
|
||||
}
|
||||
} // namespace G13
|
||||
|
||||
|
||||
|
130
g13d/g13.h
130
g13d/g13.h
@ -1,21 +1,20 @@
|
||||
#ifndef __G13_H__
|
||||
#define __G13_H__
|
||||
|
||||
|
||||
#include "helper.h"
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <fstream>
|
||||
#include <linux/uinput.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// *************************************************************************
|
||||
|
||||
@ -34,7 +33,6 @@ const size_t G13_REPORT_SIZE = 8;
|
||||
const size_t G13_LCD_BUFFER_SIZE = 0x3c0;
|
||||
const size_t G13_NUM_KEYS = 40;
|
||||
|
||||
|
||||
const size_t G13_LCD_COLUMNS = 160;
|
||||
const size_t G13_LCD_ROWS = 48;
|
||||
const size_t G13_LCD_BYTES_PER_ROW = G13_LCD_COLUMNS / 8;
|
||||
@ -42,7 +40,14 @@ const size_t G13_LCD_BUF_SIZE = G13_LCD_ROWS * G13_LCD_BYTES_PER_ROW;
|
||||
const size_t G13_LCD_TEXT_CHEIGHT = 8;
|
||||
const size_t G13_LCD_TEXT_ROWS = 160 / G13_LCD_TEXT_CHEIGHT;
|
||||
|
||||
enum stick_mode_t { STICK_ABSOLUTE, STICK_RELATIVE, STICK_KEYS, STICK_CALCENTER, STICK_CALBOUNDS, STICK_CALNORTH };
|
||||
enum stick_mode_t {
|
||||
STICK_ABSOLUTE,
|
||||
STICK_RELATIVE,
|
||||
STICK_KEYS,
|
||||
STICK_CALCENTER,
|
||||
STICK_CALBOUNDS,
|
||||
STICK_CALNORTH
|
||||
};
|
||||
|
||||
typedef int LINUX_KEY_VALUE;
|
||||
const LINUX_KEY_VALUE BAD_KEY_VALUE = -1;
|
||||
@ -51,8 +56,8 @@ typedef int G13_KEY_INDEX;
|
||||
|
||||
// *************************************************************************
|
||||
|
||||
using Helper::repr;
|
||||
using Helper::find_or_throw;
|
||||
using Helper::repr;
|
||||
|
||||
// *************************************************************************
|
||||
|
||||
@ -97,7 +102,6 @@ private:
|
||||
G13_Device &_keypad;
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
* action to send one or more keystrokes
|
||||
*/
|
||||
@ -140,16 +144,13 @@ public:
|
||||
std::string _cmd;
|
||||
};
|
||||
|
||||
|
||||
typedef boost::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 ) :
|
||||
_parent_ptr(&parent_arg), _name(name)
|
||||
{}
|
||||
G13_Actionable(PARENT_T &parent_arg, const std::string &name)
|
||||
: _parent_ptr(&parent_arg), _name(name) {}
|
||||
virtual ~G13_Actionable() { _parent_ptr = 0; }
|
||||
|
||||
G13_ActionPtr action() const { return _action; }
|
||||
@ -159,12 +160,9 @@ public:
|
||||
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;
|
||||
G13_ActionPtr _action;
|
||||
|
||||
@ -178,22 +176,14 @@ private:
|
||||
*/
|
||||
class G13_Key : public G13_Actionable<G13_Profile> {
|
||||
public:
|
||||
|
||||
|
||||
void dump(std::ostream &o) const;
|
||||
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;
|
||||
@ -203,20 +193,16 @@ protected:
|
||||
// G13_Profile is the only class able to instantiate G13_Keys
|
||||
friend class G13_Profile;
|
||||
|
||||
G13_Key( G13_Profile & mode, const std::string &name, int index ) : G13_Actionable<G13_Profile>( mode, name ),
|
||||
_index(index),
|
||||
_should_parse(true)
|
||||
{
|
||||
}
|
||||
G13_Key(G13_Profile &mode, const std::string &name, int 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),
|
||||
_should_parse(key._should_parse)
|
||||
{
|
||||
G13_Key(G13_Profile &mode, const G13_Key &key)
|
||||
: G13_Actionable<G13_Profile>(mode, key.name()), _index(key._index),
|
||||
_should_parse(key._should_parse) {
|
||||
set_action(key.action());
|
||||
}
|
||||
|
||||
|
||||
KeyIndex _index;
|
||||
bool _should_parse;
|
||||
};
|
||||
@ -229,13 +215,12 @@ protected:
|
||||
*/
|
||||
class G13_Profile {
|
||||
public:
|
||||
G13_Profile(G13_Device &keypad, const std::string &name_arg ) : _keypad(keypad), _name(name_arg) {
|
||||
G13_Profile(G13_Device &keypad, const std::string &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)
|
||||
{
|
||||
}
|
||||
|
||||
G13_Profile(const G13_Profile &other, const std::string &name_arg)
|
||||
: _keypad(other._keypad), _name(name_arg), _keys(other._keys) {}
|
||||
|
||||
// search key by G13 keyname
|
||||
G13_Key *find_key(const std::string &keyname);
|
||||
@ -276,7 +261,6 @@ public:
|
||||
G13_Font();
|
||||
G13_Font(const std::string &name, unsigned int width = 8);
|
||||
|
||||
|
||||
void set_character(unsigned int c, unsigned char *data);
|
||||
|
||||
template <class ARRAY_T, class FLAGST>
|
||||
@ -286,6 +270,7 @@ public:
|
||||
unsigned int width() const { return _width; }
|
||||
|
||||
const G13_FontChar &char_data(unsigned int x) { return _chars[x]; }
|
||||
|
||||
protected:
|
||||
std::string _name;
|
||||
unsigned int _width;
|
||||
@ -299,8 +284,6 @@ typedef boost::shared_ptr<G13_Font> FontPtr;
|
||||
|
||||
class G13_LCD {
|
||||
public:
|
||||
|
||||
|
||||
G13_LCD(G13_Device &keypad);
|
||||
|
||||
G13_Device &_keypad;
|
||||
@ -310,14 +293,10 @@ 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;
|
||||
@ -326,12 +305,9 @@ public:
|
||||
void image_setpixel(unsigned row, unsigned col);
|
||||
void image_clearpixel(unsigned row, unsigned col);
|
||||
|
||||
|
||||
|
||||
void write_char(char c, int row = -1, int col = -1);
|
||||
void write_string(const char *str);
|
||||
void write_pos(int row, int col);
|
||||
|
||||
};
|
||||
using Helper::repr;
|
||||
|
||||
@ -344,10 +320,12 @@ typedef Helper::Bounds<double> G13_ZoneBounds;
|
||||
|
||||
class G13_StickZone : public G13_Actionable<G13_Stick> {
|
||||
public:
|
||||
G13_StickZone(G13_Stick &, const std::string &name, const G13_ZoneBounds &,
|
||||
G13_ActionPtr = 0);
|
||||
|
||||
G13_StickZone( G13_Stick &, const std::string &name, const G13_ZoneBounds &, G13_ActionPtr = 0 );
|
||||
|
||||
bool operator == ( const G13_StickZone &other ) const { return _name == other._name; }
|
||||
bool operator==(const G13_StickZone &other) const {
|
||||
return _name == other._name;
|
||||
}
|
||||
|
||||
void dump(std::ostream &) const;
|
||||
|
||||
@ -355,13 +333,10 @@ public:
|
||||
void test(const G13_ZoneCoord &loc);
|
||||
void set_bounds(const G13_ZoneBounds &bounds) { _bounds = bounds; }
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
bool _active;
|
||||
|
||||
G13_ZoneBounds _bounds;
|
||||
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<G13_StickZone> G13_StickZonePtr;
|
||||
@ -383,7 +358,6 @@ public:
|
||||
void dump(std::ostream &) const;
|
||||
|
||||
protected:
|
||||
|
||||
void _recalc_calibrated();
|
||||
|
||||
G13_Device &_keypad;
|
||||
@ -396,17 +370,14 @@ protected:
|
||||
G13_StickCoord _current_pos;
|
||||
|
||||
stick_mode_t _stick_mode;
|
||||
|
||||
};
|
||||
|
||||
// *************************************************************************
|
||||
|
||||
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; }
|
||||
|
||||
@ -433,7 +404,6 @@ public:
|
||||
void set_key_color(int red, int green, int blue);
|
||||
void set_mode_leds(int leds);
|
||||
|
||||
|
||||
void send_event(int type, int code, int val);
|
||||
void write_output_pipe(const std::string &out);
|
||||
|
||||
@ -456,12 +426,10 @@ public:
|
||||
typedef std::map<std::string, COMMAND_FUNCTION> CommandFunctionTable;
|
||||
|
||||
protected:
|
||||
|
||||
void _init_fonts();
|
||||
void init_lcd();
|
||||
void _init_commands();
|
||||
|
||||
|
||||
// typedef void (COMMAND_FUNCTION)( G13_Device*, const char *, const char * );
|
||||
CommandFunctionTable _command_table;
|
||||
|
||||
@ -488,13 +456,11 @@ protected:
|
||||
G13_LCD _lcd;
|
||||
G13_Stick _stick;
|
||||
|
||||
|
||||
bool keys[G13_NUM_KEYS];
|
||||
};
|
||||
|
||||
// *************************************************************************
|
||||
|
||||
|
||||
/*!
|
||||
* top level class, holds what would otherwise be in global variables
|
||||
*/
|
||||
@ -521,21 +487,18 @@ public:
|
||||
void set_log_level(const std::string &);
|
||||
|
||||
protected:
|
||||
|
||||
void init_keynames();
|
||||
void display_keys();
|
||||
void discover_g13s(libusb_device **devs, ssize_t count, std::vector<G13_Device*>& g13s);
|
||||
void discover_g13s(libusb_device **devs, ssize_t count,
|
||||
std::vector<G13_Device *> &g13s);
|
||||
void cleanup();
|
||||
|
||||
|
||||
|
||||
std::string logo_filename;
|
||||
libusb_device **devs;
|
||||
|
||||
libusb_context *ctx;
|
||||
std::vector<G13_Device *> g13s;
|
||||
|
||||
|
||||
std::map<G13_KEY_INDEX, std::string> g13_key_to_name;
|
||||
std::map<std::string, G13_KEY_INDEX> g13_name_to_key;
|
||||
std::map<LINUX_KEY_VALUE, std::string> input_key_to_name;
|
||||
@ -551,18 +514,13 @@ protected:
|
||||
|
||||
// inlines
|
||||
|
||||
inline G13_Manager &G13_Action::manager() {
|
||||
return _keypad.manager();
|
||||
}
|
||||
inline G13_Manager &G13_Action::manager() { return _keypad.manager(); }
|
||||
|
||||
inline const G13_Manager &G13_Action::manager() const {
|
||||
return _keypad.manager();
|
||||
}
|
||||
|
||||
inline bool G13_Device::is_set(int key)
|
||||
{
|
||||
return keys[key];
|
||||
}
|
||||
inline bool G13_Device::is_set(int key) { return keys[key]; }
|
||||
|
||||
inline bool G13_Device::update(int key, bool v) {
|
||||
bool old = keys[key];
|
||||
@ -570,14 +528,12 @@ inline bool G13_Device::update(int key, bool v) {
|
||||
return old != v;
|
||||
}
|
||||
|
||||
inline const G13_Manager &G13_Profile::manager() const
|
||||
{
|
||||
inline const G13_Manager &G13_Profile::manager() const {
|
||||
return _keypad.manager();
|
||||
}
|
||||
|
||||
// *************************************************************************
|
||||
|
||||
|
||||
} // namespace G13
|
||||
|
||||
#endif // __G13_H__
|
||||
|
@ -4,7 +4,6 @@ using namespace std;
|
||||
|
||||
namespace G13 {
|
||||
|
||||
|
||||
// font data from https://github.com/dhepper/font8x8
|
||||
// Constant: font8x8_basic
|
||||
// Contains an 8x8 font map for unicode points U+0000 - U+007F (basic latin)
|
||||
@ -366,16 +365,13 @@ namespace G13 {
|
||||
{0x18, 0xA2, 0xA0, 0xA2, 0x78} // 0xFF ÿ
|
||||
};
|
||||
|
||||
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) {}
|
||||
|
||||
G13_Font::G13_Font( const std::string &name, unsigned int width ) :_name(name), _width(width)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void G13_FontChar::set_character( unsigned char *data, int width, unsigned flags ) {
|
||||
void G13_FontChar::set_character(unsigned char *data, int width,
|
||||
unsigned flags) {
|
||||
unsigned char *dest = bits_regular;
|
||||
memset(dest, 0, CHAR_BUF_SIZE);
|
||||
if (flags && FF_ROTATE) {
|
||||
@ -396,9 +392,9 @@ void G13_FontChar::set_character( unsigned char *data, int width, unsigned flags
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename T, int size>
|
||||
int GetFontCharacterCount( T(&)[size] ) { return size; }
|
||||
template <typename T, int size> int GetFontCharacterCount(T (&)[size]) {
|
||||
return size;
|
||||
}
|
||||
|
||||
template <class ARRAY_T, class FLAGST>
|
||||
void G13_Font::install_font(ARRAY_T &data, FLAGST flags, int first) {
|
||||
@ -419,4 +415,3 @@ void G13_Device::_init_fonts() {
|
||||
}
|
||||
|
||||
} // namespace G13
|
||||
|
||||
|
@ -14,19 +14,18 @@ namespace G13 {
|
||||
*/
|
||||
|
||||
#define G13_KEY_SEQ \
|
||||
/* byte 3 */ (G1)(G2)(G3)(G4)(G5)(G6)(G7)(G8) \
|
||||
/* byte 4 */ (G9)(G10)(G11)(G12)(G13)(G14)(G15)(G16) \
|
||||
/* byte 5 */ (G17)(G18)(G19)(G20)(G21)(G22)(UNDEF1)(LIGHT_STATE) \
|
||||
/* byte 6 */ (BD)(L1)(L2)(L3)(L4)(M1)(M2)(M3) \
|
||||
/* byte 7 */ (MR)(LEFT)(DOWN)(TOP)(UNDEF3)(LIGHT)(LIGHT2)(MISC_TOGGLE) \
|
||||
|
||||
/* byte 3 */ (G1)(G2)(G3)(G4)(G5)(G6)(G7)(G8) /* byte 4 */ \
|
||||
(G9)(G10)(G11)(G12)(G13)(G14)(G15)(G16) /* byte 5 */ (G17)(G18)(G19)( \
|
||||
G20)(G21)(G22)(UNDEF1)(LIGHT_STATE) /* byte 6 */ \
|
||||
(BD)(L1)(L2)(L3)(L4)(M1)(M2)(M3) /* byte 7 */ (MR)(LEFT)(DOWN)(TOP)( \
|
||||
UNDEF3)(LIGHT)(LIGHT2)(MISC_TOGGLE)
|
||||
|
||||
/*! G13_NONPARSED_KEY_SEQ is a Boost Preprocessor sequence containing the
|
||||
* G13 keys that shouldn't be tested input. These aren't actually keys,
|
||||
* but they are in the bitmap defined by G13_KEY_SEQ.
|
||||
*/
|
||||
#define G13_NONPARSED_KEY_SEQ \
|
||||
(UNDEF1)(LIGHT_STATE)(UNDEF3)(LIGHT)(LIGHT2)(UNDEF3)(MISC_TOGGLE) \
|
||||
(UNDEF1)(LIGHT_STATE)(UNDEF3)(LIGHT)(LIGHT2)(UNDEF3)(MISC_TOGGLE)
|
||||
|
||||
/*! KB_INPUT_KEY_SEQ is a Boost Preprocessor sequence containing the
|
||||
* names of keyboard keys we can send through binding actions.
|
||||
@ -35,22 +34,14 @@ namespace G13 {
|
||||
*/
|
||||
|
||||
#define KB_INPUT_KEY_SEQ \
|
||||
(ESC)(1)(2)(3)(4)(5)(6)(7)(8)(9)(0) \
|
||||
(MINUS)(EQUAL)(BACKSPACE)(TAB) \
|
||||
(Q)(W)(E)(R)(T)(Y)(U)(I)(O)(P) \
|
||||
(LEFTBRACE)(RIGHTBRACE)(ENTER)(LEFTCTRL)(RIGHTCTRL) \
|
||||
(A)(S)(D)(F)(G)(H)(J)(K)(L) \
|
||||
(SEMICOLON)(APOSTROPHE)(GRAVE)(LEFTSHIFT)(BACKSLASH) \
|
||||
(Z)(X)(C)(V)(B)(N)(M) \
|
||||
(COMMA)(DOT)(SLASH)(RIGHTSHIFT)(KPASTERISK) \
|
||||
(LEFTALT)(RIGHTALT)(SPACE)(CAPSLOCK) \
|
||||
(F1)(F2)(F3)(F4)(F5)(F6)(F7)(F8)(F9)(F10)(F11)(F12) \
|
||||
(NUMLOCK)(SCROLLLOCK) \
|
||||
(KP7)(KP8)(KP9)(KPMINUS)(KP4)(KP5)(KP6)(KPPLUS) \
|
||||
(KP1)(KP2)(KP3)(KP0)(KPDOT) \
|
||||
(LEFT)(RIGHT)(UP)(DOWN) \
|
||||
(PAGEUP)(PAGEDOWN)(HOME)(END)(INSERT)(DELETE) \
|
||||
|
||||
(ESC)(1)(2)(3)(4)(5)(6)(7)(8)(9)(0)(MINUS)(EQUAL)(BACKSPACE)(TAB)(Q)(W)(E)( \
|
||||
R)(T)(Y)(U)(I)(O)(P)(LEFTBRACE)(RIGHTBRACE)(ENTER)(LEFTCTRL)(RIGHTCTRL)( \
|
||||
A)(S)(D)(F)(G)(H)(J)(K)(L)(SEMICOLON)(APOSTROPHE)(GRAVE)(LEFTSHIFT)( \
|
||||
BACKSLASH)(Z)(X)(C)(V)(B)(N)(M)(COMMA)(DOT)(SLASH)(RIGHTSHIFT)( \
|
||||
KPASTERISK)(LEFTALT)(RIGHTALT)(SPACE)(CAPSLOCK)(F1)(F2)(F3)(F4)(F5)(F6)( \
|
||||
F7)(F8)(F9)(F10)(F11)(F12)(NUMLOCK)(SCROLLLOCK)(KP7)(KP8)(KP9)(KPMINUS)( \
|
||||
KP4)(KP5)(KP6)(KPPLUS)(KP1)(KP2)(KP3)(KP0)(KPDOT)(LEFT)(RIGHT)(UP)( \
|
||||
DOWN)(PAGEUP)(PAGEDOWN)(HOME)(END)(INSERT)(DELETE)
|
||||
|
||||
// *************************************************************************
|
||||
|
||||
@ -62,7 +53,7 @@ void G13_Profile::_init_keys() {
|
||||
{ \
|
||||
G13_Key key(*this, BOOST_PP_STRINGIZE(elem), key_index++); \
|
||||
_keys.push_back(key); \
|
||||
} \
|
||||
}
|
||||
|
||||
BOOST_PP_SEQ_FOR_EACH(INIT_KEY, _, G13_KEY_SEQ)
|
||||
|
||||
@ -74,7 +65,7 @@ void G13_Profile::_init_keys() {
|
||||
G13_Key *key = find_key(BOOST_PP_STRINGIZE(elem)); \
|
||||
assert(key); \
|
||||
key->_should_parse = false; \
|
||||
} \
|
||||
}
|
||||
|
||||
BOOST_PP_SEQ_FOR_EACH(MARK_NON_PARSED_KEY, _, G13_NONPARSED_KEY_SEQ)
|
||||
}
|
||||
@ -116,9 +107,6 @@ G13_Key * G13_Profile::find_key(const std::string &keyname) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// *************************************************************************
|
||||
|
||||
void G13_Key::parse_key(unsigned char *byte, G13_Device *g13) {
|
||||
@ -144,7 +132,7 @@ void G13_Manager::init_keynames() {
|
||||
g13_key_to_name[key_index] = name; \
|
||||
g13_name_to_key[name] = key_index; \
|
||||
key_index++; \
|
||||
} \
|
||||
}
|
||||
|
||||
BOOST_PP_SEQ_FOR_EACH(ADD_G13_KEY_MAPPING, _, G13_KEY_SEQ)
|
||||
|
||||
@ -155,13 +143,13 @@ void G13_Manager::init_keynames() {
|
||||
int keyval = BOOST_PP_CAT(KEY_, elem); \
|
||||
input_key_to_name[keyval] = name; \
|
||||
input_name_to_key[name] = keyval; \
|
||||
} \
|
||||
|
||||
}
|
||||
|
||||
BOOST_PP_SEQ_FOR_EACH(ADD_KB_KEY_MAPPING, _, KB_INPUT_KEY_SEQ)
|
||||
}
|
||||
|
||||
LINUX_KEY_VALUE G13_Manager::find_g13_key_value( const std::string &keyname ) const {
|
||||
LINUX_KEY_VALUE
|
||||
G13_Manager::find_g13_key_value(const std::string &keyname) const {
|
||||
auto i = g13_name_to_key.find(keyname);
|
||||
if (i == g13_name_to_key.end()) {
|
||||
return BAD_KEY_VALUE;
|
||||
@ -169,8 +157,8 @@ LINUX_KEY_VALUE G13_Manager::find_g13_key_value( const std::string &keyname ) co
|
||||
return i->second;
|
||||
}
|
||||
|
||||
|
||||
LINUX_KEY_VALUE G13_Manager::find_input_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)) {
|
||||
@ -187,8 +175,7 @@ LINUX_KEY_VALUE G13_Manager::find_input_key_value( const std::string &keyname )
|
||||
std::string G13_Manager::find_input_key_name(LINUX_KEY_VALUE v) const {
|
||||
try {
|
||||
return find_or_throw(input_key_to_name, v);
|
||||
}
|
||||
catch(...) {
|
||||
} catch (...) {
|
||||
return "(unknown linux key)";
|
||||
}
|
||||
}
|
||||
@ -196,14 +183,11 @@ std::string G13_Manager::find_input_key_name( LINUX_KEY_VALUE v ) const {
|
||||
std::string G13_Manager::find_g13_key_name(G13_KEY_INDEX v) const {
|
||||
try {
|
||||
return find_or_throw(g13_key_to_name, v);
|
||||
}
|
||||
catch(...) {
|
||||
} catch (...) {
|
||||
return "(unknown G13 key)";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void G13_Manager::display_keys() {
|
||||
|
||||
typedef std::map<std::string, int> mapType;
|
||||
@ -212,8 +196,6 @@ void G13_Manager::display_keys() {
|
||||
|
||||
G13_OUT("Known keys to map to:");
|
||||
G13_OUT(Helper::map_keys_out(input_name_to_key));
|
||||
|
||||
}
|
||||
|
||||
} // namespace G13
|
||||
|
||||
|
@ -4,7 +4,8 @@
|
||||
byte 0 contains column 0 / row 0 - 7
|
||||
byte 1 contains column 1 / row 0 - 7
|
||||
|
||||
so the masks for each pixel are laid out as below (ByteOffset.PixelMask)
|
||||
so the masks for each pixel are laid out as below
|
||||
(ByteOffset.PixelMask)
|
||||
|
||||
00.01 01.01 02.01 ...
|
||||
00.02 01.02 02.02 ...
|
||||
@ -34,7 +35,8 @@ void G13_Device::init_lcd() {
|
||||
void G13_Device::write_lcd(unsigned char *data, size_t size) {
|
||||
init_lcd();
|
||||
if (size != G13_LCD_BUFFER_SIZE) {
|
||||
G13_LOG( error, "Invalid LCD data size " << size << ", should be " << G13_LCD_BUFFER_SIZE );
|
||||
G13_LOG(error, "Invalid LCD data size " << size << ", should be "
|
||||
<< G13_LCD_BUFFER_SIZE);
|
||||
return;
|
||||
}
|
||||
unsigned char buffer[G13_LCD_BUFFER_SIZE + 32];
|
||||
@ -42,9 +44,12 @@ void G13_Device::write_lcd( unsigned char *data, size_t size ) {
|
||||
buffer[0] = 0x03;
|
||||
memcpy(buffer + 32, data, G13_LCD_BUFFER_SIZE);
|
||||
int bytes_written;
|
||||
int error = libusb_interrupt_transfer(handle, LIBUSB_ENDPOINT_OUT | G13_LCD_ENDPOINT, buffer, G13_LCD_BUFFER_SIZE + 32, &bytes_written, 1000);
|
||||
int error = libusb_interrupt_transfer(
|
||||
handle, LIBUSB_ENDPOINT_OUT | G13_LCD_ENDPOINT, buffer,
|
||||
G13_LCD_BUFFER_SIZE + 32, &bytes_written, 1000);
|
||||
if (error)
|
||||
G13_LOG( error, "Error when transferring image: " << error << ", " << bytes_written << " bytes written" );
|
||||
G13_LOG(error, "Error when transferring image: "
|
||||
<< error << ", " << bytes_written << " bytes written");
|
||||
}
|
||||
|
||||
void G13_Device::write_lcd_file(const string &filename) {
|
||||
@ -77,11 +82,13 @@ G13_LCD::G13_LCD( G13_Device &keypad ) : _keypad(keypad) {
|
||||
}
|
||||
|
||||
void G13_LCD::image_setpixel(unsigned row, unsigned col) {
|
||||
unsigned offset = image_byte_offset(row, col); // col + (row /8 ) * BYTES_PER_ROW * 8;
|
||||
unsigned offset =
|
||||
image_byte_offset(row, col); // col + (row /8 ) * BYTES_PER_ROW * 8;
|
||||
unsigned char mask = 1 << ((row)&7);
|
||||
|
||||
if (offset >= G13_LCD_BUF_SIZE) {
|
||||
G13_LOG( error, "bad offset " << offset << " for " << (row) << " x " << (col) );
|
||||
G13_LOG(error,
|
||||
"bad offset " << offset << " for " << (row) << " x " << (col));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -90,17 +97,18 @@ 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 offset =
|
||||
image_byte_offset(row, col); // col + (row /8 ) * BYTES_PER_ROW * 8;
|
||||
unsigned char mask = 1 << ((row)&7);
|
||||
|
||||
if (offset >= G13_LCD_BUF_SIZE) {
|
||||
G13_LOG( error, "bad offset " << offset << " for " << (row) << " x " << (col) );
|
||||
G13_LOG(error,
|
||||
"bad offset " << offset << " for " << (row) << " x " << (col));
|
||||
return;
|
||||
}
|
||||
image_buf[offset] &= ~mask;
|
||||
}
|
||||
|
||||
|
||||
void G13_LCD::write_pos(int row, int col) {
|
||||
cursor_row = row;
|
||||
cursor_col = col;
|
||||
@ -124,11 +132,16 @@ void G13_LCD::write_char( char c, int row, int col ) {
|
||||
}
|
||||
}
|
||||
|
||||
unsigned offset = image_byte_offset( row*G13_LCD_TEXT_CHEIGHT, col ); //*_keypad._current_font->_width );
|
||||
unsigned offset = image_byte_offset(row * G13_LCD_TEXT_CHEIGHT,
|
||||
col); //*_keypad._current_font->_width );
|
||||
if (text_mode) {
|
||||
memcpy( & image_buf[offset], &_keypad.current_font().char_data(c).bits_inverted, _keypad.current_font().width() );
|
||||
memcpy(&image_buf[offset],
|
||||
&_keypad.current_font().char_data(c).bits_inverted,
|
||||
_keypad.current_font().width());
|
||||
} else {
|
||||
memcpy( & image_buf[offset], &_keypad.current_font().char_data(c).bits_regular, _keypad.current_font().width() );
|
||||
memcpy(&image_buf[offset],
|
||||
&_keypad.current_font().char_data(c).bits_regular,
|
||||
_keypad.current_font().width());
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,12 +196,9 @@ void G13_LCD::image_test( int x, int y ) {
|
||||
image_setpixel(row, G13_LCD_COLUMNS - col);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
image_send();
|
||||
}
|
||||
|
||||
|
||||
} // namespace G13
|
||||
|
||||
|
@ -1,27 +1,23 @@
|
||||
#include "g13.h"
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/log/attributes.hpp>
|
||||
#include <boost/log/core/core.hpp>
|
||||
#include <boost/log/expressions.hpp>
|
||||
#include <boost/log/expressions/formatters/stream.hpp>
|
||||
#include <boost/log/sources/severity_feature.hpp>
|
||||
#include <boost/log/sources/severity_logger.hpp>
|
||||
#include <boost/log/core/core.hpp>
|
||||
#include <boost/log/attributes.hpp>
|
||||
#include <boost/log/support/date_time.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/log/expressions.hpp>
|
||||
#include <boost/log/utility/setup.hpp>
|
||||
#include <boost/log/utility/setup/console.hpp>
|
||||
#include <boost/log/expressions/formatters/stream.hpp>
|
||||
#include <boost/log/support/date_time.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace G13 {
|
||||
|
||||
|
||||
void G13_Manager::set_log_level(::boost::log::trivial::severity_level lvl) {
|
||||
boost::log::core::get()->set_filter
|
||||
(
|
||||
::boost::log::trivial::severity >= lvl
|
||||
);
|
||||
boost::log::core::get()->set_filter(::boost::log::trivial::severity >= lvl);
|
||||
G13_OUT("set log level to " << lvl);
|
||||
}
|
||||
|
||||
@ -31,7 +27,7 @@ void G13_Manager::set_log_level( const std::string &level ) {
|
||||
if (level == BOOST_PP_STRINGIZE(L)) { \
|
||||
set_log_level(::boost::log::trivial::L); \
|
||||
return; \
|
||||
} \
|
||||
}
|
||||
|
||||
CHECK_LEVEL(trace);
|
||||
CHECK_LEVEL(debug);
|
||||
@ -44,5 +40,3 @@ void G13_Manager::set_log_level( const std::string &level ) {
|
||||
}
|
||||
|
||||
} // namespace G13
|
||||
|
||||
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#if 0
|
||||
#include <boost/log/core/core.hpp>
|
||||
#include <boost/log/attributes.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/log/core/core.hpp>
|
||||
#include <boost/log/expressions.hpp>
|
||||
#include <boost/log/utility/setup.hpp>
|
||||
#include <boost/log/utility/setup/console.hpp>
|
||||
#include <boost/log/expressions/formatters/stream.hpp>
|
||||
#include <boost/log/support/date_time.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/log/utility/setup.hpp>
|
||||
#include <boost/log/utility/setup/console.hpp>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
@ -23,11 +23,10 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// Declare the supported options.
|
||||
po::options_description desc("Allowed options");
|
||||
desc.add_options()
|
||||
("help", "produce help message")
|
||||
;
|
||||
desc.add_options()("help", "produce help message");
|
||||
std::vector<std::string> sopt_names;
|
||||
auto add_string_option = [ &sopt_names, &desc ]( const char *name, const char *description ) {
|
||||
auto add_string_option = [&sopt_names, &desc](const char *name,
|
||||
const char *description) {
|
||||
desc.add_options()(name, po::value<std::string>(), description);
|
||||
sopt_names.push_back(name);
|
||||
};
|
||||
@ -41,8 +40,9 @@ int main(int argc, char *argv[]) {
|
||||
po::positional_options_description p;
|
||||
p.add("logo", -1);
|
||||
po::variables_map vm;
|
||||
po::store(po::command_line_parser(argc, argv).
|
||||
options(desc).positional(p).run(), vm);
|
||||
po::store(
|
||||
po::command_line_parser(argc, argv).options(desc).positional(p).run(),
|
||||
vm);
|
||||
po::notify(vm);
|
||||
|
||||
if (vm.count("help")) {
|
||||
@ -67,4 +67,3 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
manager.run();
|
||||
}
|
||||
|
||||
|
@ -3,33 +3,26 @@
|
||||
*/
|
||||
#include "g13.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace G13 {
|
||||
|
||||
|
||||
// *************************************************************************
|
||||
|
||||
void G13_Device::parse_joystick(unsigned char *buf) {
|
||||
_stick.parse_joystick(buf);
|
||||
}
|
||||
|
||||
G13_Stick::G13_Stick( G13_Device &keypad ) :
|
||||
_keypad(keypad),
|
||||
_bounds(0,0,255,255),
|
||||
_center_pos(127,127),
|
||||
_north_pos( 127, 0 )
|
||||
{
|
||||
G13_Stick::G13_Stick(G13_Device &keypad)
|
||||
: _keypad(keypad), _bounds(0, 0, 255, 255), _center_pos(127, 127),
|
||||
_north_pos(127, 0) {
|
||||
_stick_mode = STICK_KEYS;
|
||||
|
||||
auto add_zone = [this, &keypad]( const std::string &name, double x1, double y1, double x2, double y2 ) {
|
||||
_zones.push_back( G13_StickZone( *this, "STICK_"+name,
|
||||
G13_ZoneBounds( x1, y1, x2, y2 ),
|
||||
G13_ActionPtr(
|
||||
new G13_Action_Keys( keypad, "KEY_" + name ) )
|
||||
)
|
||||
);
|
||||
auto add_zone = [this, &keypad](const std::string &name, double x1, double y1,
|
||||
double x2, double y2) {
|
||||
_zones.push_back(G13_StickZone(
|
||||
*this, "STICK_" + name, G13_ZoneBounds(x1, y1, x2, y2),
|
||||
G13_ActionPtr(new G13_Action_Keys(keypad, "KEY_" + name))));
|
||||
};
|
||||
|
||||
add_zone("UP", 0.0, 0.1, 1.0, 0.3);
|
||||
@ -38,7 +31,6 @@ G13_Stick::G13_Stick( G13_Device &keypad ) :
|
||||
add_zone("RIGHT", 0.8, 0.0, 1.0, 1.0);
|
||||
add_zone("PAGEUP", 0.0, 0.0, 1.0, 0.1);
|
||||
add_zone("PAGEDOWN", 0.0, 0.9, 1.0, 1.0);
|
||||
|
||||
}
|
||||
|
||||
G13_StickZone *G13_Stick::zone(const std::string &name, bool create) {
|
||||
@ -49,7 +41,8 @@ G13_StickZone *G13_Stick::zone( const std::string &name, bool create ) {
|
||||
}
|
||||
}
|
||||
if (create) {
|
||||
_zones.push_back( G13_StickZone( *this, name, G13_ZoneBounds( 0.0, 0.0, 0.0, 0.0 ) ) );
|
||||
_zones.push_back(
|
||||
G13_StickZone(*this, name, G13_ZoneBounds(0.0, 0.0, 0.0, 0.0)));
|
||||
return zone(name);
|
||||
}
|
||||
return 0;
|
||||
@ -58,7 +51,8 @@ G13_StickZone *G13_Stick::zone( const std::string &name, bool create ) {
|
||||
void G13_Stick::set_mode(stick_mode_t m) {
|
||||
if (m == _stick_mode)
|
||||
return;
|
||||
if( _stick_mode == STICK_CALCENTER || _stick_mode == STICK_CALBOUNDS || _stick_mode == STICK_CALNORTH ) {
|
||||
if (_stick_mode == STICK_CALCENTER || _stick_mode == STICK_CALBOUNDS ||
|
||||
_stick_mode == STICK_CALNORTH) {
|
||||
_recalc_calibrated();
|
||||
}
|
||||
_stick_mode = m;
|
||||
@ -70,13 +64,11 @@ void G13_Stick::set_mode( stick_mode_t m ) {
|
||||
}
|
||||
}
|
||||
|
||||
void G13_Stick::_recalc_calibrated() {
|
||||
}
|
||||
void G13_Stick::_recalc_calibrated() {}
|
||||
|
||||
void G13_Stick::remove_zone(const G13_StickZone &zone) {
|
||||
G13_StickZone target(zone);
|
||||
_zones.erase(std::remove(_zones.begin(), _zones.end(), target), _zones.end());
|
||||
|
||||
}
|
||||
void G13_Stick::dump(std::ostream &out) const {
|
||||
BOOST_FOREACH (const G13_StickZone &zone, _zones) {
|
||||
@ -95,7 +87,8 @@ void G13_StickZone::dump( std::ostream & out ) const {
|
||||
}
|
||||
|
||||
void G13_StickZone::test(const G13_ZoneCoord &loc) {
|
||||
if( !_action ) return;
|
||||
if (!_action)
|
||||
return;
|
||||
bool prior_active = _active;
|
||||
_active = _bounds.contains(loc);
|
||||
if (!_active) {
|
||||
@ -109,11 +102,10 @@ 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 ), _bounds(b), _active(false)
|
||||
{
|
||||
G13_StickZone::G13_StickZone(G13_Stick &stick, const std::string &name,
|
||||
const G13_ZoneBounds &b, G13_ActionPtr action)
|
||||
: G13_Actionable<G13_Stick>(stick, name), _bounds(b), _active(false) {
|
||||
set_action(action);
|
||||
|
||||
}
|
||||
|
||||
void G13_Stick::parse_joystick(unsigned char *buf) {
|
||||
@ -157,7 +149,8 @@ void G13_Stick::parse_joystick(unsigned char *buf) {
|
||||
dy = 1.0 - dy;
|
||||
}
|
||||
|
||||
G13_LOG( trace, "x=" << _current_pos.x << " y=" << _current_pos.y << " dx=" << dx << " dy=" << dy );
|
||||
G13_LOG(trace, "x=" << _current_pos.x << " y=" << _current_pos.y
|
||||
<< " dx=" << dx << " dy=" << dy);
|
||||
G13_ZoneCoord jpos(dx, dy);
|
||||
if (_stick_mode == STICK_ABSOLUTE) {
|
||||
_keypad.send_event(EV_ABS, ABS_X, _current_pos.x);
|
||||
@ -165,9 +158,7 @@ void G13_Stick::parse_joystick(unsigned char *buf) {
|
||||
|
||||
} else if (_stick_mode == STICK_KEYS) {
|
||||
|
||||
BOOST_FOREACH( G13_StickZone &zone, _zones ) {
|
||||
zone.test(jpos);
|
||||
}
|
||||
BOOST_FOREACH (G13_StickZone &zone, _zones) { zone.test(jpos); }
|
||||
return;
|
||||
|
||||
} else {
|
||||
@ -177,4 +168,3 @@ void G13_Stick::parse_joystick(unsigned char *buf) {
|
||||
}
|
||||
|
||||
} // namespace G13
|
||||
|
||||
|
@ -41,10 +41,18 @@ void string_repr_out::write_on( std::ostream &o ) const {
|
||||
while (cp < end) {
|
||||
|
||||
switch (*cp) {
|
||||
case '\n': o << "\\n"; break;
|
||||
case '\r': o << "\\r"; break;
|
||||
case '\0': o << "\\0"; break;
|
||||
case '\t': o << "\\t"; break;
|
||||
case '\n':
|
||||
o << "\\n";
|
||||
break;
|
||||
case '\r':
|
||||
o << "\\r";
|
||||
break;
|
||||
case '\0':
|
||||
o << "\\0";
|
||||
break;
|
||||
case '\t':
|
||||
o << "\\t";
|
||||
break;
|
||||
case '\\':
|
||||
case '\'':
|
||||
case '\"':
|
||||
@ -67,10 +75,6 @@ void string_repr_out::write_on( std::ostream &o ) const {
|
||||
o << "\"";
|
||||
};
|
||||
|
||||
|
||||
}; // namespace Helper
|
||||
|
||||
|
||||
// *************************************************************************
|
||||
|
||||
|
||||
|
@ -31,21 +31,21 @@
|
||||
#ifndef __HELPER_HPP__
|
||||
#define __HELPER_HPP__
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/preprocessor/seq.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/seq.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
#include <exception>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
// *************************************************************************
|
||||
|
||||
@ -63,8 +63,7 @@ inline std::ostream &operator <<( std::ostream & o, const string_repr_out & sro
|
||||
return o;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const T &repr( const T &v ) { return v; }
|
||||
template <class T> inline const T &repr(const T &v) { return v; }
|
||||
|
||||
inline string_repr_out repr(const char *s) { return string_repr_out(s); }
|
||||
inline string_repr_out repr(const std::string &s) { return string_repr_out(s); }
|
||||
@ -73,12 +72,12 @@ inline string_repr_out repr( const std::string & s ) { return string_repr_out(s)
|
||||
|
||||
class NotFoundException : public std::exception {
|
||||
public:
|
||||
|
||||
const char *what() throw();
|
||||
};
|
||||
|
||||
template <class KEY_T, class VAL_T>
|
||||
inline const VAL_T &find_or_throw( const std::map<KEY_T,VAL_T> &m, const KEY_T &target ) {
|
||||
inline const VAL_T &find_or_throw(const std::map<KEY_T, VAL_T> &m,
|
||||
const KEY_T &target) {
|
||||
auto i = m.find(target);
|
||||
if (i == m.end()) {
|
||||
throw NotFoundException();
|
||||
@ -95,17 +94,14 @@ inline VAL_T &find_or_throw( std::map<KEY_T,VAL_T> &m, const KEY_T &target ) {
|
||||
return i->second;
|
||||
};
|
||||
|
||||
|
||||
// *************************************************************************
|
||||
|
||||
template <class T>
|
||||
class Coord {
|
||||
template <class T> class Coord {
|
||||
public:
|
||||
Coord() : x(), y() {}
|
||||
Coord(T _x, T _y) : x(_x), y(_y) {}
|
||||
T x;
|
||||
T y;
|
||||
|
||||
};
|
||||
|
||||
template <class T>
|
||||
@ -114,9 +110,7 @@ std::ostream &operator<<( std::ostream &o, const Coord<T> &c ) {
|
||||
return o;
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class Bounds {
|
||||
template <class T> class Bounds {
|
||||
public:
|
||||
typedef Coord<T> CT;
|
||||
Bounds(const CT &_tl, const CT &_br) : tl(_tl), br(_br) {}
|
||||
@ -127,10 +121,14 @@ public:
|
||||
}
|
||||
|
||||
void expand(const CT &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;
|
||||
}
|
||||
CT tl;
|
||||
CT br;
|
||||
@ -138,7 +136,8 @@ 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;
|
||||
};
|
||||
|
||||
@ -159,14 +158,12 @@ inline const char *advance_ws(CCP &source, std::string &dest) {
|
||||
|
||||
// *************************************************************************
|
||||
|
||||
template <class MAP_T>
|
||||
struct _map_keys_out {
|
||||
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;
|
||||
std::string sep;
|
||||
};
|
||||
|
||||
|
||||
template <class STREAM_T, class MAP_T>
|
||||
STREAM_T &operator<<(STREAM_T &o, const _map_keys_out<MAP_T> &_mko) {
|
||||
bool first = true;
|
||||
@ -182,7 +179,8 @@ STREAM_T &operator <<( STREAM_T &o, const _map_keys_out<MAP_T> &_mko ) {
|
||||
};
|
||||
|
||||
template <class MAP_T>
|
||||
_map_keys_out<MAP_T> map_keys_out( const MAP_T &c, const std::string &sep = " " ) {
|
||||
_map_keys_out<MAP_T> map_keys_out(const MAP_T &c,
|
||||
const std::string &sep = " ") {
|
||||
return _map_keys_out<MAP_T>(c, sep);
|
||||
};
|
||||
|
||||
@ -190,8 +188,6 @@ _map_keys_out<MAP_T> map_keys_out( const MAP_T &c, const std::string &sep = " "
|
||||
|
||||
}; // namespace Helper
|
||||
|
||||
|
||||
// *************************************************************************
|
||||
|
||||
|
||||
#endif // __HELPER_HPP__
|
||||
|
141
g13d/logo.h
141
g13d/logo.h
@ -1,66 +1,85 @@
|
||||
#ifndef G13_LOGO_H
|
||||
#define G13_LOGO_H
|
||||
static unsigned char g13_logo[160 * 48 / 8] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xc0, 0xe0, 0xe0, 0xf0,
|
||||
0xf0, 0xf8, 0x78, 0x78, 0x7c, 0x3c, 0x3c, 0x3e, 0x3e, 0x1e, 0x1e, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f,
|
||||
0xdf, 0xdf, 0x9f, 0x9f, 0x9f, 0xbe, 0x3e, 0x7e, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x20, 0x90, 0xe8, 0x70, 0x94, 0x28, 0x0a, 0x0c, 0x12, 0x04,
|
||||
0x06, 0x10, 0x14, 0x10, 0x10, 0x48, 0x40, 0x00, 0x40, 0x00, 0x00, 0x00, 0x80, 0x00, 0x40, 0x00,
|
||||
0x48, 0x10, 0x0c, 0x10, 0x18, 0x04, 0x18, 0x08, 0x28, 0x5c, 0x30, 0xe8, 0x90, 0x20, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0xc0, 0xf0, 0xf8, 0x7c, 0x3e, 0x1e, 0x0f, 0x0f, 0x07, 0x03, 0x83, 0x81, 0x81,
|
||||
0x00, 0x00, 0x00, 0x00, 0xe0, 0xe0, 0x80, 0x00, 0xe0, 0xe0, 0x00, 0x18, 0x38, 0xf0, 0xf0, 0xf8,
|
||||
0x8b, 0x07, 0x04, 0x04, 0x07, 0x0f, 0x0f, 0x1f, 0x1e, 0x3e, 0x7c, 0xf8, 0xf0, 0xc0, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xf0, 0xf0, 0xf8, 0xf8, 0xfc, 0xfc, 0x7c, 0x7c,
|
||||
0x3c, 0x3c, 0x3c, 0x3c, 0x7c, 0x7c, 0x78, 0xf8, 0xfc, 0xfc, 0xfc, 0x80, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x60, 0x70, 0xf0, 0xf0, 0xf0, 0xf0, 0xf8, 0xf0, 0xf8, 0xf8, 0x38, 0x10, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xe0, 0xf8, 0xf8, 0x78, 0x3c, 0x3c, 0x7c, 0xfc, 0xfc, 0xf8, 0xf8, 0xf0,
|
||||
0xe0, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x1f, 0xff, 0xe4, 0x80, 0x80, 0x80, 0xe0, 0xd0, 0x28,
|
||||
0x34, 0x18, 0x1d, 0x1e, 0xcf, 0x0f, 0x6f, 0x0f, 0x0f, 0x87, 0x2e, 0x01, 0x01, 0x65, 0x03, 0xcf,
|
||||
0x4f, 0x0f, 0x1e, 0x1d, 0x38, 0x60, 0xd0, 0xe0, 0x80, 0xe0, 0xcb, 0xfd, 0x3f, 0x80, 0x35, 0x00,
|
||||
0xf0, 0xfe, 0xff, 0x0f, 0x03, 0x01, 0x3e, 0xfe, 0xfe, 0x00, 0x08, 0xfb, 0xfb, 0x00, 0xff, 0xff,
|
||||
0x03, 0x1f, 0xff, 0xfe, 0x0f, 0x1f, 0x1f, 0x1c, 0x1f, 0x3f, 0x98, 0x80, 0x4f, 0xe7, 0x61, 0x01,
|
||||
0x83, 0xc2, 0xfc, 0xfc, 0xfc, 0x80, 0xf0, 0xf0, 0xd0, 0xf0, 0x30, 0x00, 0x03, 0xff, 0xff, 0xfc,
|
||||
0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00,
|
||||
0x00, 0x40, 0x70, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf1, 0xf3, 0xf3, 0xf0, 0xf0, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x18, 0x18, 0x38, 0x3e, 0xff, 0xff, 0xff, 0xf7, 0xe7,
|
||||
0xc1, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x01, 0x09, 0xc3, 0x3f, 0x03, 0x00, 0x00,
|
||||
0x80, 0x80, 0x40, 0x10, 0x44, 0x00, 0x00, 0x02, 0x02, 0x03, 0x00, 0xc0, 0x01, 0x00, 0x40, 0x03,
|
||||
0x06, 0x17, 0x30, 0x40, 0x20, 0x80, 0x21, 0x03, 0x4b, 0x23, 0x01, 0x04, 0x02, 0x00, 0x00, 0x00,
|
||||
0x07, 0x7f, 0xfe, 0xe0, 0x80, 0x00, 0x00, 0x3f, 0x3f, 0x00, 0x00, 0x07, 0x03, 0x00, 0xf4, 0xfe,
|
||||
0xf4, 0x7c, 0xfc, 0xfc, 0x18, 0xfc, 0xfc, 0xf0, 0x1e, 0xbf, 0xf7, 0xe3, 0x1f, 0xff, 0xff, 0x3e,
|
||||
0x7f, 0x77, 0x39, 0x7f, 0x7f, 0x03, 0x0f, 0x0f, 0x0c, 0x0e, 0x86, 0xe0, 0xf8, 0x7f, 0x1f, 0x03,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x0f, 0x1f, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xf8, 0xf0,
|
||||
0xe0, 0xe0, 0xe0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00,
|
||||
0x80, 0xc0, 0xc0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xc0, 0xc0, 0x80, 0x00,
|
||||
0x00, 0x00, 0x18, 0x78, 0xf8, 0xf0, 0xf0, 0xf0, 0xf0, 0xf8, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x7f,
|
||||
0x3f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x0d, 0xe1, 0x00,
|
||||
0x00, 0x07, 0x10, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x21, 0x00, 0x41, 0x41, 0x00,
|
||||
0x40, 0x00, 0x40, 0x48, 0x30, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x03, 0x0f, 0x1e, 0x3e, 0x7c, 0x78, 0xf0, 0xe0, 0xe0, 0xc0, 0xc0, 0xc7, 0x8f,
|
||||
0x8f, 0x80, 0x87, 0x07, 0x00, 0x00, 0x07, 0x07, 0x83, 0x83, 0x83, 0x81, 0x80, 0x80, 0xc0, 0xc0,
|
||||
0xc0, 0xe0, 0xe0, 0xf0, 0x70, 0x78, 0x3c, 0x1c, 0x0e, 0x0f, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
|
||||
0x04, 0x08, 0x00, 0x00, 0x01, 0x01, 0x0e, 0x58, 0x3c, 0x38, 0xe0, 0xc0, 0xc0, 0xe2, 0xe2, 0xa2,
|
||||
0x9a, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x03,
|
||||
0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x03, 0x01, 0x03, 0x01,
|
||||
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80,
|
||||
0xc0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf8, 0x78, 0x78, 0x7c, 0x3c, 0x3c, 0x3e,
|
||||
0x3e, 0x1e, 0x1e, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0xdf, 0xdf, 0x9f, 0x9f,
|
||||
0x9f, 0xbe, 0x3e, 0x7e, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x20, 0x90,
|
||||
0xe8, 0x70, 0x94, 0x28, 0x0a, 0x0c, 0x12, 0x04, 0x06, 0x10, 0x14, 0x10,
|
||||
0x10, 0x48, 0x40, 0x00, 0x40, 0x00, 0x00, 0x00, 0x80, 0x00, 0x40, 0x00,
|
||||
0x48, 0x10, 0x0c, 0x10, 0x18, 0x04, 0x18, 0x08, 0x28, 0x5c, 0x30, 0xe8,
|
||||
0x90, 0x20, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xf0, 0xf8, 0x7c, 0x3e,
|
||||
0x1e, 0x0f, 0x0f, 0x07, 0x03, 0x83, 0x81, 0x81, 0x00, 0x00, 0x00, 0x00,
|
||||
0xe0, 0xe0, 0x80, 0x00, 0xe0, 0xe0, 0x00, 0x18, 0x38, 0xf0, 0xf0, 0xf8,
|
||||
0x8b, 0x07, 0x04, 0x04, 0x07, 0x0f, 0x0f, 0x1f, 0x1e, 0x3e, 0x7c, 0xf8,
|
||||
0xf0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0,
|
||||
0xf0, 0xf0, 0xf8, 0xf8, 0xfc, 0xfc, 0x7c, 0x7c, 0x3c, 0x3c, 0x3c, 0x3c,
|
||||
0x7c, 0x7c, 0x78, 0xf8, 0xfc, 0xfc, 0xfc, 0x80, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x60, 0x70, 0xf0, 0xf0, 0xf0, 0xf0, 0xf8, 0xf0, 0xf8, 0xf8, 0x38,
|
||||
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xf8, 0xf8, 0x78,
|
||||
0x3c, 0x3c, 0x7c, 0xfc, 0xfc, 0xf8, 0xf8, 0xf0, 0xe0, 0x00, 0x00, 0x00,
|
||||
0x00, 0xb0, 0x00, 0x1f, 0xff, 0xe4, 0x80, 0x80, 0x80, 0xe0, 0xd0, 0x28,
|
||||
0x34, 0x18, 0x1d, 0x1e, 0xcf, 0x0f, 0x6f, 0x0f, 0x0f, 0x87, 0x2e, 0x01,
|
||||
0x01, 0x65, 0x03, 0xcf, 0x4f, 0x0f, 0x1e, 0x1d, 0x38, 0x60, 0xd0, 0xe0,
|
||||
0x80, 0xe0, 0xcb, 0xfd, 0x3f, 0x80, 0x35, 0x00, 0xf0, 0xfe, 0xff, 0x0f,
|
||||
0x03, 0x01, 0x3e, 0xfe, 0xfe, 0x00, 0x08, 0xfb, 0xfb, 0x00, 0xff, 0xff,
|
||||
0x03, 0x1f, 0xff, 0xfe, 0x0f, 0x1f, 0x1f, 0x1c, 0x1f, 0x3f, 0x98, 0x80,
|
||||
0x4f, 0xe7, 0x61, 0x01, 0x83, 0xc2, 0xfc, 0xfc, 0xfc, 0x80, 0xf0, 0xf0,
|
||||
0xd0, 0xf0, 0x30, 0x00, 0x03, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00,
|
||||
0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00,
|
||||
0x00, 0x40, 0x70, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf1, 0xf3, 0xf3, 0xf0,
|
||||
0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x01, 0x01, 0x18, 0x18, 0x38, 0x3e, 0xff, 0xff, 0xff, 0xf7, 0xe7,
|
||||
0xc1, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x01, 0x09, 0xc3,
|
||||
0x3f, 0x03, 0x00, 0x00, 0x80, 0x80, 0x40, 0x10, 0x44, 0x00, 0x00, 0x02,
|
||||
0x02, 0x03, 0x00, 0xc0, 0x01, 0x00, 0x40, 0x03, 0x06, 0x17, 0x30, 0x40,
|
||||
0x20, 0x80, 0x21, 0x03, 0x4b, 0x23, 0x01, 0x04, 0x02, 0x00, 0x00, 0x00,
|
||||
0x07, 0x7f, 0xfe, 0xe0, 0x80, 0x00, 0x00, 0x3f, 0x3f, 0x00, 0x00, 0x07,
|
||||
0x03, 0x00, 0xf4, 0xfe, 0xf4, 0x7c, 0xfc, 0xfc, 0x18, 0xfc, 0xfc, 0xf0,
|
||||
0x1e, 0xbf, 0xf7, 0xe3, 0x1f, 0xff, 0xff, 0x3e, 0x7f, 0x77, 0x39, 0x7f,
|
||||
0x7f, 0x03, 0x0f, 0x0f, 0x0c, 0x0e, 0x86, 0xe0, 0xf8, 0x7f, 0x1f, 0x03,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x0f, 0x1f, 0x7f, 0x7f, 0xff, 0xff, 0xff,
|
||||
0xff, 0xfe, 0xf8, 0xf0, 0xe0, 0xe0, 0xe0, 0xf0, 0xff, 0xff, 0xff, 0xff,
|
||||
0x7f, 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xc0, 0xf0,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xc0, 0xc0, 0x80, 0x00,
|
||||
0x00, 0x00, 0x18, 0x78, 0xf8, 0xf0, 0xf0, 0xf0, 0xf0, 0xf8, 0xfc, 0xff,
|
||||
0xff, 0xff, 0xff, 0x7f, 0x3f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x02, 0x02, 0x0d, 0xe1, 0x00, 0x00, 0x07, 0x10, 0x20,
|
||||
0x40, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x21, 0x00, 0x41, 0x41, 0x00,
|
||||
0x40, 0x00, 0x40, 0x48, 0x30, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x0f, 0x1e, 0x3e, 0x7c,
|
||||
0x78, 0xf0, 0xe0, 0xe0, 0xc0, 0xc0, 0xc7, 0x8f, 0x8f, 0x80, 0x87, 0x07,
|
||||
0x00, 0x00, 0x07, 0x07, 0x83, 0x83, 0x83, 0x81, 0x80, 0x80, 0xc0, 0xc0,
|
||||
0xc0, 0xe0, 0xe0, 0xf0, 0x70, 0x78, 0x3c, 0x1c, 0x0e, 0x0f, 0x07, 0x03,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
|
||||
0x04, 0x08, 0x00, 0x00, 0x01, 0x01, 0x0e, 0x58, 0x3c, 0x38, 0xe0, 0xc0,
|
||||
0xc0, 0xe2, 0xe2, 0xa2, 0x9a, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x03,
|
||||
0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03,
|
||||
0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x01, 0x00, 0x01, 0x03, 0x01, 0x03, 0x01, 0x03, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
#endif
|
||||
/* G13_LOGO_H */
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#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
|
||||
|
||||
@ -23,7 +23,8 @@ int main(int argc, char *argv[]) {
|
||||
return -1;
|
||||
}
|
||||
if (w != 160 || h != 43) {
|
||||
cerr << "incorrect width / height, mandated: 160x43, found: " << w << "x" << h << endl;
|
||||
cerr << "incorrect width / height, mandated: 160x43, found: " << w << "x"
|
||||
<< h << endl;
|
||||
return -1;
|
||||
}
|
||||
cin >> noskipws;
|
||||
@ -46,7 +47,8 @@ int main(int argc, char *argv[]) {
|
||||
i++;
|
||||
}
|
||||
if (i != 160 * 43 / 8) {
|
||||
cerr << "wrong number of bytes, expected " << 160*43/8 << ", got " << i << endl;
|
||||
cerr << "wrong number of bytes, expected " << 160 * 43 / 8 << ", got " << i
|
||||
<< endl;
|
||||
}
|
||||
for (int i = 0; i < 160 * 48 / 8; i++) {
|
||||
cout << hex << (char)buf[i];
|
||||
|
Loading…
Reference in New Issue
Block a user