Skip to content

Commit

Permalink
hidpp10: Add default profile page in mouse info
Browse files Browse the repository at this point in the history
Different mice load their default profile from different locations. The
default profile page is added to the HID++1.0 mouse info so that the
first profile can be written in the right place.

Only set the value for the G500 and G500s.
More informations are needed for the G9, G9x, G700, G700s.
  • Loading branch information
cvuchener committed Aug 20, 2017
1 parent fc40d45 commit d36da2d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/libhidpp/hidpp/DeviceInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ HIDPP10::MouseInfo G9xInfo = {
HIDPP10::MouseInfo G500Info = {
&HIDPP10::RangeSensor::S9500,
HIDPP10::IResolutionType3,
HIDPP10::G500ProfileType
HIDPP10::G500ProfileType,
2
};

HIDPP10::MouseInfo G500sInfo = {
&HIDPP10::RangeSensor::S9808,
HIDPP10::IResolutionType3,
HIDPP10::G500ProfileType
HIDPP10::G500ProfileType,
5
};

HIDPP10::MouseInfo G700Info = {
Expand Down
7 changes: 5 additions & 2 deletions src/libhidpp/hidpp10/DeviceInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@ namespace HIDPP10
const Sensor *sensor;
IResolutionType iresolution_type;
ProfileType profile_type;
unsigned int default_profile_page;

MouseInfo (const Sensor *sensor,
IResolutionType iresolution_type,
ProfileType profile_type):
ProfileType profile_type,
unsigned int default_profile_page = 2):
HIDPP::DeviceInfo (HIDPP::DeviceInfo::Device),
sensor (sensor),
iresolution_type (iresolution_type),
profile_type (profile_type)
profile_type (profile_type),
default_profile_page (default_profile_page)
{
}
};
Expand Down
10 changes: 5 additions & 5 deletions src/tools/hidpp-persistent-profiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extern "C" {
#include <hidpp20/MemoryMapping.h>
#include <hidpp10/MacroFormat.h>
#include <hidpp20/MacroFormat.h>
#include <hidpp10/DeviceInfo.h>
#include <misc/Log.h>

#include "common/common.h"
Expand Down Expand Up @@ -88,19 +89,21 @@ int main (int argc, char *argv[])
std::unique_ptr<HIDPP::AbstractProfileFormat> profile_format;
std::unique_ptr<HIDPP::AbstractMemoryMapping> memory;
std::unique_ptr<HIDPP::AbstractMacroFormat> macro_format;
HIDPP::Address dir_address;
HIDPP::Address dir_address, prof_address;

/*
* HID++ 1.0
*/
if (major == 1 && minor == 0) {
auto dev = new HIDPP10::Device (std::move (generic_device));
const HIDPP10::MouseInfo *info = HIDPP10::getMouseInfo (dev->productID ());
device.reset (dev);
profdir_format = HIDPP10::getProfileDirectoryFormat (dev);
profile_format = HIDPP10::getProfileFormat (dev);
macro_format = HIDPP10::getMacroFormat (dev);
memory.reset (new HIDPP10::MemoryMapping (dev));
dir_address = HIDPP::Address { 0, 1, 0 };
prof_address = HIDPP::Address { 0, info->default_profile_page, 0 };
}
/*
* HID++ 2.0 and later
Expand All @@ -113,6 +116,7 @@ int main (int argc, char *argv[])
macro_format = HIDPP20::getMacroFormat (dev);
memory.reset (new HIDPP20::MemoryMapping (dev));
dir_address = HIDPP::Address { HIDPP20::IOnboardProfiles::Writeable, 0, 0 };
prof_address = HIDPP::Address { HIDPP20::IOnboardProfiles::Writeable, 1, 0 };
}
else {
fprintf (stderr, "Unsupported HID++ protocol version.\n");
Expand Down Expand Up @@ -151,10 +155,6 @@ int main (int argc, char *argv[])
std::vector<HIDPP::Profile> profiles;
std::vector<std::vector<HIDPP::Macro>> macros;

// The first profile will be written on the page after the directory
HIDPP::Address prof_address = dir_address;
++prof_address.page;

const XMLElement *root = doc.RootElement ();
const XMLElement *element = root->FirstChildElement ("profile");
while (element) {
Expand Down

0 comments on commit d36da2d

Please sign in to comment.