Commit 54add433 authored by Krayon's avatar Krayon

RELEASE: 0.2.3

Merge branch 'release/0.2.3'
parents 5c8a2b8b 41868085
......@@ -4,6 +4,7 @@
== RatSlap Contributors ==
-
[[ https://github.com/captn3m0 | Nemo ]]
* [[ https://github.com/krayon/ratslap/pull/14 | GitHub PR #14 ]]
<<< vim:set ts=4 sw=4 tw=80 et cindent ai si syn=creole: >>>
= Contributing =
== Pull Requests ==
== Making Changes ==
If you have a pull request (PR) for a change or a fix, please try to base your
changes off develop unless it's a serious security issue with a specific release
in which case base it off that.
Don't be too concerned if you can't deside, an incorrectly targeted PR is better
than no PR :D
Wherever possible, please base your changes on the //develop// branch. The one
exception is if you have a fix for a security issue in a specific release in
which case base it off that release branch. Either way, don't be too concerned
if you can't decide what to branch off, an incorrectly targeted PR is better
than no PR at all :D
... and Thank you.
== Basic workflow ==
# Go to the project page, and select //Fork//
# Clone your copy of the repository:
{{{
git clone https://gitlab.com/<YOURUSERNAME>/ratslap
}}}
# Check out the //develop// branch as your new feature branch:
{{{
git checkout -b feature/coolnewfeature origin/develop
}}}
# Make your changes and commit them to your branch.
# Push your branch up to your repository:
{{{
git push origin feature/coolnewfeature:feature/coolnewfeature
}}}
# Create a Pull Request (PR - GitHub)/Merge Request (MR - GitLab) with
//develop// as the base/destination.
<<< vim:set ts=4 sw=4 tw=80 et cindent ai si syn=creole: >>>
......@@ -37,15 +37,44 @@ please see [[CONTRIBUTING.creole]] .
== Availability ==
//RatSlap// source is available on [[https://gitlab.com/krayon/ratslap|GitLab]],
[[https://github.com/krayon/ratslap|GitHub]] and
[[https://bitbucket.org/krayonx/ratslap|BitBucket]] with the primary (public)
repository being [[https://gitlab.com/krayon/ratslap|GitLab]].
The most current release is v0.2.3 and is available from:
* [[https://gitlab.com/krayon/ratslap/tags/0.2.3|GitLab (RELEASE v0.2.3)]]
* [[https://github.com/krayon/ratslap/releases/tag/0.2.3|GitHub (RELEASE v0.2.3)]]
//RatSlap// binary and archive should be signed with my GPG key (
[[http://pgp.mit.edu/pks/lookup?op=get&search=0x231A94F481ECF212|231A 94F4 81EC F212]]
).
Binary signature files end in .asc and can be verified using
[[https://www.gnupg.org/|gpg/gpg2]] thus:
{{{
gpg --verify ratslap-0.2.2.x86_64.tar.gz.asc
gpg: assuming signed data in `ratslap-0.2.2.x86_64.tar.gz'
gpg: Signature made 2018-05-01T01:00:52 AEST using RSA key ID 81ECF212
gpg: Good signature from "Krayon (Code Signing Key) <krayon.git@qdnx.org>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: CDEC 1051 0874 06FB 8323 46DC 231A 94F4 81EC F212
}}}
You may first need to retrieve my public key if you haven't already done so:
{{{
gpg --recv-keys 81ECF212
gpg: keyring `/home/krayon//.gnupg/secring.gpg' created
gpg: requesting key 81ECF212 from hkp server keys.gnupg.net
gpg: /home/krayon//.gnupg/trustdb.gpg: trustdb created
gpg: key 81ECF212: public key "Krayon (Code Signing Key) <krayon.git@qdnx.org>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
}}}
//RatSlap// source is available on [[https://gitlab.com/krayon/ratslap|GitLab]],
[[https://github.com/krayon/ratslap|GitHub]] and
[[https://bitbucket.org/krayonx/ratslap|BitBucket]] with the primary (public)
repository being [[https://gitlab.com/krayon/ratslap|GitLab]].
== Bug Tracker ==
Bugs are tracked on the
......@@ -254,14 +283,19 @@ tool cannot do).
** Prettier Changelog
** Added man page
* v0.2.2
** [[https://bugs.qdnx.org/121|QB#121 - set_debug is deprecated, use libusb_set_option instead]]
** [[https://bugs.qdnx.org/bug/121|QB#121 - set_debug is deprecated, use libusb_set_option instead]]
** Added some documentation: AUTHORS, CONTRIBUTING
* v0.2.3
** [[https://bugs.qdnx.org/bug/122|QB#122 - Help shouldn't require USB permissions]]
** [[https://bugs.qdnx.org/bug/123|QB#123 - Check mode_load() return code]]
** [[https://bugs.qdnx.org/bug/124|QB#124 - Failed operations don't abort execution]]
== TODO ==
* [[https://bugs.qdnx.org/bug/113|QB#113 - Configure DPI #[1-4], DPI Default and * DPI Shift values]]
* [[https://bugs.qdnx.org/bug/114|QB#114 - Factory reset option]]
* [[https://bugs.qdnx.org/bug/115|QB#115 - Ability to save/load profiles]]
* BUG: [[https://bugs.qdnx.org/bug/125|QB#125 - Error assigning Num+]]
* FEATURE: [[https://bugs.qdnx.org/bug/113|QB#113 - Configure DPI #[1-4], DPI Default and * DPI Shift values]]
* FEATURE: [[https://bugs.qdnx.org/bug/114|QB#114 - Factory reset option]]
* FEATURE: [[https://bugs.qdnx.org/bug/115|QB#115 - Ability to save/load profiles]]
== Notes ==
......
......@@ -391,15 +391,44 @@ const int report_rate[] = {
};
const int n_report_rates = 4;
static int dpi_point(int dpip) {
return dpip * 250;
}
libusb_context *usb_ctx = NULL;
libusb_device_handle *usb_dev_handle = NULL;
libusb_device *usb_device = NULL;
struct libusb_device_descriptor usb_desc;
int usb_interface_index = -1;
int mouse_primed = 0;
static int dpi_point(int dpip);
static void help_version(void);
static void help_usage(void);
static void keylist_print(void);
static libusb_context *usb_init(void);
static int usb_deinit(void);
static libusb_device_handle *mouse_init(const uint16_t vendor_id, const uint16_t product_id, const char* product_name);
static int mouse_deinit(void);
static void display_mouse_hid(const uint16_t vendor_id, const uint16_t product_id);
int mouse_hid_detach_kernel(int iface);
int mouse_hid_attach_kernel(int iface);
static t_mode change_mode(libusb_device_handle *usb_dev_handle, t_mode mode);
static int mode_load(unsigned char *mode_data, libusb_device_handle *usb_dev_handle, t_mode mode);
static int mode_save(unsigned char *mode_data, libusb_device_handle *usb_dev_handle, const t_mode mode);
static int mode_print(unsigned char *mode_data, int len);
static int set_mode_rate(unsigned char *mode_data, const int rate);
static unsigned char set_mode_colour(unsigned char *mode_data, const t_colour colour);
static int set_mode_button(unsigned char *mode_data, const unsigned char button, const char *keys);
static int mouse_editmode(void);
int mouse_prime(void);
int mouse_unprime(void);
static int dpi_point(int dpip) {
return dpip * 250;
}
static void help_version(void) {
printf("%s v%s (BUILT: %s)\n", (APP_NAME), (APP_VERSION), (BUILD_DATE));
......@@ -740,7 +769,7 @@ static t_mode change_mode(libusb_device_handle *usb_dev_handle, t_mode mode) {
int ret;
if (!usb_dev_handle || mode >= mode_COUNT) return mode_COUNT;
if (!mouse_primed || !usb_dev_handle || mode >= mode_COUNT) return mode_COUNT;
if (mode == mode_f3) {
// Top Mode
......@@ -791,7 +820,7 @@ static int mode_load(unsigned char *mode_data, libusb_device_handle *usb_dev_han
uint16_t mi;
int ret;
if (!mode_data || !usb_dev_handle || mode >= mode_COUNT) return 0;
if (!mouse_primed || !mode_data || !usb_dev_handle || mode >= mode_COUNT) return 0;
if (mode == mode_f3) mi = 0xf3;
else if (mode == mode_f4) mi = 0xf4;
......@@ -838,7 +867,7 @@ static int mode_save(unsigned char *mode_data, libusb_device_handle *usb_dev_han
unsigned char cmp[255];
if (!mode_data || !usb_dev_handle || mode >= mode_COUNT) return 0;
if (!mouse_primed || !mode_data || !usb_dev_handle || mode >= mode_COUNT) return 0;
if (mode == mode_f3) mi = 0xf3;
else if (mode == mode_f4) mi = 0xf4;
......@@ -1094,6 +1123,8 @@ static int set_mode_button(unsigned char *mode_data, const unsigned char button,
++ky;
}
// FIXME: QB#125 - Handle Keys containing '+' (currently only "Num+")
// If it's not the last element...
if (*kptr) {
// And didn't match a modifier, BAD!
......@@ -1148,8 +1179,9 @@ static int set_mode_button(unsigned char *mode_data, const unsigned char button,
return 1;
}
static int mouse_editmode(void) {
if (!usb_dev_handle) return 0;
if (!mouse_primed || !usb_dev_handle) return 0;
// LAUNCH EDITOR
// 2117030035 S Co:2:039:0 s 21 09 03f0 0001 0004 4 = f0423900
......@@ -1189,21 +1221,8 @@ static int mouse_editmode(void) {
return 1;
}
int main (int argc, char *argv[]) {
t_exit ret = exit_none;
int c;
t_mode mode = mode_COUNT;
// Data structures to store loaded and ready to save mode data
unsigned char mode_data_l[255];
unsigned char mode_data_s[255];
log_init();
help_version();
// FIXME: Help and version shouldn't initialise USB
int mouse_prime(void) {
if (mouse_primed) return exit_none;
// Initialise USB
usb_init();
......@@ -1239,6 +1258,43 @@ int main (int argc, char *argv[]) {
return exit_usberr;
}
mouse_primed = 1;
return exit_none;
}
int mouse_unprime(void) {
if (!mouse_primed) return exit_none;
// Re-attach kernel driver
printf("Attaching kernel driver...\n");
mouse_hid_attach_kernel(usb_interface_index);
// De-initialise mouse
mouse_deinit();
// De-initialise USB
usb_deinit();
mouse_primed = 0;
return exit_none;
}
int main (int argc, char *argv[]) {
t_exit ret = exit_none;
int c;
t_mode mode = mode_COUNT;
// Data structures to store loaded and ready to save mode data
unsigned char mode_data_l[255];
unsigned char mode_data_s[255];
log_init();
help_version();
while (1) {
int option_index = 0;
static struct option long_options[] = {
......@@ -1285,8 +1341,8 @@ int main (int argc, char *argv[]) {
c = getopt_long(argc, argv, "hVs:p:m:r:c:1:2:3:4:5:6:7:8:9:",
long_options, &option_index);
if (c == -1)
break;
// If we've had a previous error, or there's not more options, break
if (ret != exit_none || c == -1) break;
switch (c) {
// Help
......@@ -1326,6 +1382,10 @@ int main (int argc, char *argv[]) {
printf("Mode Selection Specified: %s\n", s_mode[mnew]);
// Initialise USB and mouse, detach kernel driver (if necessary)
// If we cannot, abort (caught at start of loop)
if ((ret = mouse_prime())) continue;
if (mode != mode_COUNT) {
// They've been editing another mode, so save
printf("Saving Mode: %s\n", s_mode[mode]);
......@@ -1360,6 +1420,10 @@ int main (int argc, char *argv[]) {
continue;
}
// Initialise USB and mouse, detach kernel driver (if necessary)
// If we cannot, abort (caught at start of loop)
if ((ret = mouse_prime())) continue;
if (mode != mode_COUNT) {
// They've been editing another mode, so save
printf("Saving Mode: %s\n", s_mode[mode]);
......@@ -1369,8 +1433,9 @@ int main (int argc, char *argv[]) {
printf("Printing Mode: %s\n", s_mode[mnew]);
len = mode_load(&mode_data_p[0], usb_dev_handle, mnew);
mode_print(&mode_data_p[0], len);
if ((len = mode_load(&mode_data_p[0], usb_dev_handle, mnew)) > 0) {
mode_print(&mode_data_p[0], len);
}
}
break;
......@@ -1379,6 +1444,10 @@ int main (int argc, char *argv[]) {
{
t_mode mnew = mode_COUNT;
// Initialise USB and mouse, detach kernel driver (if necessary)
// If we cannot, abort (caught at start of loop)
if ((ret = mouse_prime())) continue;
if (!optarg) {
elog("ERROR: Mode required for modify option\n");
......@@ -1422,8 +1491,9 @@ int main (int argc, char *argv[]) {
mouse_editmode();
mode_load(&mode_data_l[0], usb_dev_handle, mode);
memcpy(&mode_data_s, &mode_data_l, 255);
if (mode_load(&mode_data_l[0], usb_dev_handle, mode) > 0) {
memcpy(&mode_data_s, &mode_data_l, 255);
}
}
break;
......@@ -1523,7 +1593,7 @@ int main (int argc, char *argv[]) {
} // switch (c)
} // while (1)
if (optind < argc) {
if (ret == exit_none && optind < argc) {
char optout[255]
,*po = &optout[0];
......@@ -1542,16 +1612,8 @@ int main (int argc, char *argv[]) {
mode = mode_COUNT;
}
// Re-attach kernel driver
printf("Attaching kernel driver...\n");
mouse_hid_attach_kernel(usb_interface_index);
// De-initialise mouse
mouse_deinit();
// De-initialise USB
usb_deinit();
// Re-attach kernel driver, de-initialise mouse and USB (if necessary)
mouse_unprime();
log_end();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment