Repository: ponty/framebuffer-vncserver
Branch: master
Commit: 1963e57bebfd
Files: 58
Total size: 115.8 KB
Directory structure:
gitextract_gwh7gede/
├── .git/
│ ├── HEAD
│ ├── config
│ ├── description
│ ├── hooks/
│ │ ├── applypatch-msg.sample
│ │ ├── commit-msg.sample
│ │ ├── fsmonitor-watchman.sample
│ │ ├── post-update.sample
│ │ ├── pre-applypatch.sample
│ │ ├── pre-commit.sample
│ │ ├── pre-merge-commit.sample
│ │ ├── pre-push.sample
│ │ ├── pre-rebase.sample
│ │ ├── pre-receive.sample
│ │ ├── prepare-commit-msg.sample
│ │ ├── push-to-checkout.sample
│ │ ├── sendemail-validate.sample
│ │ └── update.sample
│ ├── index
│ ├── info/
│ │ └── exclude
│ ├── logs/
│ │ ├── HEAD
│ │ └── refs/
│ │ ├── heads/
│ │ │ └── master
│ │ └── remotes/
│ │ └── origin/
│ │ └── HEAD
│ ├── objects/
│ │ └── pack/
│ │ ├── pack-bef8852657c06b106e38622c43f30aebfe12ac48.idx
│ │ ├── pack-bef8852657c06b106e38622c43f30aebfe12ac48.pack
│ │ ├── pack-bef8852657c06b106e38622c43f30aebfe12ac48.promisor
│ │ └── pack-bef8852657c06b106e38622c43f30aebfe12ac48.rev
│ ├── packed-refs
│ ├── refs/
│ │ ├── heads/
│ │ │ └── master
│ │ └── remotes/
│ │ └── origin/
│ │ └── HEAD
│ └── shallow
├── .github/
│ └── workflows/
│ └── main.yml
├── .gitignore
├── .travis.yml.bak
├── CMakeLists.txt
├── Dockerfile
├── LICENSE
├── README.md
├── Vagrantfile
├── Vagrantfile.20.04.rb
├── deployment.pri
├── fbvnc.service
├── format-code.sh
├── framebuffer-vncserver.pro
├── gradient.py
├── src/
│ ├── framebuffer-vncserver.c
│ ├── keyboard.c
│ ├── keyboard.h
│ ├── logging.h
│ ├── mouse.c
│ ├── mouse.h
│ ├── touch.c
│ └── touch.h
├── tests/
│ └── vfb/
│ ├── Makefile
│ ├── README
│ └── ins.sh
├── vagrant.sh
├── vfb.py
└── yocto/
└── framebuffer-vncserver_git.bb
================================================
FILE CONTENTS
================================================
================================================
FILE: .git/HEAD
================================================
ref: refs/heads/master
================================================
FILE: .git/config
================================================
[core]
repositoryformatversion = 1
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://github.com/ponty/framebuffer-vncserver
tagOpt = --no-tags
fetch = +refs/heads/master:refs/remotes/origin/master
promisor = true
partialclonefilter = blob:limit=1048576
[branch "master"]
remote = origin
merge = refs/heads/master
================================================
FILE: .git/description
================================================
Unnamed repository; edit this file 'description' to name the repository.
================================================
FILE: .git/hooks/applypatch-msg.sample
================================================
#!/bin/sh
#
# An example hook script to check the commit log message taken by
# applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit. The hook is
# allowed to edit the commit message file.
#
# To enable this hook, rename this file to "applypatch-msg".
. git-sh-setup
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
:
================================================
FILE: .git/hooks/commit-msg.sample
================================================
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".
# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
# This example catches duplicate Signed-off-by lines.
test "" = "$(grep '^Signed-off-by: ' "$1" |
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
echo >&2 Duplicate Signed-off-by lines.
exit 1
}
================================================
FILE: .git/hooks/fsmonitor-watchman.sample
================================================
#!/usr/bin/perl
use strict;
use warnings;
use IPC::Open2;
# An example hook script to integrate Watchman
# (https://facebook.github.io/watchman/) with git to speed up detecting
# new and modified files.
#
# The hook is passed a version (currently 2) and last update token
# formatted as a string and outputs to stdout a new update token and
# all files that have been modified since the update token. Paths must
# be relative to the root of the working tree and separated by a single NUL.
#
# To enable this hook, rename this file to "query-watchman" and set
# 'git config core.fsmonitor .git/hooks/query-watchman'
#
my ($version, $last_update_token) = @ARGV;
# Uncomment for debugging
# print STDERR "$0 $version $last_update_token\n";
# Check the hook interface version
if ($version ne 2) {
die "Unsupported query-fsmonitor hook version '$version'.\n" .
"Falling back to scanning...\n";
}
my $git_work_tree = get_working_dir();
my $retry = 1;
my $json_pkg;
eval {
require JSON::XS;
$json_pkg = "JSON::XS";
1;
} or do {
require JSON::PP;
$json_pkg = "JSON::PP";
};
launch_watchman();
sub launch_watchman {
my $o = watchman_query();
if (is_work_tree_watched($o)) {
output_result($o->{clock}, @{$o->{files}});
}
}
sub output_result {
my ($clockid, @files) = @_;
# Uncomment for debugging watchman output
# open (my $fh, ">", ".git/watchman-output.out");
# binmode $fh, ":utf8";
# print $fh "$clockid\n@files\n";
# close $fh;
binmode STDOUT, ":utf8";
print $clockid;
print "\0";
local $, = "\0";
print @files;
}
sub watchman_clock {
my $response = qx/watchman clock "$git_work_tree"/;
die "Failed to get clock id on '$git_work_tree'.\n" .
"Falling back to scanning...\n" if $? != 0;
return $json_pkg->new->utf8->decode($response);
}
sub watchman_query {
my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty')
or die "open2() failed: $!\n" .
"Falling back to scanning...\n";
# In the query expression below we're asking for names of files that
# changed since $last_update_token but not from the .git folder.
#
# To accomplish this, we're using the "since" generator to use the
# recency index to select candidate nodes and "fields" to limit the
# output to file names only. Then we're using the "expression" term to
# further constrain the results.
my $last_update_line = "";
if (substr($last_update_token, 0, 1) eq "c") {
$last_update_token = "\"$last_update_token\"";
$last_update_line = qq[\n"since": $last_update_token,];
}
my $query = <<" END";
["query", "$git_work_tree", {$last_update_line
"fields": ["name"],
"expression": ["not", ["dirname", ".git"]]
}]
END
# Uncomment for debugging the watchman query
# open (my $fh, ">", ".git/watchman-query.json");
# print $fh $query;
# close $fh;
print CHLD_IN $query;
close CHLD_IN;
my $response = do {local $/; <CHLD_OUT>};
# Uncomment for debugging the watch response
# open ($fh, ">", ".git/watchman-response.json");
# print $fh $response;
# close $fh;
die "Watchman: command returned no output.\n" .
"Falling back to scanning...\n" if $response eq "";
die "Watchman: command returned invalid output: $response\n" .
"Falling back to scanning...\n" unless $response =~ /^\{/;
return $json_pkg->new->utf8->decode($response);
}
sub is_work_tree_watched {
my ($output) = @_;
my $error = $output->{error};
if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) {
$retry--;
my $response = qx/watchman watch "$git_work_tree"/;
die "Failed to make watchman watch '$git_work_tree'.\n" .
"Falling back to scanning...\n" if $? != 0;
$output = $json_pkg->new->utf8->decode($response);
$error = $output->{error};
die "Watchman: $error.\n" .
"Falling back to scanning...\n" if $error;
# Uncomment for debugging watchman output
# open (my $fh, ">", ".git/watchman-output.out");
# close $fh;
# Watchman will always return all files on the first query so
# return the fast "everything is dirty" flag to git and do the
# Watchman query just to get it over with now so we won't pay
# the cost in git to look up each individual file.
my $o = watchman_clock();
$error = $output->{error};
die "Watchman: $error.\n" .
"Falling back to scanning...\n" if $error;
output_result($o->{clock}, ("/"));
$last_update_token = $o->{clock};
eval { launch_watchman() };
return 0;
}
die "Watchman: $error.\n" .
"Falling back to scanning...\n" if $error;
return 1;
}
sub get_working_dir {
my $working_dir;
if ($^O =~ 'msys' || $^O =~ 'cygwin') {
$working_dir = Win32::GetCwd();
$working_dir =~ tr/\\/\//;
} else {
require Cwd;
$working_dir = Cwd::cwd();
}
return $working_dir;
}
================================================
FILE: .git/hooks/post-update.sample
================================================
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
exec git update-server-info
================================================
FILE: .git/hooks/pre-applypatch.sample
================================================
#!/bin/sh
#
# An example hook script to verify what is about to be committed
# by applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-applypatch".
. git-sh-setup
precommit="$(git rev-parse --git-path hooks/pre-commit)"
test -x "$precommit" && exec "$precommit" ${1+"$@"}
:
================================================
FILE: .git/hooks/pre-commit.sample
================================================
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi
# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --type=bool hooks.allownonascii)
# Redirect output to stderr.
exec 1>&2
# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff-index --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name.
This can cause problems if you want to work with people on other platforms.
To be portable it is advisable to rename the file.
If you know what you are doing you can disable this check using:
git config hooks.allownonascii true
EOF
exit 1
fi
# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --
================================================
FILE: .git/hooks/pre-merge-commit.sample
================================================
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git merge" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message to
# stderr if it wants to stop the merge commit.
#
# To enable this hook, rename this file to "pre-merge-commit".
. git-sh-setup
test -x "$GIT_DIR/hooks/pre-commit" &&
exec "$GIT_DIR/hooks/pre-commit"
:
================================================
FILE: .git/hooks/pre-push.sample
================================================
#!/bin/sh
# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local oid> <remote ref> <remote oid>
#
# This sample shows how to prevent push of commits where the log message starts
# with "WIP" (work in progress).
remote="$1"
url="$2"
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
while read local_ref local_oid remote_ref remote_oid
do
if test "$local_oid" = "$zero"
then
# Handle delete
:
else
if test "$remote_oid" = "$zero"
then
# New branch, examine all commits
range="$local_oid"
else
# Update to existing branch, examine new commits
range="$remote_oid..$local_oid"
fi
# Check for WIP commit
commit=$(git rev-list -n 1 --grep '^WIP' "$range")
if test -n "$commit"
then
echo >&2 "Found WIP commit in $local_ref, not pushing"
exit 1
fi
fi
done
exit 0
================================================
FILE: .git/hooks/pre-rebase.sample
================================================
#!/bin/sh
#
# Copyright (c) 2006, 2008 Junio C Hamano
#
# The "pre-rebase" hook is run just before "git rebase" starts doing
# its job, and can prevent the command from running by exiting with
# non-zero status.
#
# The hook is called with the following parameters:
#
# $1 -- the upstream the series was forked from.
# $2 -- the branch being rebased (or empty when rebasing the current branch).
#
# This sample shows how to prevent topic branches that are already
# merged to 'next' branch from getting rebased, because allowing it
# would result in rebasing already published history.
publish=next
basebranch="$1"
if test "$#" = 2
then
topic="refs/heads/$2"
else
topic=`git symbolic-ref HEAD` ||
exit 0 ;# we do not interrupt rebasing detached HEAD
fi
case "$topic" in
refs/heads/??/*)
;;
*)
exit 0 ;# we do not interrupt others.
;;
esac
# Now we are dealing with a topic branch being rebased
# on top of master. Is it OK to rebase it?
# Does the topic really exist?
git show-ref -q "$topic" || {
echo >&2 "No such branch $topic"
exit 1
}
# Is topic fully merged to master?
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
if test -z "$not_in_master"
then
echo >&2 "$topic is fully merged to master; better remove it."
exit 1 ;# we could allow it, but there is no point.
fi
# Is topic ever merged to next? If so you should not be rebasing it.
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
only_next_2=`git rev-list ^master ${publish} | sort`
if test "$only_next_1" = "$only_next_2"
then
not_in_topic=`git rev-list "^$topic" master`
if test -z "$not_in_topic"
then
echo >&2 "$topic is already up to date with master"
exit 1 ;# we could allow it, but there is no point.
else
exit 0
fi
else
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
/usr/bin/perl -e '
my $topic = $ARGV[0];
my $msg = "* $topic has commits already merged to public branch:\n";
my (%not_in_next) = map {
/^([0-9a-f]+) /;
($1 => 1);
} split(/\n/, $ARGV[1]);
for my $elem (map {
/^([0-9a-f]+) (.*)$/;
[$1 => $2];
} split(/\n/, $ARGV[2])) {
if (!exists $not_in_next{$elem->[0]}) {
if ($msg) {
print STDERR $msg;
undef $msg;
}
print STDERR " $elem->[1]\n";
}
}
' "$topic" "$not_in_next" "$not_in_master"
exit 1
fi
<<\DOC_END
This sample hook safeguards topic branches that have been
published from being rewound.
The workflow assumed here is:
* Once a topic branch forks from "master", "master" is never
merged into it again (either directly or indirectly).
* Once a topic branch is fully cooked and merged into "master",
it is deleted. If you need to build on top of it to correct
earlier mistakes, a new topic branch is created by forking at
the tip of the "master". This is not strictly necessary, but
it makes it easier to keep your history simple.
* Whenever you need to test or publish your changes to topic
branches, merge them into "next" branch.
The script, being an example, hardcodes the publish branch name
to be "next", but it is trivial to make it configurable via
$GIT_DIR/config mechanism.
With this workflow, you would want to know:
(1) ... if a topic branch has ever been merged to "next". Young
topic branches can have stupid mistakes you would rather
clean up before publishing, and things that have not been
merged into other branches can be easily rebased without
affecting other people. But once it is published, you would
not want to rewind it.
(2) ... if a topic branch has been fully merged to "master".
Then you can delete it. More importantly, you should not
build on top of it -- other people may already want to
change things related to the topic as patches against your
"master", so if you need further changes, it is better to
fork the topic (perhaps with the same name) afresh from the
tip of "master".
Let's look at this example:
o---o---o---o---o---o---o---o---o---o "next"
/ / / /
/ a---a---b A / /
/ / / /
/ / c---c---c---c B /
/ / / \ /
/ / / b---b C \ /
/ / / / \ /
---o---o---o---o---o---o---o---o---o---o---o "master"
A, B and C are topic branches.
* A has one fix since it was merged up to "next".
* B has finished. It has been fully merged up to "master" and "next",
and is ready to be deleted.
* C has not merged to "next" at all.
We would want to allow C to be rebased, refuse A, and encourage
B to be deleted.
To compute (1):
git rev-list ^master ^topic next
git rev-list ^master next
if these match, topic has not merged in next at all.
To compute (2):
git rev-list master..topic
if this is empty, it is fully merged to "master".
DOC_END
================================================
FILE: .git/hooks/pre-receive.sample
================================================
#!/bin/sh
#
# An example hook script to make use of push options.
# The example simply echoes all push options that start with 'echoback='
# and rejects all pushes when the "reject" push option is used.
#
# To enable this hook, rename this file to "pre-receive".
if test -n "$GIT_PUSH_OPTION_COUNT"
then
i=0
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"
do
eval "value=\$GIT_PUSH_OPTION_$i"
case "$value" in
echoback=*)
echo "echo from the pre-receive-hook: ${value#*=}" >&2
;;
reject)
exit 1
esac
i=$((i + 1))
done
fi
================================================
FILE: .git/hooks/prepare-commit-msg.sample
================================================
#!/bin/sh
#
# An example hook script to prepare the commit log message.
# Called by "git commit" with the name of the file that has the
# commit message, followed by the description of the commit
# message's source. The hook's purpose is to edit the commit
# message file. If the hook fails with a non-zero status,
# the commit is aborted.
#
# To enable this hook, rename this file to "prepare-commit-msg".
# This hook includes three examples. The first one removes the
# "# Please enter the commit message..." help message.
#
# The second includes the output of "git diff --name-status -r"
# into the message, just before the "git status" output. It is
# commented because it doesn't cope with --amend or with squashed
# commits.
#
# The third example adds a Signed-off-by line to the message, that can
# still be edited. This is rarely a good idea.
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
SHA1=$3
/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE"
# case "$COMMIT_SOURCE,$SHA1" in
# ,|template,)
# /usr/bin/perl -i.bak -pe '
# print "\n" . `git diff --cached --name-status -r`
# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;;
# *) ;;
# esac
# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
# if test -z "$COMMIT_SOURCE"
# then
# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
# fi
================================================
FILE: .git/hooks/push-to-checkout.sample
================================================
#!/bin/sh
# An example hook script to update a checked-out tree on a git push.
#
# This hook is invoked by git-receive-pack(1) when it reacts to git
# push and updates reference(s) in its repository, and when the push
# tries to update the branch that is currently checked out and the
# receive.denyCurrentBranch configuration variable is set to
# updateInstead.
#
# By default, such a push is refused if the working tree and the index
# of the remote repository has any difference from the currently
# checked out commit; when both the working tree and the index match
# the current commit, they are updated to match the newly pushed tip
# of the branch. This hook is to be used to override the default
# behaviour; however the code below reimplements the default behaviour
# as a starting point for convenient modification.
#
# The hook receives the commit with which the tip of the current
# branch is going to be updated:
commit=$1
# It can exit with a non-zero status to refuse the push (when it does
# so, it must not modify the index or the working tree).
die () {
echo >&2 "$*"
exit 1
}
# Or it can make any necessary changes to the working tree and to the
# index to bring them to the desired state when the tip of the current
# branch is updated to the new commit, and exit with a zero status.
#
# For example, the hook can simply run git read-tree -u -m HEAD "$1"
# in order to emulate git fetch that is run in the reverse direction
# with git push, as the two-tree form of git read-tree -u -m is
# essentially the same as git switch or git checkout that switches
# branches while keeping the local changes in the working tree that do
# not interfere with the difference between the branches.
# The below is a more-or-less exact translation to shell of the C code
# for the default behaviour for git's push-to-checkout hook defined in
# the push_to_deploy() function in builtin/receive-pack.c.
#
# Note that the hook will be executed from the repository directory,
# not from the working tree, so if you want to perform operations on
# the working tree, you will have to adapt your code accordingly, e.g.
# by adding "cd .." or using relative paths.
if ! git update-index -q --ignore-submodules --refresh
then
die "Up-to-date check failed"
fi
if ! git diff-files --quiet --ignore-submodules --
then
die "Working directory has unstaged changes"
fi
# This is a rough translation of:
#
# head_has_history() ? "HEAD" : EMPTY_TREE_SHA1_HEX
if git cat-file -e HEAD 2>/dev/null
then
head=HEAD
else
head=$(git hash-object -t tree --stdin </dev/null)
fi
if ! git diff-index --quiet --cached --ignore-submodules $head --
then
die "Working directory has staged changes"
fi
if ! git read-tree -u -m "$commit"
then
die "Could not update working tree to new HEAD"
fi
================================================
FILE: .git/hooks/sendemail-validate.sample
================================================
#!/bin/sh
# An example hook script to validate a patch (and/or patch series) before
# sending it via email.
#
# The hook should exit with non-zero status after issuing an appropriate
# message if it wants to prevent the email(s) from being sent.
#
# To enable this hook, rename this file to "sendemail-validate".
#
# By default, it will only check that the patch(es) can be applied on top of
# the default upstream branch without conflicts in a secondary worktree. After
# validation (successful or not) of the last patch of a series, the worktree
# will be deleted.
#
# The following config variables can be set to change the default remote and
# remote ref that are used to apply the patches against:
#
# sendemail.validateRemote (default: origin)
# sendemail.validateRemoteRef (default: HEAD)
#
# Replace the TODO placeholders with appropriate checks according to your
# needs.
validate_cover_letter () {
file="$1"
# TODO: Replace with appropriate checks (e.g. spell checking).
true
}
validate_patch () {
file="$1"
# Ensure that the patch applies without conflicts.
git am -3 "$file" || return
# TODO: Replace with appropriate checks for this patch
# (e.g. checkpatch.pl).
true
}
validate_series () {
# TODO: Replace with appropriate checks for the whole series
# (e.g. quick build, coding style checks, etc.).
true
}
# main -------------------------------------------------------------------------
if test "$GIT_SENDEMAIL_FILE_COUNTER" = 1
then
remote=$(git config --default origin --get sendemail.validateRemote) &&
ref=$(git config --default HEAD --get sendemail.validateRemoteRef) &&
worktree=$(mktemp --tmpdir -d sendemail-validate.XXXXXXX) &&
git worktree add -fd --checkout "$worktree" "refs/remotes/$remote/$ref" &&
git config --replace-all sendemail.validateWorktree "$worktree"
else
worktree=$(git config --get sendemail.validateWorktree)
fi || {
echo "sendemail-validate: error: failed to prepare worktree" >&2
exit 1
}
unset GIT_DIR GIT_WORK_TREE
cd "$worktree" &&
if grep -q "^diff --git " "$1"
then
validate_patch "$1"
else
validate_cover_letter "$1"
fi &&
if test "$GIT_SENDEMAIL_FILE_COUNTER" = "$GIT_SENDEMAIL_FILE_TOTAL"
then
git config --unset-all sendemail.validateWorktree &&
trap 'git worktree remove -ff "$worktree"' EXIT &&
validate_series
fi
================================================
FILE: .git/hooks/update.sample
================================================
#!/bin/sh
#
# An example hook script to block unannotated tags from entering.
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
#
# To enable this hook, rename this file to "update".
#
# Config
# ------
# hooks.allowunannotated
# This boolean sets whether unannotated tags will be allowed into the
# repository. By default they won't be.
# hooks.allowdeletetag
# This boolean sets whether deleting tags will be allowed in the
# repository. By default they won't be.
# hooks.allowmodifytag
# This boolean sets whether a tag may be modified after creation. By default
# it won't be.
# hooks.allowdeletebranch
# This boolean sets whether deleting branches will be allowed in the
# repository. By default they won't be.
# hooks.denycreatebranch
# This boolean sets whether remotely creating branches will be denied
# in the repository. By default this is allowed.
#
# --- Command line
refname="$1"
oldrev="$2"
newrev="$3"
# --- Safety check
if [ -z "$GIT_DIR" ]; then
echo "Don't run this script from the command line." >&2
echo " (if you want, you could supply GIT_DIR then run" >&2
echo " $0 <ref> <oldrev> <newrev>)" >&2
exit 1
fi
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
echo "usage: $0 <ref> <oldrev> <newrev>" >&2
exit 1
fi
# --- Config
allowunannotated=$(git config --type=bool hooks.allowunannotated)
allowdeletebranch=$(git config --type=bool hooks.allowdeletebranch)
denycreatebranch=$(git config --type=bool hooks.denycreatebranch)
allowdeletetag=$(git config --type=bool hooks.allowdeletetag)
allowmodifytag=$(git config --type=bool hooks.allowmodifytag)
# check for no description
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
case "$projectdesc" in
"Unnamed repository"* | "")
echo "*** Project description file hasn't been set" >&2
exit 1
;;
esac
# --- Check types
# if $newrev is 0000...0000, it's a commit to delete a ref.
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
if [ "$newrev" = "$zero" ]; then
newrev_type=delete
else
newrev_type=$(git cat-file -t $newrev)
fi
case "$refname","$newrev_type" in
refs/tags/*,commit)
# un-annotated tag
short_refname=${refname##refs/tags/}
if [ "$allowunannotated" != "true" ]; then
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
exit 1
fi
;;
refs/tags/*,delete)
# delete tag
if [ "$allowdeletetag" != "true" ]; then
echo "*** Deleting a tag is not allowed in this repository" >&2
exit 1
fi
;;
refs/tags/*,tag)
# annotated tag
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
then
echo "*** Tag '$refname' already exists." >&2
echo "*** Modifying a tag is not allowed in this repository." >&2
exit 1
fi
;;
refs/heads/*,commit)
# branch
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
echo "*** Creating a branch is not allowed in this repository" >&2
exit 1
fi
;;
refs/heads/*,delete)
# delete branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a branch is not allowed in this repository" >&2
exit 1
fi
;;
refs/remotes/*,commit)
# tracking branch
;;
refs/remotes/*,delete)
# delete tracking branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
exit 1
fi
;;
*)
# Anything else (is there anything else?)
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
exit 1
;;
esac
# --- Finished
exit 0
================================================
FILE: .git/info/exclude
================================================
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
================================================
FILE: .git/logs/HEAD
================================================
0000000000000000000000000000000000000000 1963e57bebfde420baeecbb2c6848a2382488413 appuser <appuser@7c99e0e64a07.(none)> 1778656786 +0000 clone: from https://github.com/ponty/framebuffer-vncserver
================================================
FILE: .git/logs/refs/heads/master
================================================
0000000000000000000000000000000000000000 1963e57bebfde420baeecbb2c6848a2382488413 appuser <appuser@7c99e0e64a07.(none)> 1778656786 +0000 clone: from https://github.com/ponty/framebuffer-vncserver
================================================
FILE: .git/logs/refs/remotes/origin/HEAD
================================================
0000000000000000000000000000000000000000 1963e57bebfde420baeecbb2c6848a2382488413 appuser <appuser@7c99e0e64a07.(none)> 1778656786 +0000 clone: from https://github.com/ponty/framebuffer-vncserver
================================================
FILE: .git/objects/pack/pack-bef8852657c06b106e38622c43f30aebfe12ac48.promisor
================================================
1963e57bebfde420baeecbb2c6848a2382488413 refs/heads/master
================================================
FILE: .git/packed-refs
================================================
# pack-refs with: peeled fully-peeled sorted
1963e57bebfde420baeecbb2c6848a2382488413 refs/remotes/origin/master
================================================
FILE: .git/refs/heads/master
================================================
1963e57bebfde420baeecbb2c6848a2382488413
================================================
FILE: .git/refs/remotes/origin/HEAD
================================================
ref: refs/remotes/origin/master
================================================
FILE: .git/shallow
================================================
1963e57bebfde420baeecbb2c6848a2382488413
================================================
FILE: .github/workflows/main.yml
================================================
# For more information see:
# https://docs.github.com/en/actions/automating-builds-and-tests/
name: build
on:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '30 5 1 */3 *'
push:
pull_request:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- "ubuntu-20.04"
- "ubuntu-22.04"
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libvncserver-dev cmake qt5-qmake qtbase5-dev
- name: Test CMake build
run: |
mkdir -p build && cd build && cmake .. && make && cd ..
- name: Test QT build
run: |
mkdir -p buildqt && cd buildqt && qmake ../framebuffer-vncserver.pro && make && cd ..
================================================
FILE: .gitignore
================================================
# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.dll
*.dylib
# Qt-es
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.moc
moc_*.cpp
qrc_*.cpp
ui_*.h
#Makefile*
*-build-*
# QtCreator
*.autosave
#QtCtreator Qml
*.qmlproject.user
*.qmlproject.user.*
.*
!.git*
!.travis*
build/
*.log
================================================
FILE: .travis.yml.bak
================================================
language: c
install:
- sudo apt-get update -qq
- sudo apt-get install -y libvncserver-dev cmake qt4-qmake
script:
- mkdir -p build1 && cd build1 && cmake .. && make && cd ..
- mkdir -p build2 && cd build2 && qmake ../framebuffer-vncserver.pro && make && cd ..
================================================
FILE: CMakeLists.txt
================================================
PROJECT(framebuffer-vncserver)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
FILE(GLOB SOURCES src/*.c)
ADD_EXECUTABLE(framebuffer-vncserver ${SOURCES})
INSTALL(TARGETS framebuffer-vncserver RUNTIME DESTINATION bin)
# LIBVNC
find_library(LIBVNC NAMES libvncserver vncserver)
target_link_libraries(framebuffer-vncserver ${LIBVNC})
MESSAGE( STATUS "LIBVNC: " ${LIBVNC} )
================================================
FILE: Dockerfile
================================================
FROM alpine as builder
LABEL maintainer="ek5.chimenti@gmail.com"
ADD . /target/
WORKDIR /target
RUN apk fetch
RUN apk add libvncserver-dev
RUN apk add gcc g++ cmake make linux-headers
RUN mkdir -p build
WORKDIR /target/build
RUN cmake ..
RUN make
FROM alpine
COPY --from=builder /target/build/framebuffer-vncserver /usr/bin
RUN apk update && apk add libvncserver
ENTRYPOINT [ "framebuffer-vncserver" ]
================================================
FILE: LICENSE
================================================
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{description}
Copyright (C) {year} {fullname}
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
================================================
FILE: README.md
================================================
# framebuffer-vncserver
VNC server for Linux framebuffer devices.

The goal is to access remote embedded Linux systems without X.
Implemented features: remote display, touchscreen, keyboard, rotation
Not implemented: file transfer, ..
Working configurations:
without rotation:
- [x] 1 bit/pixel
- [x] 8 bit/pixel
- [x] 16 bit/pixel
- [x] 24 bit/pixel
- [x] 32 bit/pixel
with rotation:
- [ ] 1 bit/pixel
- [ ] 8 bit/pixel
- [x] 16 bit/pixel
- [ ] 24 bit/pixel
- [ ] 32 bit/pixel
The code is based on a LibVNC example for Android:
https://github.com/LibVNC/libvncserver/blob/master/examples/androidvncserver.c
### build
Dependency:
sudo apt-get install libvncserver-dev
There are 2 options: CMake or qmake
Using cmake:
mkdir -p build && cd build
cmake ..
make
Using qmake:
mkdir -p buildqt && cd buildqt
qmake ../framebuffer-vncserver.pro
make
### command-line help
./framebuffer-vncserver [-f device] [-p port] [-t touchscreen] [-m mouse] [-k keyboard] [-r rotation] [-R touchscreen rotation] [-F FPS] [-v] [-h]
-p port: VNC port, default is 5900
-f device: framebuffer device node, default is /dev/fb0
-k device: keyboard device node (example: /dev/input/event0)
-t device: touchscreen device node (example:/dev/input/event2)
-m device: mouse device node (example:/dev/input/event2)
-r degrees: framebuffer rotation, default is 0
-R degrees: touchscreen rotation, default is same as framebuffer rotation
-F FPS: Maximum target FPS, default is 10
-v: verbose
-h: print this help
## Run on startup as service
To run at startup as a service using systemd, edit the file `fbvnc.service` make sure the path and command line arguments are correct and then run:
```shell
sudo cp fbvnc.service /etc/systemd/system/
sudo systemctl enable fbvnc.service
sudo systemctl start fbvnc.service
```
## Vfb test
Linux Virtual Frame Buffer kernel object (vfb.ko) is used for this test.
https://cateee.net/lkddb/web-lkddb/FB_VIRTUAL.html
Local computer:
# install
sudo apt install vagrant virtualbox xtightvncviewer
# after framebuffer-vncserver start
vncviewer localhost
vagrant up
vagrant ssh
Inside vagrant box:
sudo su
cd /home/vagrant/build/
# build framebuffer-vncserver
make
# set resolution, color depth
fbset -g 640 480 640 480 16
# restart framebuffer-vncserver
killall framebuffer-vncserver;./framebuffer-vncserver -t /dev/input/ms -k /dev/input/kbd &
# set test pattern or ..
fb-test
# draw random rectangles or ..
rect
# display a GUI or ...
qmlscene -platform linuxfb -plugin evdevmouse:/dev/input/ms:abs -plugin evdevkeyboard:/dev/input/kbd:grab=1
### Automatic test
This generates patterns with different resolutions and color depths (on local computer):
python3 -m pip install fabric vncdotool python-vagrant entrypoint2
python3 vfb.py
| rotation | color | fbtest | qmlscene | gradient |
| -------: | ----: | --------------------------------------- | ----------------------------------------- | ----------------------------------------- |
| 0 | 1 | |  | |
| 0 | 8 |  | |  |
| 0 | 16 |  |  |  |
| 0 | 24 |  |  |  |
| 0 | 32 |  |  |  |
| 90 | 16 |  |  |  |
| 180 | 16 |  |  |  |
| 270 | 16 |  |  |  |
## Testing single-touch
$ (evtest /dev/input/event0 &) ;./framebuffer-vncserver -t /dev/input/event0 -v
...
Initializing touch device /dev/input/event0 ...
x:(0 4095) y:(0 4095)
...
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 330 (BTN_TOUCH)
Event type 3 (EV_ABS)
Event code 0 (ABS_X)
Value 1970
Min 0
Max 4095
Event code 1 (ABS_Y)
Value 1745
Min 0
Max 4095
Event code 24 (ABS_PRESSURE)
Value 0
Min 0
Max 255
...
Got ptrevent: 0001 (x=186, y=570)
Event: time 1580221917.655639, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
Event: time 1580221917.655639, type 3 (EV_ABS), code 0 (ABS_X), value 1586
Event: time 1580221917.655639, type 3 (EV_ABS), code 1 (ABS_Y), value 2733
Event: time 1580221917.655639, -------------- SYN_REPORT ------------
injectTouchEvent (screen(186,570) -> touch(1586,2733), mouse=1)
...
Got ptrevent: 0000 (x=186, y=570)
Event: time 1580221918.516897, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
Event: time 1580221918.516897, -------------- SYN_REPORT ------------
injectTouchEvent (screen(186,570) -> touch(1586,2733), mouse=0)
## Testing multi-touch
$ (evtest /dev/input/event2 &) ;./framebuffer-vncserver -t /dev/input/event2 -v
...
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 330 (BTN_TOUCH)
Event type 3 (EV_ABS)
Event code 0 (ABS_X)
Value 245
Min 0
Max 480
Event code 1 (ABS_Y)
Value 485
Min 0
Max 854
Event code 47 (ABS_MT_SLOT)
Value 4
Min 0
Max 4
Event code 48 (ABS_MT_TOUCH_MAJOR)
Value 0
Min 0
Max 255
Event code 50 (ABS_MT_WIDTH_MAJOR)
Value 0
Min 0
Max 255
Event code 53 (ABS_MT_POSITION_X)
Value 0
Min 0
Max 480
Event code 54 (ABS_MT_POSITION_Y)
Value 0
Min 0
Max 854
Event code 57 (ABS_MT_TRACKING_ID)
Value 0
Min 0
Max 65535
...
Initializing touch device /dev/input/event2 ...
x:(0 480) y:(0 854)
...
Got ptrevent: 0001 (x=237, y=528)
Event: time 1580221680.870277, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 0
Event: time 1580221680.870277, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
Event: time 1580221680.870277, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 237
Event: time 1580221680.870277, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 528
Event: time 1580221680.870277, type 3 (EV_ABS), code 0 (ABS_X), value 237
Event: time 1580221680.870277, type 3 (EV_ABS), code 1 (ABS_Y), value 528
Event: time 1580221680.870277, -------------- SYN_REPORT ------------
injectTouchEvent (screen(237,528) -> touch(237,528), mouse=1)
...
Got ptrevent: 0000 (x=237, y=528)
Event: time 1580221681.190716, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 1580221681.190716, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
Event: time 1580221681.190716, -------------- SYN_REPORT ------------
injectTouchEvent (screen(237,528) -> touch(237,528), mouse=0)
================================================
FILE: Vagrantfile
================================================
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/jammy64"
config.vm.network "forwarded_port", guest: 5900, host: 5900
config.vm.provider "virtualbox" do |vb|
vb.name = "framebuffer-vncserver.22.04"
# vb.gui = true
# vb.memory = "1024"
# https://bugs.launchpad.net/cloud-images/+bug/1829625
# vb.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"]
# vb.customize ["modifyvm", :id, "--uartmode1", "file", "./ttyS0.log"]
end
# disable vbox fb
config.vm.provision "shell", inline: "echo 'blacklist vboxvideo' >> /etc/modprobe.d/vbox.conf;sudo update-initramfs -u"
# vagrant plugin install vagrant-reload
config.vm.provision :reload
config.vm.provision "shell", path: "vagrant.sh"
config.ssh.extra_args = ["-t", "cd /vagrant;sudo su"]
end
================================================
FILE: Vagrantfile.20.04.rb
================================================
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/focal64"
config.vm.network "forwarded_port", guest: 5900, host: 5900
config.vm.provider "virtualbox" do |vb|
vb.name = "framebuffer-vncserver.20.04"
# vb.gui = true
# vb.memory = "1024"
# https://bugs.launchpad.net/cloud-images/+bug/1829625
# vb.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"]
# vb.customize ["modifyvm", :id, "--uartmode1", "file", "./ttyS0.log"]
end
config.vm.provision "shell", path: "vagrant.sh"
config.ssh.extra_args = ["-t", "cd /vagrant;sudo su"]
end
# export VAGRANT_VAGRANTFILE=Vagrantfile.20.04.rb;export VAGRANT_DOTFILE_PATH=.vagrant_${VAGRANT_VAGRANTFILE}
================================================
FILE: deployment.pri
================================================
# This file was generated by an application wizard of Qt Creator.
# The code below handles deployment to Android and Maemo, aswell as copying
# of the application data to shadow build directories on desktop.
# It is recommended not to modify this file, since newer versions of Qt Creator
# may offer an updated version of it.
defineTest(qtcAddDeployment) {
for(deploymentfolder, DEPLOYMENTFOLDERS) {
item = item$${deploymentfolder}
greaterThan(QT_MAJOR_VERSION, 4) {
itemsources = $${item}.files
} else {
itemsources = $${item}.sources
}
$$itemsources = $$eval($${deploymentfolder}.source)
itempath = $${item}.path
$$itempath= $$eval($${deploymentfolder}.target)
export($$itemsources)
export($$itempath)
DEPLOYMENT += $$item
}
MAINPROFILEPWD = $$PWD
android-no-sdk {
for(deploymentfolder, DEPLOYMENTFOLDERS) {
item = item$${deploymentfolder}
itemfiles = $${item}.files
$$itemfiles = $$eval($${deploymentfolder}.source)
itempath = $${item}.path
$$itempath = /data/user/qt/$$eval($${deploymentfolder}.target)
export($$itemfiles)
export($$itempath)
INSTALLS += $$item
}
target.path = /data/user/qt
export(target.path)
INSTALLS += target
} else:android {
for(deploymentfolder, DEPLOYMENTFOLDERS) {
item = item$${deploymentfolder}
itemfiles = $${item}.files
$$itemfiles = $$eval($${deploymentfolder}.source)
itempath = $${item}.path
$$itempath = /assets/$$eval($${deploymentfolder}.target)
export($$itemfiles)
export($$itempath)
INSTALLS += $$item
}
x86 {
target.path = /libs/x86
} else: armeabi-v7a {
target.path = /libs/armeabi-v7a
} else {
target.path = /libs/armeabi
}
export(target.path)
INSTALLS += target
} else:win32 {
copyCommand =
for(deploymentfolder, DEPLOYMENTFOLDERS) {
source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
source = $$replace(source, /, \\)
sourcePathSegments = $$split(source, \\)
target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments)
target = $$replace(target, /, \\)
target ~= s,\\\\\\.?\\\\,\\,
!isEqual(source,$$target) {
!isEmpty(copyCommand):copyCommand += &&
isEqual(QMAKE_DIR_SEP, \\) {
copyCommand += $(COPY_DIR) \"$$source\" \"$$target\"
} else {
source = $$replace(source, \\\\, /)
target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
target = $$replace(target, \\\\, /)
copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\"
}
}
}
!isEmpty(copyCommand) {
copyCommand = @echo Copying application data... && $$copyCommand
copydeploymentfolders.commands = $$copyCommand
first.depends = $(first) copydeploymentfolders
export(first.depends)
export(copydeploymentfolders.commands)
QMAKE_EXTRA_TARGETS += first copydeploymentfolders
}
} else:ios {
copyCommand =
for(deploymentfolder, DEPLOYMENTFOLDERS) {
source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
source = $$replace(source, \\\\, /)
target = $CODESIGNING_FOLDER_PATH/$$eval($${deploymentfolder}.target)
target = $$replace(target, \\\\, /)
sourcePathSegments = $$split(source, /)
targetFullPath = $$target/$$last(sourcePathSegments)
targetFullPath ~= s,/\\.?/,/,
!isEqual(source,$$targetFullPath) {
!isEmpty(copyCommand):copyCommand += &&
copyCommand += mkdir -p \"$$target\"
copyCommand += && cp -r \"$$source\" \"$$target\"
}
}
!isEmpty(copyCommand) {
copyCommand = echo Copying application data... && $$copyCommand
!isEmpty(QMAKE_POST_LINK): QMAKE_POST_LINK += ";"
QMAKE_POST_LINK += "$$copyCommand"
export(QMAKE_POST_LINK)
}
} else:unix {
maemo5 {
desktopfile.files = $${TARGET}.desktop
desktopfile.path = /usr/share/applications/hildon
icon.files = $${TARGET}64.png
icon.path = /usr/share/icons/hicolor/64x64/apps
} else:!isEmpty(MEEGO_VERSION_MAJOR) {
desktopfile.files = $${TARGET}_harmattan.desktop
desktopfile.path = /usr/share/applications
icon.files = $${TARGET}80.png
icon.path = /usr/share/icons/hicolor/80x80/apps
} else { # Assumed to be a Desktop Unix
copyCommand =
for(deploymentfolder, DEPLOYMENTFOLDERS) {
source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
source = $$replace(source, \\\\, /)
macx {
target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target)
} else {
target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
}
target = $$replace(target, \\\\, /)
sourcePathSegments = $$split(source, /)
targetFullPath = $$target/$$last(sourcePathSegments)
targetFullPath ~= s,/\\.?/,/,
!isEqual(source,$$targetFullPath) {
!isEmpty(copyCommand):copyCommand += &&
copyCommand += $(MKDIR) \"$$target\"
copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\"
}
}
!isEmpty(copyCommand) {
copyCommand = @echo Copying application data... && $$copyCommand
copydeploymentfolders.commands = $$copyCommand
first.depends = $(first) copydeploymentfolders
export(first.depends)
export(copydeploymentfolders.commands)
QMAKE_EXTRA_TARGETS += first copydeploymentfolders
}
}
!isEmpty(target.path) {
installPrefix = $${target.path}
} else {
installPrefix = /opt/$${TARGET}
}
for(deploymentfolder, DEPLOYMENTFOLDERS) {
item = item$${deploymentfolder}
itemfiles = $${item}.files
$$itemfiles = $$eval($${deploymentfolder}.source)
itempath = $${item}.path
$$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target)
export($$itemfiles)
export($$itempath)
INSTALLS += $$item
}
!isEmpty(desktopfile.path) {
export(icon.files)
export(icon.path)
export(desktopfile.files)
export(desktopfile.path)
INSTALLS += icon desktopfile
}
isEmpty(target.path) {
target.path = $${installPrefix}/bin
export(target.path)
}
INSTALLS += target
}
export (ICON)
export (INSTALLS)
export (DEPLOYMENT)
export (LIBS)
export (QMAKE_EXTRA_TARGETS)
}
================================================
FILE: fbvnc.service
================================================
[Unit]
Description=Framebuffer VNC Server for 3.5" TFT Display
[Service]
Type=simple
PIDFile=/var/run/fbvnc.pid
ExecStart=/home/pi/framebuffer-vncserver/build/framebuffer-vncserver -f /dev/fb1 -p 5901 -t /dev/input/touchscreen
[Install]
WantedBy=multi-user.target
================================================
FILE: format-code.sh
================================================
#!/bin/bash
set -e
autoflake -i -r --remove-all-unused-imports .
autoflake -i -r --remove-unused-variables .
isort .
black .
================================================
FILE: framebuffer-vncserver.pro
================================================
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += src/framebuffer-vncserver.c
SOURCES += src/keyboard.c
SOURCES += src/touch.c
SOURCES += src/mouse.c
include(deployment.pri)
qtcAddDeployment()
LIBS += -lvncserver
DISTFILES += \
README.md
================================================
FILE: gradient.py
================================================
from entrypoint2 import entrypoint
# last color channel
chan = {
8: 0x07,
16: 0x1F,
24: 0xFF,
32: 0xFF,
}
@entrypoint
def gradient(width=320, height=240, colorbit=32, fileout="/dev/fb0"):
"""colorbit: 8/16/24/32"""
assert colorbit in chan
with open(fileout, "wb") as f:
for y in range(0, height):
for x in range(0, width):
c = int(chan[colorbit] * (x + y) / (width + height))
f.write((c).to_bytes(int(colorbit / 8), byteorder="little"))
================================================
FILE: src/framebuffer-vncserver.c
================================================
/*
* $Id$
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* This project is an adaptation of the original fbvncserver for the iPAQ
* and Zaurus.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/sysmacros.h> /* For makedev() */
#include <fcntl.h>
#include <linux/fb.h>
#include <linux/input.h>
#include <assert.h>
#include <errno.h>
/* libvncserver */
#include "rfb/rfb.h"
#include "rfb/keysym.h"
#include "touch.h"
#include "mouse.h"
#include "keyboard.h"
#include "logging.h"
/*****************************************************************************/
#define LOG_FPS
#define BITS_PER_SAMPLE 5
#define SAMPLES_PER_PIXEL 2
// #define CHANNELS_PER_PIXEL 4
static char fb_device[256] = "/dev/fb0";
static char touch_device[256] = "";
static char kbd_device[256] = "";
static char mouse_device[256] = "";
static struct fb_var_screeninfo var_scrinfo;
static struct fb_fix_screeninfo fix_scrinfo;
static int fbfd = -1;
static unsigned short int *fbmmap = MAP_FAILED;
static unsigned short int *vncbuf;
static unsigned short int *fbbuf;
static int vnc_port = 5900;
static int vnc_rotate = 0;
static int touch_rotate = -1;
static int target_fps = 10;
static rfbScreenInfoPtr server;
static size_t bytespp;
static unsigned int bits_per_pixel;
static unsigned int frame_size;
static unsigned int fb_xres;
static unsigned int fb_yres;
int verbose = 0;
#define UNUSED(x) (void)(x)
/* No idea, just copied from fbvncserver as part of the frame differerencing
* algorithm. I will probably be later rewriting all of this. */
static struct varblock_t
{
int min_i;
int min_j;
int max_i;
int max_j;
int r_offset;
int g_offset;
int b_offset;
int rfb_xres;
int rfb_maxy;
} varblock;
/*****************************************************************************/
static void init_fb(void)
{
size_t pixels;
if ((fbfd = open(fb_device, O_RDONLY)) == -1)
{
error_print("cannot open fb device %s\n", fb_device);
exit(EXIT_FAILURE);
}
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &var_scrinfo) != 0)
{
error_print("ioctl error\n");
exit(EXIT_FAILURE);
}
if (ioctl(fbfd, FBIOGET_FSCREENINFO, &fix_scrinfo) != 0)
{
error_print("ioctl error\n");
exit(EXIT_FAILURE);
}
/*
* Get actual resolution of the framebufffer, which is not always the same as the screen resolution.
* This prevents the screen from 'smearing' on 1366 x 768 displays
*/
fb_xres = fix_scrinfo.line_length / (var_scrinfo.bits_per_pixel / 8.0);
fb_yres = var_scrinfo.yres;
pixels = fb_xres * fb_yres;
bytespp = var_scrinfo.bits_per_pixel / 8;
bits_per_pixel = var_scrinfo.bits_per_pixel;
frame_size = pixels * bits_per_pixel / 8;
info_print(" xres=%d, yres=%d, xresv=%d, yresv=%d, xoffs=%d, yoffs=%d, bpp=%d\n",
(int)fb_xres, (int)fb_yres,
(int)var_scrinfo.xres_virtual, (int)var_scrinfo.yres_virtual,
(int)var_scrinfo.xoffset, (int)var_scrinfo.yoffset,
(int)var_scrinfo.bits_per_pixel);
info_print(" offset:length red=%d:%d green=%d:%d blue=%d:%d \n",
(int)var_scrinfo.red.offset, (int)var_scrinfo.red.length,
(int)var_scrinfo.green.offset, (int)var_scrinfo.green.length,
(int)var_scrinfo.blue.offset, (int)var_scrinfo.blue.length);
fbmmap = mmap(NULL, frame_size, PROT_READ, MAP_SHARED, fbfd, 0);
if (fbmmap == MAP_FAILED)
{
error_print("mmap failed\n");
exit(EXIT_FAILURE);
}
}
static void cleanup_fb(void)
{
if (fbfd != -1)
{
close(fbfd);
fbfd = -1;
}
}
static void keyevent(rfbBool down, rfbKeySym key, rfbClientPtr cl)
{
int scancode;
debug_print("Got keysym: %04x (down=%d)\n", (unsigned int)key, (int)down);
if ((scancode = keysym2scancode(key, cl)))
{
injectKeyEvent(scancode, down);
}
}
static void ptrevent_touch(int buttonMask, int x, int y, rfbClientPtr cl)
{
UNUSED(cl);
/* Indicates either pointer movement or a pointer button press or release. The pointer is
now at (x-position, y-position), and the current state of buttons 1 to 8 are represented
by bits 0 to 7 of button-mask respectively, 0 meaning up, 1 meaning down (pressed).
On a conventional mouse, buttons 1, 2 and 3 correspond to the left, middle and right
buttons on the mouse. On a wheel mouse, each step of the wheel upwards is represented
by a press and release of button 4, and each step downwards is represented by
a press and release of button 5.
From: http://www.vislab.usyd.edu.au/blogs/index.php/2009/05/22/an-headerless-indexed-protocol-for-input-1?blog=61 */
debug_print("Got ptrevent: %04x (x=%d, y=%d)\n", buttonMask, x, y);
// Simulate left mouse event as touch event
static int pressed = 0;
if (buttonMask & 1)
{
if (pressed == 1)
{
injectTouchEvent(MouseDrag, x, y, &var_scrinfo);
}
else
{
pressed = 1;
injectTouchEvent(MousePress, x, y, &var_scrinfo);
}
}
if (buttonMask == 0)
{
if (pressed == 1)
{
pressed = 0;
injectTouchEvent(MouseRelease, x, y, &var_scrinfo);
}
}
}
static void ptrevent_mouse(int buttonMask, int x, int y, rfbClientPtr cl)
{
UNUSED(cl);
/* Indicates either pointer movement or a pointer button press or release. The pointer is
now at (x-position, y-position), and the current state of buttons 1 to 8 are represented
by bits 0 to 7 of button-mask respectively, 0 meaning up, 1 meaning down (pressed).
On a conventional mouse, buttons 1, 2 and 3 correspond to the left, middle and right
buttons on the mouse. On a wheel mouse, each step of the wheel upwards is represented
by a press and release of button 4, and each step downwards is represented by
a press and release of button 5.
From: http://www.vislab.usyd.edu.au/blogs/index.php/2009/05/22/an-headerless-indexed-protocol-for-input-1?blog=61 */
debug_print("Got mouse: %04x (x=%d, y=%d)\n", buttonMask, x, y);
// Simulate left mouse event as touch event
injectMouseEvent(&var_scrinfo, buttonMask, x, y);
}
/*****************************************************************************/
static void init_fb_server(int argc, char **argv, rfbBool enable_touch, rfbBool enable_mouse)
{
info_print("Initializing server...\n");
int rbytespp = bits_per_pixel == 1 ? 1 : bytespp;
int rframe_size = bits_per_pixel == 1 ? frame_size * 8 : frame_size;
/* Allocate the VNC server buffer to be managed (not manipulated) by
* libvncserver. */
vncbuf = malloc(rframe_size);
assert(vncbuf != NULL);
memset(vncbuf, bits_per_pixel == 1 ? 0xFF : 0x00, rframe_size);
/* Allocate the comparison buffer for detecting drawing updates from frame
* to frame. */
fbbuf = calloc(frame_size, 1);
assert(fbbuf != NULL);
/* TODO: This assumes var_scrinfo.bits_per_pixel is 16. */
server = rfbGetScreen(&argc, argv, fb_xres, fb_yres, BITS_PER_SAMPLE, SAMPLES_PER_PIXEL, rbytespp);
assert(server != NULL);
server->desktopName = "framebuffer";
server->frameBuffer = (char *)vncbuf;
server->alwaysShared = TRUE;
server->httpDir = NULL;
server->port = vnc_port;
server->kbdAddEvent = keyevent;
if (enable_touch)
{
server->ptrAddEvent = ptrevent_touch;
}
if (enable_mouse)
{
server->ptrAddEvent = ptrevent_mouse;
}
rfbInitServer(server);
/* Mark as dirty since we haven't sent any updates at all yet. */
rfbMarkRectAsModified(server, 0, 0, fb_xres, fb_yres);
/* No idea. */
varblock.r_offset = var_scrinfo.red.offset + var_scrinfo.red.length - BITS_PER_SAMPLE;
varblock.g_offset = var_scrinfo.green.offset + var_scrinfo.green.length - BITS_PER_SAMPLE;
varblock.b_offset = var_scrinfo.blue.offset + var_scrinfo.blue.length - BITS_PER_SAMPLE;
varblock.rfb_xres = fb_yres;
varblock.rfb_maxy = fb_xres - 1;
}
// sec
#define LOG_TIME 5
int timeToLogFPS()
{
static struct timeval now = {0, 0}, then = {0, 0};
double elapsed, dnow, dthen;
gettimeofday(&now, NULL);
dnow = now.tv_sec + (now.tv_usec / 1000000.0);
dthen = then.tv_sec + (then.tv_usec / 1000000.0);
elapsed = dnow - dthen;
if (elapsed > LOG_TIME)
memcpy((char *)&then, (char *)&now, sizeof(struct timeval));
return elapsed > LOG_TIME;
}
/*****************************************************************************/
//#define COLOR_MASK 0x1f001f
#define COLOR_MASK (((1 << BITS_PER_SAMPLE) << 1) - 1)
#define PIXEL_FB_TO_RFB(p, r_offset, g_offset, b_offset) \
((p >> r_offset) & COLOR_MASK) | (((p >> g_offset) & COLOR_MASK) << BITS_PER_SAMPLE) | (((p >> b_offset) & COLOR_MASK) << (2 * BITS_PER_SAMPLE))
static void update_screen(void)
{
#ifdef LOG_FPS
if (verbose)
{
static int frames = 0;
frames++;
if (timeToLogFPS())
{
double fps = frames / LOG_TIME;
info_print(" fps: %f\n", fps);
frames = 0;
}
}
#endif
varblock.min_i = varblock.min_j = 9999;
varblock.max_i = varblock.max_j = -1;
if (vnc_rotate == 0 && bits_per_pixel == 24)
{
uint8_t *f = (uint8_t *)fbmmap; /* -> framebuffer */
uint8_t *c = (uint8_t *)fbbuf; /* -> compare framebuffer */
uint8_t *r = (uint8_t *)vncbuf; /* -> remote framebuffer */
if (memcmp(fbmmap, fbbuf, frame_size) != 0)
{
int y;
for (y = 0; y < (int)fb_yres; y++)
{
int x;
for (x = 0; x < (int)fb_xres; x++)
{
uint32_t pixel = *(uint32_t *)f & 0x00FFFFFF;
uint32_t comp = *(uint32_t *)c & 0x00FFFFFF;
if (pixel != comp)
{
*(c + 0) = *(f + 0);
*(c + 1) = *(f + 1);
*(c + 2) = *(f + 2);
uint32_t rem = PIXEL_FB_TO_RFB(pixel,
varblock.r_offset, varblock.g_offset, varblock.b_offset);
*(r + 0) = (uint8_t)((rem >> 0) & 0xFF);
*(r + 1) = (uint8_t)((rem >> 8) & 0xFF);
*(r + 2) = (uint8_t)((rem >> 16) & 0xFF);
if (x < varblock.min_i)
varblock.min_i = x;
else if (x > varblock.max_i)
varblock.max_i = x;
if (y > varblock.max_j)
varblock.max_j = y;
else if (y < varblock.min_j)
varblock.min_j = y;
}
f += bytespp;
c += bytespp;
r += bytespp;
}
}
}
}
else if (vnc_rotate == 0 && bits_per_pixel == 1)
{
uint8_t *f = (uint8_t *)fbmmap; /* -> framebuffer */
uint8_t *c = (uint8_t *)fbbuf; /* -> compare framebuffer */
uint8_t *r = (uint8_t *)vncbuf; /* -> remote framebuffer */
int xstep = 8;
if (memcmp(fbmmap, fbbuf, frame_size) != 0)
{
int y;
for (y = 0; y < (int)fb_yres; y++)
{
int x;
for (x = 0; x < (int)fb_xres; x += xstep)
{
uint8_t pixels = *f;
if (pixels != *c)
{
*c = pixels;
for (int bit = 0; bit < 8; bit++)
{
// *(r+bit) = ((pixels >> (7-bit)) & 0x1) ? 0xFF : 0x00;
*(r + bit) = ((pixels >> (7 - bit)) & 0x1) ? 0x00 : 0xFF;
}
int x2 = x + xstep - 1;
if (x < varblock.min_i)
varblock.min_i = x;
else if (x2 > varblock.max_i)
varblock.max_i = x2;
if (y > varblock.max_j)
varblock.max_j = y;
else if (y < varblock.min_j)
varblock.min_j = y;
}
f += 1;
c += 1;
r += 8;
}
}
}
}
else if (vnc_rotate == 0)
{
uint32_t *f = (uint32_t *)fbmmap; /* -> framebuffer */
uint32_t *c = (uint32_t *)fbbuf; /* -> compare framebuffer */
uint32_t *r = (uint32_t *)vncbuf; /* -> remote framebuffer */
if (memcmp(fbmmap, fbbuf, frame_size) != 0)
{
// memcpy(fbbuf, fbmmap, size);
int xstep = 4 / bytespp;
int y;
for (y = 0; y < (int)fb_yres; y++)
{
/* Compare every 1/2/4 pixels at a time */
int x;
for (x = 0; x < (int)fb_xres; x += xstep)
{
uint32_t pixel = *f;
if (pixel != *c)
{
*c = pixel;
#if 0
/* XXX: Undo the checkered pattern to test the efficiency
* gain using hextile encoding. */
if (pixel == 0x18e320e4 || pixel == 0x20e418e3)
pixel = 0x18e318e3;
#endif
if (bytespp == 4)
{
*r = PIXEL_FB_TO_RFB(pixel,
varblock.r_offset, varblock.g_offset, varblock.b_offset);
}
else if (bytespp == 2)
{
*r = PIXEL_FB_TO_RFB(pixel,
varblock.r_offset, varblock.g_offset, varblock.b_offset);
uint32_t high_pixel = (0xffff0000 & pixel) >> 16;
uint32_t high_r = PIXEL_FB_TO_RFB(high_pixel, varblock.r_offset, varblock.g_offset, varblock.b_offset);
*r |= (0xffff & high_r) << 16;
}
else if (bytespp == 1)
{
*r = pixel;
}
else
{
// TODO
}
int x2 = x + xstep - 1;
if (x < varblock.min_i)
varblock.min_i = x;
else if (x2 > varblock.max_i)
varblock.max_i = x2;
if (y > varblock.max_j)
varblock.max_j = y;
else if (y < varblock.min_j)
varblock.min_j = y;
}
f++;
c++;
r++;
}
}
}
}
else if (bits_per_pixel == 16)
{
uint16_t *f = (uint16_t *)fbmmap; /* -> framebuffer */
uint16_t *c = (uint16_t *)fbbuf; /* -> compare framebuffer */
uint16_t *r = (uint16_t *)vncbuf; /* -> remote framebuffer */
switch (vnc_rotate)
{
case 0:
case 180:
server->width = fb_xres;
server->height = fb_yres;
server->paddedWidthInBytes = fb_xres * bytespp;
break;
case 90:
case 270:
server->width = fb_yres;
server->height = fb_xres;
server->paddedWidthInBytes = fb_yres * bytespp;
break;
}
if (memcmp(fbmmap, fbbuf, frame_size) != 0)
{
int y;
for (y = 0; y < (int)fb_yres; y++)
{
/* Compare every pixels at a time */
int x;
for (x = 0; x < (int)fb_xres; x++)
{
uint16_t pixel = *f;
if (pixel != *c)
{
int x2, y2;
*c = pixel;
switch (vnc_rotate)
{
case 0:
x2 = x;
y2 = y;
break;
case 90:
x2 = fb_yres - 1 - y;
y2 = x;
break;
case 180:
x2 = fb_xres - 1 - x;
y2 = fb_yres - 1 - y;
break;
case 270:
x2 = y;
y2 = fb_xres - 1 - x;
break;
default:
error_print("rotation is invalid\n");
exit(EXIT_FAILURE);
}
r[y2 * server->width + x2] = PIXEL_FB_TO_RFB(pixel, varblock.r_offset, varblock.g_offset, varblock.b_offset);
if (x2 < varblock.min_i)
varblock.min_i = x2;
else
{
if (x2 > varblock.max_i)
varblock.max_i = x2;
if (y2 > varblock.max_j)
varblock.max_j = y2;
else if (y2 < varblock.min_j)
varblock.min_j = y2;
}
}
f++;
c++;
}
}
}
}
else
{
error_print("not supported color depth or rotation\n");
exit(EXIT_FAILURE);
}
if (varblock.min_i < 9999)
{
if (varblock.max_i < 0)
varblock.max_i = varblock.min_i;
if (varblock.max_j < 0)
varblock.max_j = varblock.min_j;
debug_print("Dirty page: %dx%d+%d+%d...\n",
(varblock.max_i + 2) - varblock.min_i, (varblock.max_j + 1) - varblock.min_j,
varblock.min_i, varblock.min_j);
rfbMarkRectAsModified(server, varblock.min_i, varblock.min_j,
varblock.max_i + 2, varblock.max_j + 1);
}
}
/*****************************************************************************/
void print_usage(char **argv)
{
info_print("%s [-f device] [-p port] [-t touchscreen] [-m mouse] [-k keyboard] [-r rotation] [-R touchscreen rotation] [-F FPS] [-v] [-h]\n"
"-p port: VNC port, default is 5900\n"
"-f device: framebuffer device node, default is /dev/fb0\n"
"-k device: keyboard device node (example: /dev/input/event0)\n"
"-t device: touchscreen device node (example:/dev/input/event2)\n"
"-m device: mouse device node (example:/dev/input/event2)\n"
"-r degrees: framebuffer rotation, default is 0\n"
"-R degrees: touchscreen rotation, default is same as framebuffer rotation\n"
"-F FPS: Maximum target FPS, default is 10\n"
"-v: verbose\n"
"-h: print this help\n",
*argv);
}
int main(int argc, char **argv)
{
if (argc > 1)
{
int i = 1;
while (i < argc)
{
if (*argv[i] == '-')
{
switch (*(argv[i] + 1))
{
case 'h':
print_usage(argv);
exit(0);
break;
case 'f':
i++;
if (argv[i])
strcpy(fb_device, argv[i]);
break;
case 't':
i++;
if (argv[i])
strcpy(touch_device, argv[i]);
break;
case 'm':
i++;
if (argv[i])
strcpy(mouse_device, argv[i]);
break;
case 'k':
i++;
strcpy(kbd_device, argv[i]);
break;
case 'p':
i++;
if (argv[i])
vnc_port = atoi(argv[i]);
break;
case 'r':
i++;
if (argv[i])
vnc_rotate = atoi(argv[i]);
break;
case 'R':
i++;
if (argv[i])
touch_rotate = atoi(argv[i]);
break;
case 'F':
i++;
if (argv[i])
target_fps = atoi(argv[i]);
break;
case 'v':
verbose = 1;
break;
}
}
i++;
}
}
if (touch_rotate < 0)
touch_rotate = vnc_rotate;
info_print("Initializing framebuffer device %s...\n", fb_device);
init_fb();
if (strlen(kbd_device) > 0)
{
int ret = init_kbd(kbd_device);
if (!ret)
info_print("Keyboard device %s not available.\n", kbd_device);
}
else
{
info_print("No keyboard device\n");
}
rfbBool enable_touch = FALSE;
rfbBool enable_mouse = FALSE;
if(strlen(touch_device) > 0 && strlen(mouse_device) > 0)
{
error_print("It can't using both mouse and touch device.\n");
exit(EXIT_FAILURE);
}
else if (strlen(touch_device) > 0)
{
// init touch only if there is a touch device defined
int ret = init_touch(touch_device, touch_rotate);
enable_touch = (ret > 0);
}
else if(strlen(mouse_device) > 0)
{
// init touch only if there is a mouse device defined
int ret = init_mouse(mouse_device, touch_rotate);
enable_mouse = (ret > 0);
}
else
{
info_print("No touch or mouse device\n");
}
info_print("Initializing VNC server:\n");
info_print(" width: %d\n", (int)fb_xres);
info_print(" height: %d\n", (int)fb_yres);
info_print(" bpp: %d\n", (int)var_scrinfo.bits_per_pixel);
info_print(" port: %d\n", (int)vnc_port);
info_print(" rotate: %d\n", (int)vnc_rotate);
info_print(" mouse/touch rotate: %d\n", (int)touch_rotate);
info_print(" target FPS: %d\n", (int)target_fps);
init_fb_server(argc, argv, enable_touch, enable_mouse);
/* Implement our own event loop to detect changes in the framebuffer. */
while (1)
{
rfbRunEventLoop(server, 100 * 1000, TRUE);
while (rfbIsActive(server))
{
if (server->clientHead != NULL)
update_screen();
if (target_fps > 0)
usleep(1000 * 1000 / target_fps);
else if (server->clientHead == NULL)
usleep(100 * 1000);
}
}
info_print("Cleaning up...\n");
cleanup_fb();
cleanup_kbd();
cleanup_touch();
}
================================================
FILE: src/keyboard.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/sysmacros.h> /* For makedev() */
#include <fcntl.h>
#include <linux/fb.h>
#include <linux/input.h>
#include <assert.h>
#include <errno.h>
/* libvncserver */
#include "rfb/rfb.h"
#include "rfb/keysym.h"
#include "keyboard.h"
#include "logging.h"
#ifndef input_event_sec
#define input_event_sec time.tv_sec
#define input_event_usec time.tv_usec
#endif
//static char KBD_DEVICE[256] = "/dev/input/event1";
static int kbdfd = -1;
int init_kbd(const char *kbd_device)
{
info_print("Initializing keyboard device %s ...\n", kbd_device);
if ((kbdfd = open(kbd_device, O_RDWR)) == -1)
{
error_print("cannot open kbd device %s\n", kbd_device);
return 0;
}
else
{
return 1;
}
}
void cleanup_kbd()
{
if (kbdfd != -1)
{
close(kbdfd);
}
}
void injectKeyEvent(uint16_t code, uint16_t value)
{
struct input_event ev;
memset(&ev, 0, sizeof(ev));
struct timeval time;
gettimeofday(&time, 0);
ev.input_event_sec = time.tv_sec;
ev.input_event_usec = time.tv_usec;
ev.type = EV_KEY;
ev.code = code;
ev.value = value;
if (write(kbdfd, &ev, sizeof(ev)) < 0)
{
error_print("write event failed, %s\n", strerror(errno));
}
// Finally send the SYN
gettimeofday(&time, 0);
ev.input_event_sec = time.tv_sec;
ev.input_event_usec = time.tv_usec;
ev.type = EV_SYN;
ev.code = 0;
ev.value = 0;
if (write(kbdfd, &ev, sizeof(ev)) < 0)
{
error_print("write event failed, %s\n", strerror(errno));
}
debug_print("injectKey (%d, %d)\n", code, value);
}
int keysym2scancode(rfbKeySym key, rfbClientPtr cl)
{
int scancode = 0;
int code = (int)key;
if (code >= '0' && code <= '9')
{
scancode = (code & 0xF) - 1;
if (scancode < 0)
scancode += 10;
scancode += KEY_1;
}
else if ((code >= 'A' && code <= 'Z') || (code >= 'a' && code <= 'z'))
{
static const uint16_t map[] = {
KEY_A, KEY_B, KEY_C, KEY_D, KEY_E,
KEY_F, KEY_G, KEY_H, KEY_I, KEY_J,
KEY_K, KEY_L, KEY_M, KEY_N, KEY_O,
KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T,
KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z};
scancode = map[(code & 0x5F) - 'A'];
}
else
{
switch (code)
{
case XK_space: scancode = KEY_SPACE; break; //20
case XK_exclam: scancode = KEY_1; break; //21
case XK_quotedbl: scancode = KEY_APOSTROPHE; break; //22
case XK_numbersign: scancode = KEY_3; break; //23
case XK_dollar: scancode = KEY_4; break; //24
case XK_percent: scancode = KEY_5; break; //25
case XK_ampersand: scancode = KEY_7; break; //26
case XK_apostrophe: scancode = KEY_APOSTROPHE; break; //27
case XK_parenleft: scancode = KEY_9; break; //28
case XK_parenright: scancode = KEY_0; break; //29
case XK_asterisk: scancode = KEY_8; break; //2a
case XK_plus: scancode = KEY_MINUS; break; //2b
case XK_comma: scancode = KEY_EQUAL; break; //2c
case XK_minus: scancode = KEY_MINUS; break; //2d
case XK_period: scancode = KEY_DOT; break; //2e
case XK_slash: scancode = KEY_SLASH; break; //2f
// XK_0 .. XK_9 // 30 .. 39
case XK_colon: scancode = KEY_SEMICOLON; break; //3a
case XK_semicolon: scancode = KEY_SEMICOLON; break; //3b
case XK_less: scancode = KEY_COMMA; break; //3c
case XK_equal: scancode = KEY_EQUAL; break; //3d
case XK_greater: scancode = KEY_DOT; break; //3e
case XK_question: scancode = KEY_SLASH; break; //3f
case XK_at: scancode = KEY_2; break; //40
// XK_A .. XK_Z // 41 .. 5a
case XK_bracketleft: scancode = KEY_LEFTBRACE; break; //5b
case XK_backslash: scancode = KEY_BACKSLASH; break; //5c
case XK_bracketright: scancode = KEY_RIGHTBRACE; break; //5d
case XK_asciicircum: scancode = KEY_6; break; //5e
case XK_underscore: scancode = KEY_MINUS; break; //5f
case XK_grave: scancode = KEY_GRAVE; break; //60
// XK_a .. XK_z // 61 .. 7a
case XK_braceleft: scancode = KEY_LEFTBRACE; break; //7b
case XK_bar: scancode = KEY_BACKSLASH; break; //7c
case XK_braceright: scancode = KEY_RIGHTBRACE; break; //7d
case XK_asciitilde: scancode = KEY_GRAVE; break; //7e
case XK_BackSpace: scancode = KEY_BACKSPACE; break; //ff08
case XK_Escape: scancode = KEY_ESC; break; //ff1b
case XK_Tab: scancode = KEY_TAB; break; //ff09
case XK_Return: scancode = KEY_ENTER; break; //ff0d
case XK_F1: scancode = KEY_F1; break; //ffbe
case XK_F2: scancode = KEY_F2; break; //ffbf
case XK_F3: scancode = KEY_F3; break; //ffc0
case XK_F4: scancode = KEY_F4; break; //ffc1
case XK_F5: scancode = KEY_F5; break; //ffc2
case XK_F6: scancode = KEY_F6; break; //ffc3
case XK_F7: scancode = KEY_F7; break; //ffc4
case XK_F8: scancode = KEY_F8; break; //ffc5
case XK_F9: scancode = KEY_F9; break; //ffc6
case XK_F10: scancode = KEY_F10; break; //ffc7
//case XK_F11: scancode = KEY_F11; break; //ffc8
case XK_F12: scancode = KEY_F12; break; //ffc9
case XK_F11:
rfbShutdownServer(cl->screen, TRUE);
break; //ffc8
case XK_Home: scancode = KEY_HOME; break; //ff50
case XK_Left: scancode = KEY_LEFT; break; //ff51
case XK_Up: scancode = KEY_UP; break; //ff52
case XK_Right: scancode = KEY_RIGHT; break; //ff53
case XK_Down: scancode = KEY_DOWN; break; //ff54
case XK_Page_Up: scancode = KEY_PAGEUP; break; //ff55
case XK_Page_Down: scancode = KEY_PAGEDOWN; break; //ff56
case XK_End: scancode = KEY_END; break; //ff57
case XK_Begin: scancode = KEY_HOME; break; //ff58
case XK_Shift_L: scancode = KEY_LEFTSHIFT; break; //ffe1
case XK_Shift_R: scancode = KEY_RIGHTSHIFT; break; //ffe2
case XK_Control_L: scancode = KEY_LEFTCTRL; break; //ffe3
case XK_Control_R: scancode = KEY_RIGHTCTRL; break; //ffe4
case XK_Alt_L: scancode = KEY_LEFTALT; break; //ffe9
case XK_Alt_R: scancode = KEY_RIGHTALT; break; //ffea
}
}
return scancode;
}
================================================
FILE: src/keyboard.h
================================================
#pragma once
int init_kbd(const char *);
void cleanup_kbd();
void injectKeyEvent(uint16_t, uint16_t);
int keysym2scancode(rfbKeySym key, rfbClientPtr cl);
================================================
FILE: src/logging.h
================================================
#pragma once
#define error_print(...) \
do \
{ \
fprintf(stderr, __VA_ARGS__); \
} while (0)
#define info_print(...) \
do \
{ \
fprintf(stderr, __VA_ARGS__); \
} while (0)
extern int verbose;
#define debug_print(...) \
do \
{ \
if (verbose) \
fprintf(stderr, __VA_ARGS__); \
} while (0)
================================================
FILE: src/mouse.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/sysmacros.h> /* For makedev() */
#include <fcntl.h>
#include <linux/fb.h>
#include <linux/input.h>
#include <assert.h>
#include <errno.h>
/* libvncserver */
#include "rfb/rfb.h"
#include "mouse.h"
#include "logging.h"
static int mousefd = -1;
static int xmin, xmax;
static int ymin, ymax;
static int rotate;
static int trkg_id = -1;
static bool is_wheel_hires = false;
#ifndef input_event_sec
#define input_event_sec time.tv_sec
#define input_event_usec time.tv_usec
#endif
typedef struct
{
const char *name;
const int value;
} map_t;
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define MAP(x) { #x,x }
#define WHEEL_UP 3
#define WHEEL_DOWN 4
int init_mouse(const char *touch_device, int vnc_rotate)
{
int size = (REL_CNT/32) + 1;
unsigned int evtype_bitmask[size];
/* Clean evtype_bitmask structure */
memset(evtype_bitmask, 0, sizeof(evtype_bitmask));
info_print("Initializing mouse device %s ...\n", touch_device);
struct input_absinfo info;
if ((mousefd = open(touch_device, O_RDWR)) == -1)
{
error_print("cannot open mouse device %s\n", touch_device);
return 0;
}
//REL_WHEEL_HI_RES
if (ioctl(mousefd, EVIOCGBIT(EV_REL, sizeof(evtype_bitmask)), evtype_bitmask) < 0) {
error_print("%s can't get evdev features: %s",touch_device, strerror(errno));
return 0;
}
#ifdef REL_WHEEL_HI_RES
int index = REL_WHEEL_HI_RES/32;
int offset = REL_WHEEL_HI_RES - (index*32);
if(CHECK_BIT(evtype_bitmask[index],offset))
{
info_print("%s has hi res wheel.\n",touch_device);
is_wheel_hires = true;
}
#endif
// Get the Range of X and Y
if (ioctl(mousefd, EVIOCGABS(ABS_X), &info))
{
error_print("cannot get ABS_X info, %s\n", strerror(errno));
return 0;
}
xmin = info.minimum;
xmax = info.maximum;
if (ioctl(mousefd, EVIOCGABS(ABS_Y), &info))
{
error_print("cannot get ABS_Y, %s\n", strerror(errno));
return 0;
}
ymin = info.minimum;
ymax = info.maximum;
rotate = vnc_rotate;
info_print(" x:(%d %d) y:(%d %d) \n", xmin, xmax, ymin, ymax);
return 1;
}
void cleanup_mouse()
{
if (mousefd != -1)
{
close(mousefd);
}
}
void injectMouseEvent(struct fb_var_screeninfo *scrinfo, int buttonMask, int x, int y)
{
/* Indicates either pointer movement or a pointer button press or release. The pointer is
now at (x-position, y-position), and the current state of buttons 1 to 8 are represented
by bits 0 to 7 of button-mask respectively, 0 meaning up, 1 meaning down (pressed).
On a conventional mouse, buttons 1, 2 and 3 correspond to the left, middle and right
buttons on the mouse. On a wheel mouse, each step of the wheel upwards is represented
by a press and release of button 4, and each step downwards is represented by
a press and release of button 5.
From: http://www.vislab.usyd.edu.au/blogs/index.php/2009/05/22/an-headerless-indexed-protocol-for-input-1?blog=61 */
static map_t mouseButtonMap[] = {
MAP(BTN_LEFT),
MAP(BTN_MIDDLE),
MAP(BTN_RIGHT),
};
static int buttonsNumber = sizeof(mouseButtonMap) / sizeof(mouseButtonMap[0]);
static int last_buttonMask;
static int last_x;
static int last_y;
static int wheel_tick;
int last_wheel_tick = 0;
struct input_event ev;
int xin = x;
int yin = y;
switch (rotate)
{
case 90:
x = yin;
y = scrinfo->yres - 1 - xin;
break;
case 180:
x = scrinfo->xres - 1 - xin;
y = scrinfo->yres - 1 - yin;
break;
case 270:
x = scrinfo->xres - 1 - yin;
y = xin;
break;
}
// Calculate the final x and y
/* Fake touch screen always reports zero */
//???//if (xmin != 0 && xmax != 0 && ymin != 0 && ymax != 0)
{
x = xmin + (x * (xmax - xmin)) / (scrinfo->xres);
y = ymin + (y * (ymax - ymin)) / (scrinfo->yres);
}
memset(&ev, 0, sizeof(ev));
struct timeval time;
// Send buttons state
int buttonsChanged = last_buttonMask ^ buttonMask;
if (buttonsChanged)
{
for (int bi = 0; bi < buttonsNumber; bi++)
{
int isChanged = CHECK_BIT(buttonsChanged,bi);
int isPressed = CHECK_BIT(buttonMask,bi);
if(isChanged)
{
// Then send a BTN_*
gettimeofday(&time, 0);
ev.input_event_sec = time.tv_sec;
ev.input_event_usec = time.tv_usec;
ev.type = EV_KEY;
ev.code = mouseButtonMap[bi].value;
ev.value = isPressed;
if (write(mousefd, &ev, sizeof(ev)) < 0)
{
error_print("write event failed, %s\n", strerror(errno));
}
info_print("Button %s=%04X\n",mouseButtonMap[bi].name, mouseButtonMap[bi].value);
}
}
if(CHECK_BIT(buttonMask,WHEEL_UP))
{
wheel_tick++;
}
else if(CHECK_BIT(buttonMask,WHEEL_DOWN))
{
wheel_tick--;
}
if(wheel_tick)
{
// Then send the WHEEL
gettimeofday(&time, 0);
ev.input_event_sec = time.tv_sec;
ev.input_event_usec = time.tv_usec;
ev.type = EV_REL;
if(is_wheel_hires)
{
#ifdef REL_WHEEL_HI_RES
info_print("HI RES WHEEL %d\n", wheel_tick);
ev.code = REL_WHEEL_HI_RES;
ev.value = wheel_tick*120;
#endif
}
else
{
info_print("WHEEL %d\n", wheel_tick);
ev.code = REL_WHEEL;
ev.value = wheel_tick;
}
if (write(mousefd, &ev, sizeof(ev)) < 0)
{
error_print("write event failed, %s\n", strerror(errno));
}
last_wheel_tick = wheel_tick;
wheel_tick = 0;
}
last_buttonMask = buttonMask;
}
int dx = x - last_x;
int dy = y - last_y;
if (dx)
{
// Then send the X
gettimeofday(&time, 0);
ev.input_event_sec = time.tv_sec;
ev.input_event_usec = time.tv_usec;
ev.type = EV_ABS;
ev.code = ABS_X;
ev.value = x;
if (write(mousefd, &ev, sizeof(ev)) < 0)
{
error_print("write event failed, %s\n", strerror(errno));
}
last_x = x;
}
if(dy)
{
// Then send the Y
gettimeofday(&time, 0);
ev.input_event_sec = time.tv_sec;
ev.input_event_usec = time.tv_usec;
ev.type = EV_ABS;
ev.code = ABS_Y;
ev.value = y;
if (write(mousefd, &ev, sizeof(ev)) < 0)
{
error_print("write event failed, %s\n", strerror(errno));
}
last_y = y;
}
// Finally send the SYN
gettimeofday(&time, 0);
ev.input_event_sec = time.tv_sec;
ev.input_event_usec = time.tv_usec;
ev.type = EV_SYN;
ev.code = 0;
ev.value = 0;
if (write(mousefd, &ev, sizeof(ev)) < 0)
{
error_print("write event failed, %s\n", strerror(errno));
}
debug_print("injectMouseEvent (screen(%d,%d) -> mouse(%d,%d), button=%d, wheel tick=%d)\n", xin, yin, x, y, buttonMask, last_wheel_tick);
}
================================================
FILE: src/mouse.h
================================================
#pragma once
int init_mouse(const char *touch_device, int vnc_rotate);
void cleanup_mouse();
void injectMouseEvent(struct fb_var_screeninfo *scrinfo, int buttonMask, int x, int y);
================================================
FILE: src/touch.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/sysmacros.h> /* For makedev() */
#include <fcntl.h>
#include <linux/fb.h>
#include <linux/input.h>
#include <assert.h>
#include <errno.h>
/* libvncserver */
#include "rfb/rfb.h"
#include "touch.h"
#include "logging.h"
//static char TOUCH_DEVICE[256] = "/dev/input/event2";
static int touchfd = -1;
static int xmin, xmax;
static int ymin, ymax;
static int rotate;
static int trkg_id = -1;
#ifndef input_event_sec
#define input_event_sec time.tv_sec
#define input_event_usec time.tv_usec
#endif
int init_touch(const char *touch_device, int vnc_rotate)
{
info_print("Initializing touch device %s ...\n", touch_device);
struct input_absinfo info;
if ((touchfd = open(touch_device, O_RDWR)) == -1)
{
error_print("cannot open touch device %s\n", touch_device);
return 0;
}
// Get the Range of X and Y
if (ioctl(touchfd, EVIOCGABS(ABS_X), &info))
{
error_print("cannot get ABS_X info, %s\n", strerror(errno));
return 0;
}
xmin = info.minimum;
xmax = info.maximum;
if (ioctl(touchfd, EVIOCGABS(ABS_Y), &info))
{
error_print("cannot get ABS_Y, %s\n", strerror(errno));
return 0;
}
ymin = info.minimum;
ymax = info.maximum;
rotate = vnc_rotate;
info_print(" x:(%d %d) y:(%d %d) \n", xmin, xmax, ymin, ymax);
return 1;
}
void cleanup_touch()
{
if (touchfd != -1)
{
close(touchfd);
}
}
void injectTouchEvent(enum MouseAction mouseAction, int x, int y, struct fb_var_screeninfo *scrinfo)
{
struct input_event ev;
int xin = x;
int yin = y;
switch (rotate)
{
case 90:
x = yin;
y = scrinfo->yres - 1 - xin;
break;
case 180:
x = scrinfo->xres - 1 - xin;
y = scrinfo->yres - 1 - yin;
break;
case 270:
x = scrinfo->xres - 1 - yin;
y = xin;
break;
}
// Calculate the final x and y
/* Fake touch screen always reports zero */
//???//if (xmin != 0 && xmax != 0 && ymin != 0 && ymax != 0)
{
x = xmin + (x * (xmax - xmin)) / (scrinfo->xres);
y = ymin + (y * (ymax - ymin)) / (scrinfo->yres);
}
memset(&ev, 0, sizeof(ev));
bool sendPos;
bool sendTouch;
int trkIdValue;
int touchValue;
struct timeval time;
switch (mouseAction)
{
case MousePress:
sendPos = true;
sendTouch = true;
trkIdValue = ++trkg_id;
touchValue = 1;
break;
case MouseRelease:
sendPos = false;
sendTouch = true;
trkIdValue = -1;
touchValue = 0;
break;
case MouseDrag:
sendPos = true;
sendTouch = false;
break;
default:
error_print("invalid mouse action\n");
exit(EXIT_FAILURE);
}
if (sendTouch)
{
// Then send a ABS_MT_TRACKING_ID
gettimeofday(&time, 0);
ev.input_event_sec = time.tv_sec;
ev.type = EV_ABS;
ev.code = ABS_MT_TRACKING_ID;
ev.value = trkIdValue;
if (write(touchfd, &ev, sizeof(ev)) < 0)
{
error_print("write event failed, %s\n", strerror(errno));
}
// Then send a BTN_TOUCH
gettimeofday(&time, 0);
ev.input_event_sec = time.tv_sec;
ev.input_event_usec = time.tv_usec;
ev.type = EV_KEY;
ev.code = BTN_TOUCH;
ev.value = touchValue;
if (write(touchfd, &ev, sizeof(ev)) < 0)
{
error_print("write event failed, %s\n", strerror(errno));
}
}
if (sendPos)
{
// Then send a ABS_MT_POSITION_X
gettimeofday(&time, 0);
ev.input_event_sec = time.tv_sec;
ev.input_event_usec = time.tv_usec;
ev.type = EV_ABS;
ev.code = ABS_MT_POSITION_X;
ev.value = x;
if (write(touchfd, &ev, sizeof(ev)) < 0)
{
error_print("write event failed, %s\n", strerror(errno));
}
// Then send a ABS_MT_POSITION_Y
gettimeofday(&time, 0);
ev.input_event_sec = time.tv_sec;
ev.input_event_usec = time.tv_usec;
ev.type = EV_ABS;
ev.code = ABS_MT_POSITION_Y;
ev.value = y;
if (write(touchfd, &ev, sizeof(ev)) < 0)
{
error_print("write event failed, %s\n", strerror(errno));
}
// Then send the X
gettimeofday(&time, 0);
ev.input_event_sec = time.tv_sec;
ev.input_event_usec = time.tv_usec;
ev.type = EV_ABS;
ev.code = ABS_X;
ev.value = x;
if (write(touchfd, &ev, sizeof(ev)) < 0)
{
error_print("write event failed, %s\n", strerror(errno));
}
// Then send the Y
gettimeofday(&time, 0);
ev.input_event_sec = time.tv_sec;
ev.input_event_usec = time.tv_usec;
ev.type = EV_ABS;
ev.code = ABS_Y;
ev.value = y;
if (write(touchfd, &ev, sizeof(ev)) < 0)
{
error_print("write event failed, %s\n", strerror(errno));
}
}
// Finally send the SYN
gettimeofday(&time, 0);
ev.input_event_sec = time.tv_sec;
ev.input_event_usec = time.tv_usec;
ev.type = EV_SYN;
ev.code = 0;
ev.value = 0;
if (write(touchfd, &ev, sizeof(ev)) < 0)
{
error_print("write event failed, %s\n", strerror(errno));
}
debug_print("injectTouchEvent (screen(%d,%d) -> touch(%d,%d), mouse=%d)\n", xin, yin, x, y, mouseAction);
}
================================================
FILE: src/touch.h
================================================
#pragma once
enum MouseAction
{
MouseDrag = -1,
MouseRelease,
MousePress
};
int init_touch(const char *touch_device, int vnc_rotate);
void cleanup_touch();
void injectTouchEvent(enum MouseAction mouseAction, int x, int y, struct fb_var_screeninfo *scrinfo);
================================================
FILE: tests/vfb/Makefile
================================================
ifneq ($(KERNELRELEASE),)
obj-m := vfb.o
else
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
all:
$(MAKE) -C $(KDIR) M=$(shell pwd) modules
install:
$(MAKE) -C $(KDIR) M=$(shell pwd) modules_install
%:
$(MAKE) -C $(KDIR) M=$(shell pwd) $@
endif
================================================
FILE: tests/vfb/README
================================================
https://github.com/torvalds/linux/blob/v4.15/drivers/video/fbdev/vfb.c
This is a `virtual' frame buffer device. It operates on a chunk of
unswappable kernel memory instead of on the memory of a graphics
board. This means you cannot see any output sent to this frame
buffer device, while it does consume precious memory. The main use
of this frame buffer device is testing and debugging the frame
buffer subsystem. Do NOT enable it for normal systems! To protect
the innocent, it has to be enabled explicitly at boot time using the
kernel option `video=vfb:'.
================================================
FILE: tests/vfb/ins.sh
================================================
#!/bin/sh
modinfo vfb.ko
sudo modprobe fb_sys_fops
sudo modprobe sysfillrect
sudo modprobe syscopyarea
sudo modprobe sysimgblt
sudo insmod vfb.ko vfb_enable=1 videomemorysize=32000000
================================================
FILE: vagrant.sh
================================================
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
sudo update-locale LANG=en_US.UTF-8 LANGUAGE=en.UTF-8
# tools
sudo apt-get update
sudo apt-get install -y mc htop
sudo apt-get install -y evtest
sudo apt-get install -y xvfb
sudo apt-get install -y python3-pip
sudo apt-get install -y libvncserver-dev
sudo apt-get install -y build-essential flex bison
sudo apt-get install -y cmake
sudo apt-get install -y qt5-qmake
sudo apt-get install -y qt5-qmake-bin
sudo apt-get install -y qtbase5-dev
sudo apt-get install -y linux-source libssl-dev libelf-dev
sudo apt-get install -y fbset fbcat fbterm fbi
sudo apt-get install -y qmlscene
sudo apt-get install -y x11vnc
sudo pip3 install entrypoint2
# fb-test
cd /home/vagrant
git clone https://github.com/ponty/fb-test-app.git
cd fb-test-app
make
cp perf /usr/local/bin
cp rect /usr/local/bin
cp fb-test /usr/local/bin
cp fb-string /usr/local/bin
# vfb
cd /home/vagrant
tar xaf /usr/src/linux-source-*.tar.*
#cd linux-source-*/
mkdir -p vfb && cd vfb
ln -s /home/vagrant/linux-source-*/drivers/video/fbdev/vfb.c vfb.c
ln -s /vagrant/tests/vfb/ins.sh ins.sh
ln -s /vagrant/tests/vfb/Makefile Makefile
make
#./ins.sh
echo '#!/bin/bash
modinfo /home/vagrant/vfb/vfb.ko
modprobe fb_sys_fops
modprobe sysfillrect
modprobe syscopyarea
modprobe sysimgblt
insmod /home/vagrant/vfb/vfb.ko vfb_enable=1 videomemorysize=32000000
' >/usr/local/bin/vfbload.sh
chmod +x /usr/local/bin/vfbload.sh
/usr/local/bin/vfbload.sh >/tmp/vfbload.log 2>&1
echo 'ENV{ID_INPUT_MOUSE}=="?*",ENV{ID_PATH}=="pci-0000:00:04.0", SYMLINK+="input/ms"' >/etc/udev/rules.d/98-input.rules
echo 'ENV{ID_INPUT_KEYBOARD}=="?*", SYMLINK+="input/kbd"' >>/etc/udev/rules.d/98-input.rules
udevadm control --reload-rules
udevadm trigger
echo 'SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
@reboot root vfbload.sh;sleep 0.1;fbset -g 640 480 640 480 16;/home/vagrant/build/framebuffer-vncserver -t /dev/input/ms -k /dev/input/kbd > /tmp/framebuffer-vncserver.log 2>&1
' >/etc/cron.d/framebuffer-vncserver
# https://askubuntu.com/questions/168279/how-do-i-build-a-single-in-tree-kernel-module
# https://askubuntu.com/questions/515407/how-recipe-to-build-only-one-kernel-module
#cd /usr/src/
#tar xaf linux-source-*.tar.*
#cd linux-source-*/
#make oldconfig # it copies .config to ./
#echo 'CONFIG_FB_VIRTUAL=m' >> .config
#make scripts
#make drivers/video/fbdev/vfb.ko
# cmake build
cd /home/vagrant
mkdir -p build && cd build
cmake /vagrant
make
# qmake build
cd /home/vagrant
mkdir -p buildqt && cd buildqt
qmake /vagrant
make
fbset -g 640 480 640 480 16
/home/vagrant/build/framebuffer-vncserver -t /dev/input/ms -k /dev/input/kbd >/tmp/framebuffer-vncserver.log 2>&1 &
================================================
FILE: vfb.py
================================================
import os
import sys
import threading
import time
from pathlib import Path
from tempfile import TemporaryDirectory
from time import sleep
import fabric
import vagrant
from entrypoint2 import entrypoint
from PIL import Image, ImageChops
from vncdotool import api
# pip3 install fabric vncdotool python-vagrant entrypoint2
print(sys.version)
def build(conn):
# with c.cd("/home/vagrant/build"): # bug in invoke: https://github.com/pyinvoke/invoke/issues/459
conn.sudo('sh -c "cd /home/vagrant/build;cmake /vagrant"')
conn.sudo('sh -c "cd /home/vagrant/build;make"')
def set_resolution(conn, *res):
(w, h, depth) = res
conn.sudo("fbset -g %s %s %s %s %s" % (w, h, w, h, depth))
def run_in_background(conn, cmd):
# https://docs.fabfile.org/en/1.3.8/faq.html#why-can-t-i-run-programs-in-the-background-with-it-makes-fabric-hang
def thread_function(a):
conn.sudo(cmd, pty=False, warn=True)
x = threading.Thread(target=thread_function, args=(1,))
x.start()
def start_server(conn, rotation, res):
conn.sudo("killall framebuffer-vncserver", warn=True)
command = f"/home/vagrant/build/framebuffer-vncserver -r {rotation}"
print(f"command: {command}")
run_in_background(conn, command)
def start_server_x11vnc(conn, rotation, res):
(w, h, depth) = res
conn.sudo("killall framebuffer-vncserver", warn=True)
conn.sudo("killall x11vnc", warn=True)
command = f"/usr/bin/x11vnc -shared -forever -rawfb map:/dev/fb0@{w}x{h}x{depth}"
print(f"command: {command}")
run_in_background(conn, command)
def cls(conn):
conn.sudo("dd if=/dev/zero of=/dev/fb0", warn=True)
def grab():
with TemporaryDirectory() as tmpdirname:
f = Path(tmpdirname) / "grab.png"
with api.connect("localhost:0") as client:
client.timeout = 5
client.captureScreen(f)
im = Image.open(f)
return im
def _grab_and_sleep(blink_time):
start = time.time()
im = grab()
dt = time.time() - start
t = blink_time / 4.0 - dt
if t > 0:
sleep(t)
return im
def img_list_min(ls):
immin = ls[0]
for im in ls[1:]:
# ImageChops.subtract= max((a-b),0)
diff = ImageChops.subtract(immin, im)
immin = ImageChops.subtract(immin, diff)
return immin
def grab_no_blink(blink_time=1.2):
lsim = [_grab_and_sleep(blink_time) for _ in range(4)]
im = img_list_min(lsim)
return im
def shot(conn, directory, png, rotation, *res):
(w, h, depth) = res
set_resolution(conn, *res)
start_server(conn, rotation, res)
if depth != 8:
cls(conn)
run_in_background(conn, "qmlscene -platform linuxfb")
sleep(0.5)
grab_no_blink().save(directory + "qmlscene_" + png)
conn.sudo("killall qmlscene")
if depth > 1:
cls(conn)
conn.sudo("fb-test")
grab().save(directory + "fbtest_" + png)
cls(conn)
conn.sudo(
f"python3 /vagrant/gradient.py --width {w} --height {h} --colorbit {depth}"
)
grab().save(directory + "gradient_" + png)
IMGDIR = "img/"
def tshot(conn, rotation, *res):
(w, h, depth) = res
fname = f"{w}x{h}_c{depth}_rot{rotation}.png"
shot(conn, IMGDIR, fname, rotation, *res)
w, h = 160, 120
@entrypoint
def main():
v = vagrant.Vagrant()
v.up()
with fabric.Connection(
v.user_hostname_port(),
connect_kwargs={
"key_filename": v.keyfile(),
},
) as conn:
build(conn)
os.makedirs(IMGDIR, exist_ok=True)
for f in Path(IMGDIR).glob("*.png"):
f.unlink()
conn.sudo("killall qmlscene", warn=True)
for rot in [0]:
tshot(conn, rot, w, h, 1)
tshot(conn, rot, w, h, 8)
tshot(conn, rot, w, h, 16)
tshot(conn, rot, w, h, 24)
tshot(conn, rot, w, h, 32)
for rot in [90, 180, 270]:
tshot(conn, rot, w, h, 16)
================================================
FILE: yocto/framebuffer-vncserver_git.bb
================================================
DESCRIPTION = "VNC server running on top of framebuffer"
HOMEPAGE = "https://github.com/ponty/framebuffer-vncserver"
LICENSE = "GPLv2"
DEPENDS = "libvncserver"
RDEPENDS_${PN} = "libvncserver"
SRC_URI = "git://github.com/ponty/framebuffer-vncserver.git"
LIC_FILES_CHKSUM = "file://LICENSE;md5=8264535c0c4e9c6c335635c4026a8022"
PR = "r1"
PR_append = "+gitr${SRCPV}"
S = "${WORKDIR}/git"
inherit cmake
SRCREV = "d3450b1a5ba7ebd7c3b6bcf5affda0975441cee2"
gitextract_gwh7gede/
├── .git/
│ ├── HEAD
│ ├── config
│ ├── description
│ ├── hooks/
│ │ ├── applypatch-msg.sample
│ │ ├── commit-msg.sample
│ │ ├── fsmonitor-watchman.sample
│ │ ├── post-update.sample
│ │ ├── pre-applypatch.sample
│ │ ├── pre-commit.sample
│ │ ├── pre-merge-commit.sample
│ │ ├── pre-push.sample
│ │ ├── pre-rebase.sample
│ │ ├── pre-receive.sample
│ │ ├── prepare-commit-msg.sample
│ │ ├── push-to-checkout.sample
│ │ ├── sendemail-validate.sample
│ │ └── update.sample
│ ├── index
│ ├── info/
│ │ └── exclude
│ ├── logs/
│ │ ├── HEAD
│ │ └── refs/
│ │ ├── heads/
│ │ │ └── master
│ │ └── remotes/
│ │ └── origin/
│ │ └── HEAD
│ ├── objects/
│ │ └── pack/
│ │ ├── pack-bef8852657c06b106e38622c43f30aebfe12ac48.idx
│ │ ├── pack-bef8852657c06b106e38622c43f30aebfe12ac48.pack
│ │ ├── pack-bef8852657c06b106e38622c43f30aebfe12ac48.promisor
│ │ └── pack-bef8852657c06b106e38622c43f30aebfe12ac48.rev
│ ├── packed-refs
│ ├── refs/
│ │ ├── heads/
│ │ │ └── master
│ │ └── remotes/
│ │ └── origin/
│ │ └── HEAD
│ └── shallow
├── .github/
│ └── workflows/
│ └── main.yml
├── .gitignore
├── .travis.yml.bak
├── CMakeLists.txt
├── Dockerfile
├── LICENSE
├── README.md
├── Vagrantfile
├── Vagrantfile.20.04.rb
├── deployment.pri
├── fbvnc.service
├── format-code.sh
├── framebuffer-vncserver.pro
├── gradient.py
├── src/
│ ├── framebuffer-vncserver.c
│ ├── keyboard.c
│ ├── keyboard.h
│ ├── logging.h
│ ├── mouse.c
│ ├── mouse.h
│ ├── touch.c
│ └── touch.h
├── tests/
│ └── vfb/
│ ├── Makefile
│ ├── README
│ └── ins.sh
├── vagrant.sh
├── vfb.py
└── yocto/
└── framebuffer-vncserver_git.bb
SYMBOL INDEX (42 symbols across 8 files) FILE: gradient.py function gradient (line 13) | def gradient(width=320, height=240, colorbit=32, fileout="/dev/fb0"): FILE: src/framebuffer-vncserver.c type fb_var_screeninfo (line 58) | struct fb_var_screeninfo type fb_fix_screeninfo (line 59) | struct fb_fix_screeninfo type varblock_t (line 81) | struct varblock_t function init_fb (line 96) | static void init_fb(void) function cleanup_fb (line 150) | static void cleanup_fb(void) function keyevent (line 159) | static void keyevent(rfbBool down, rfbKeySym key, rfbClientPtr cl) function ptrevent_touch (line 171) | static void ptrevent_touch(int buttonMask, int x, int y, rfbClientPtr cl) function ptrevent_mouse (line 208) | static void ptrevent_mouse(int buttonMask, int x, int y, rfbClientPtr cl) function init_fb_server (line 227) | static void init_fb_server(int argc, char **argv, rfbBool enable_touch, ... function timeToLogFPS (line 282) | int timeToLogFPS() function update_screen (line 301) | static void update_screen(void) function print_usage (line 597) | void print_usage(char **argv) function main (line 613) | int main(int argc, char **argv) FILE: src/keyboard.c function init_kbd (line 34) | int init_kbd(const char *kbd_device) function cleanup_kbd (line 48) | void cleanup_kbd() function injectKeyEvent (line 56) | void injectKeyEvent(uint16_t code, uint16_t value) function keysym2scancode (line 90) | int keysym2scancode(rfbKeySym key, rfbClientPtr cl) FILE: src/mouse.c type map_t (line 39) | typedef struct function init_mouse (line 50) | int init_mouse(const char *touch_device, int vnc_rotate) function cleanup_mouse (line 102) | void cleanup_mouse() function injectMouseEvent (line 110) | void injectMouseEvent(struct fb_var_screeninfo *scrinfo, int buttonMask,... FILE: src/mouse.h type fb_var_screeninfo (line 5) | struct fb_var_screeninfo FILE: src/touch.c function init_touch (line 38) | int init_touch(const char *touch_device, int vnc_rotate) function cleanup_touch (line 68) | void cleanup_touch() function injectTouchEvent (line 76) | void injectTouchEvent(enum MouseAction mouseAction, int x, int y, struct... FILE: src/touch.h type MouseAction (line 3) | enum MouseAction type MouseAction (line 12) | enum MouseAction type fb_var_screeninfo (line 12) | struct fb_var_screeninfo FILE: vfb.py function build (line 22) | def build(conn): function set_resolution (line 28) | def set_resolution(conn, *res): function run_in_background (line 33) | def run_in_background(conn, cmd): function start_server (line 43) | def start_server(conn, rotation, res): function start_server_x11vnc (line 50) | def start_server_x11vnc(conn, rotation, res): function cls (line 59) | def cls(conn): function grab (line 63) | def grab(): function _grab_and_sleep (line 73) | def _grab_and_sleep(blink_time): function img_list_min (line 83) | def img_list_min(ls): function grab_no_blink (line 92) | def grab_no_blink(blink_time=1.2): function shot (line 98) | def shot(conn, directory, png, rotation, *res): function tshot (line 126) | def tshot(conn, rotation, *res): function main (line 136) | def main():
Condensed preview — 58 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (127K chars).
[
{
"path": ".git/HEAD",
"chars": 23,
"preview": "ref: refs/heads/master\n"
},
{
"path": ".git/config",
"chars": 359,
"preview": "[core]\n\trepositoryformatversion = 1\n\tfilemode = true\n\tbare = false\n\tlogallrefupdates = true\n[remote \"origin\"]\n\turl = htt"
},
{
"path": ".git/description",
"chars": 73,
"preview": "Unnamed repository; edit this file 'description' to name the repository.\n"
},
{
"path": ".git/hooks/applypatch-msg.sample",
"chars": 478,
"preview": "#!/bin/sh\n#\n# An example hook script to check the commit log message taken by\n# applypatch from an e-mail message.\n#\n# T"
},
{
"path": ".git/hooks/commit-msg.sample",
"chars": 896,
"preview": "#!/bin/sh\n#\n# An example hook script to check the commit log message.\n# Called by \"git commit\" with one argument, the na"
},
{
"path": ".git/hooks/fsmonitor-watchman.sample",
"chars": 4726,
"preview": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\nuse IPC::Open2;\n\n# An example hook script to integrate Watchman\n# (https://fa"
},
{
"path": ".git/hooks/post-update.sample",
"chars": 189,
"preview": "#!/bin/sh\n#\n# An example hook script to prepare a packed repository for use over\n# dumb transports.\n#\n# To enable this h"
},
{
"path": ".git/hooks/pre-applypatch.sample",
"chars": 424,
"preview": "#!/bin/sh\n#\n# An example hook script to verify what is about to be committed\n# by applypatch from an e-mail message.\n#\n#"
},
{
"path": ".git/hooks/pre-commit.sample",
"chars": 1649,
"preview": "#!/bin/sh\n#\n# An example hook script to verify what is about to be committed.\n# Called by \"git commit\" with no arguments"
},
{
"path": ".git/hooks/pre-merge-commit.sample",
"chars": 416,
"preview": "#!/bin/sh\n#\n# An example hook script to verify what is about to be committed.\n# Called by \"git merge\" with no arguments."
},
{
"path": ".git/hooks/pre-push.sample",
"chars": 1374,
"preview": "#!/bin/sh\n\n# An example hook script to verify what is about to be pushed. Called by \"git\n# push\" after it has checked t"
},
{
"path": ".git/hooks/pre-rebase.sample",
"chars": 4898,
"preview": "#!/bin/sh\n#\n# Copyright (c) 2006, 2008 Junio C Hamano\n#\n# The \"pre-rebase\" hook is run just before \"git rebase\" starts d"
},
{
"path": ".git/hooks/pre-receive.sample",
"chars": 544,
"preview": "#!/bin/sh\n#\n# An example hook script to make use of push options.\n# The example simply echoes all push options that star"
},
{
"path": ".git/hooks/prepare-commit-msg.sample",
"chars": 1492,
"preview": "#!/bin/sh\n#\n# An example hook script to prepare the commit log message.\n# Called by \"git commit\" with the name of the fi"
},
{
"path": ".git/hooks/push-to-checkout.sample",
"chars": 2783,
"preview": "#!/bin/sh\n\n# An example hook script to update a checked-out tree on a git push.\n#\n# This hook is invoked by git-receive-"
},
{
"path": ".git/hooks/sendemail-validate.sample",
"chars": 2308,
"preview": "#!/bin/sh\n\n# An example hook script to validate a patch (and/or patch series) before\n# sending it via email.\n#\n# The hoo"
},
{
"path": ".git/hooks/update.sample",
"chars": 3650,
"preview": "#!/bin/sh\n#\n# An example hook script to block unannotated tags from entering.\n# Called by \"git receive-pack\" with argume"
},
{
"path": ".git/info/exclude",
"chars": 240,
"preview": "# git ls-files --others --exclude-from=.git/info/exclude\n# Lines that start with '#' are comments.\n# For a project mostl"
},
{
"path": ".git/logs/HEAD",
"chars": 196,
"preview": "0000000000000000000000000000000000000000 1963e57bebfde420baeecbb2c6848a2382488413 appuser <appuser@7c99e0e64a07.(none)> "
},
{
"path": ".git/logs/refs/heads/master",
"chars": 196,
"preview": "0000000000000000000000000000000000000000 1963e57bebfde420baeecbb2c6848a2382488413 appuser <appuser@7c99e0e64a07.(none)> "
},
{
"path": ".git/logs/refs/remotes/origin/HEAD",
"chars": 196,
"preview": "0000000000000000000000000000000000000000 1963e57bebfde420baeecbb2c6848a2382488413 appuser <appuser@7c99e0e64a07.(none)> "
},
{
"path": ".git/objects/pack/pack-bef8852657c06b106e38622c43f30aebfe12ac48.promisor",
"chars": 59,
"preview": "1963e57bebfde420baeecbb2c6848a2382488413 refs/heads/master\n"
},
{
"path": ".git/packed-refs",
"chars": 114,
"preview": "# pack-refs with: peeled fully-peeled sorted \n1963e57bebfde420baeecbb2c6848a2382488413 refs/remotes/origin/master\n"
},
{
"path": ".git/refs/heads/master",
"chars": 41,
"preview": "1963e57bebfde420baeecbb2c6848a2382488413\n"
},
{
"path": ".git/refs/remotes/origin/HEAD",
"chars": 32,
"preview": "ref: refs/remotes/origin/master\n"
},
{
"path": ".git/shallow",
"chars": 41,
"preview": "1963e57bebfde420baeecbb2c6848a2382488413\n"
},
{
"path": ".github/workflows/main.yml",
"chars": 847,
"preview": "# For more information see: \n# https://docs.github.com/en/actions/automating-builds-and-tests/\n\nname: build\n\non:\n sche"
},
{
"path": ".gitignore",
"chars": 305,
"preview": "# C++ objects and libs\n\n*.slo\n*.lo\n*.o\n*.a\n*.la\n*.lai\n*.so\n*.dll\n*.dylib\n\n# Qt-es\n\n/.qmake.cache\n/.qmake.stash\n*.pro.use"
},
{
"path": ".travis.yml.bak",
"chars": 268,
"preview": "language: c\ninstall:\n - sudo apt-get update -qq\n - sudo apt-get install -y libvncserver-dev cmake qt4-qmake \n\nscript: \n"
},
{
"path": "CMakeLists.txt",
"chars": 372,
"preview": "PROJECT(framebuffer-vncserver)\nCMAKE_MINIMUM_REQUIRED(VERSION 2.6)\n\n\nFILE(GLOB SOURCES src/*.c)\nADD_EXECUTABLE(framebuff"
},
{
"path": "Dockerfile",
"chars": 408,
"preview": "FROM alpine as builder\nLABEL maintainer=\"ek5.chimenti@gmail.com\"\n\nADD . /target/\nWORKDIR /target\n\nRUN apk fetch\nRUN apk "
},
{
"path": "LICENSE",
"chars": 18027,
"preview": "GNU GENERAL PUBLIC LICENSE\n Version 2, June 1991\n\n Copyright (C) 1989, 1991 Free Software Foundati"
},
{
"path": "README.md",
"chars": 7553,
"preview": "# framebuffer-vncserver\n\nVNC server for Linux framebuffer devices.\n\n do |config|\n config.vm.box = \"ubuntu/jammy64\"\n\n config.vm.network \"forwarded_port\", guest: 5900, "
},
{
"path": "Vagrantfile.20.04.rb",
"chars": 693,
"preview": "Vagrant.configure(2) do |config|\n config.vm.box = \"ubuntu/focal64\"\n\n config.vm.network \"forwarded_port\", guest: 5900, "
},
{
"path": "deployment.pri",
"chars": 6817,
"preview": "# This file was generated by an application wizard of Qt Creator.\n# The code below handles deployment to Android and Mae"
},
{
"path": "fbvnc.service",
"chars": 266,
"preview": "[Unit]\nDescription=Framebuffer VNC Server for 3.5\" TFT Display\n\n[Service]\nType=simple\nPIDFile=/var/run/fbvnc.pid\nExecSta"
},
{
"path": "format-code.sh",
"chars": 127,
"preview": "#!/bin/bash\nset -e\nautoflake -i -r --remove-all-unused-imports .\nautoflake -i -r --remove-unused-variables .\nisort .\nb"
},
{
"path": "framebuffer-vncserver.pro",
"chars": 275,
"preview": "TEMPLATE = app\nCONFIG += console\nCONFIG -= app_bundle\nCONFIG -= qt\n\nSOURCES += src/framebuffer-vncserver.c\nSOURCES += sr"
},
{
"path": "gradient.py",
"chars": 520,
"preview": "from entrypoint2 import entrypoint\n\n# last color channel\nchan = {\n 8: 0x07,\n 16: 0x1F,\n 24: 0xFF,\n 32: 0xFF,"
},
{
"path": "src/framebuffer-vncserver.c",
"chars": 24092,
"preview": "/*\n * $Id$\n *\n * This program is free software; you can redistribute it and/or modify it\n * under the terms of the GNU G"
},
{
"path": "src/keyboard.c",
"chars": 7280,
"preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include <unistd.h>\n#include <sys/mman.h>\n#include <sys/ioct"
},
{
"path": "src/keyboard.h",
"chars": 157,
"preview": "#pragma once\n\nint init_kbd(const char *);\nvoid cleanup_kbd();\n\nvoid injectKeyEvent(uint16_t, uint16_t);\nint keysym2scanc"
},
{
"path": "src/logging.h",
"chars": 625,
"preview": "#pragma once\n\n#define error_print(...) \\\n do \\\n { "
},
{
"path": "src/mouse.c",
"chars": 7467,
"preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdbool.h>\n#include <unistd.h>\n#include <sys/mman.h"
},
{
"path": "src/mouse.h",
"chars": 182,
"preview": "#pragma once\n\nint init_mouse(const char *touch_device, int vnc_rotate);\nvoid cleanup_mouse();\nvoid injectMouseEvent(stru"
},
{
"path": "src/touch.c",
"chars": 5684,
"preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdbool.h>\n#include <unistd.h>\n#include <sys/mman.h"
},
{
"path": "src/touch.h",
"chars": 272,
"preview": "#pragma once\n\nenum MouseAction\n{\n MouseDrag = -1,\n MouseRelease,\n MousePress\n};\n\nint init_touch(const char *tou"
},
{
"path": "tests/vfb/Makefile",
"chars": 275,
"preview": "ifneq ($(KERNELRELEASE),)\nobj-m := vfb.o\nelse\nKDIR := /lib/modules/$(shell uname -r)/build\nPWD := $(shell pwd)\n"
},
{
"path": "tests/vfb/README",
"chars": 560,
"preview": "https://github.com/torvalds/linux/blob/v4.15/drivers/video/fbdev/vfb.c\n\nThis is a `virtual' frame buffer device. It oper"
},
{
"path": "tests/vfb/ins.sh",
"chars": 186,
"preview": "#!/bin/sh\nmodinfo vfb.ko\nsudo modprobe fb_sys_fops\nsudo modprobe sysfillrect\nsudo modprobe syscopyarea\nsudo modprobe sys"
},
{
"path": "vagrant.sh",
"chars": 2720,
"preview": "#!/bin/bash\nexport DEBIAN_FRONTEND=noninteractive\nsudo update-locale LANG=en_US.UTF-8 LANGUAGE=en.UTF-8\n\n# tools\nsudo ap"
},
{
"path": "vfb.py",
"chars": 3994,
"preview": "import os\nimport sys\nimport threading\nimport time\nfrom pathlib import Path\nfrom tempfile import TemporaryDirectory\nfrom "
},
{
"path": "yocto/framebuffer-vncserver_git.bb",
"chars": 453,
"preview": "DESCRIPTION = \"VNC server running on top of framebuffer\"\nHOMEPAGE = \"https://github.com/ponty/framebuffer-vncserver\"\nLIC"
}
]
// ... and 4 more files (download for full content)
About this extraction
This page contains the full source code of the ponty/framebuffer-vncserver GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 58 files (115.8 KB), approximately 33.4k tokens, and a symbol index with 42 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.